#include <bits/stdc++.h>
using namespace std;
const int N = 2e4 + 10;
struct people{
int a, b;
}ps[N];
int n;
int Len = 4005;
int s[4005], t[4005], ans[4005];
inline bool cmp(people x, people y){
return max(x.a * x.b, y.b) < max(y.a * y.b, x.b);
}
inline void cheng(int d){
for (int i = 1; i <= Len; i++) s[i] *= d;
for (int i = 1; i <= Len; i++){
s[i + 1] += s[i] / 10;
s[i] %= 10;
}
}
inline void chu(int d){
memset(t, 0, sizeof(t));
int r = 0;
for (int i = Len; i >= 1; i--){
r = r * 10 + s[i];
t[i] = r / d;
r %= d;
}
}
inline bool f(){
for (int i = Len; i >= 1; i--){
if (t[i] > ans[i]) return true;
if (t[i] < ans[i]) return false;
}
return false;
}
inline void cop(){
for (int i = 1; i <= Len; i++) ans[i] = t[i];
}
inline void print(){
while (ans[Len] == 0 && Len > 1) Len--;
for (int i = Len; i >= 1; i--) cout << ans[i];
cout << "\n";
}
int main(){
cin >> n;
for (int i = 0; i <= n; i++)
cin >> ps[i].a >> ps[i].b;
sort(ps + 1, ps + 1 + n, cmp);
s[1] = 1;
for (int i = 1; i <= n; i++){
cheng(ps[i - 1].a);
chu(ps[i].b);
if (f()) cop();
}
print();
return 0;
}