#7测试点WA了
#include<bits/stdc++.h>
using namespace std;
const int N = 1005;
struct Man{
int left;
int right;
}man[N];
bool cmp(Man a, Man b){
if(a.left * a.right != b.left * b.right)
return a.left * a.right < b.left * b.right;
else
return a.left < b.left;
}
vector<int> Vmax(vector<int> a, vector<int> b){
if(a.size() != b.size()){
if(a.size() < b.size())
return b;
else
return a;
}
else{
for(int i = 0; i < a.size(); i ++)
if(a[i] != b[i]){
if(a[i] < b[i])
return b;
else
return a;
}
return a;
}
}
vector<int> mul(vector<int> a, int b){
vector<int> c;
int t = 0;
for(int i = 0; i < a.size(); i ++){
t += a[i] * b;
c.push_back(t % 10);
t /= 10;
}
while(t > 0){
c.push_back(t % 10);
t /= 10;
}
return c;
}
vector<int> div(vector<int> a, int b){
vector<int> c;
int t = 0;
bool is_first = true;
for(int i = a.size()-1; i >= 0; i --){
t = t * 10 + a[i];
if(t / b > 0 || is_first == false){
is_first = false;
c.push_back(t / b);
}
t %= b;
}
reverse(c.begin(), c.end());
while(c.size() > 1 && c.back() == 0)
c.pop_back();
return c;
}
void print(vector<int> a){
for(int i = a.size()-1; i >= 0; i --)
cout << a[i];
cout << endl;
}
int main(){
int n;
cin >> n;
for(int i = 0; i <= n; i ++)
cin >> man[i].left >> man[i].right;
sort(man+1, man+n+1, cmp);
vector<int> ans, now;
now.push_back(1);
for(int i = 0; i <= n; i ++){
if(i != 0)
ans = Vmax(ans, div(now, man[i].right));
now = mul(now, man[i].left);
}
print(ans);
return 0;
}