#include<bits/stdc++.h>
#define PII pair<int, int>
#define l first
#define r second
using namespace std;
PII a[1005];
bool cmp(PII p1, PII p2)
{
return p1.l * p1.r < p2.l * p2.r;
}
int n;
vector<int> ans(1, 0);
vector<int> t(1, 1);
vector<int> m(vector<int> &a, int b)
{
vector<int> res;
int t = 0;
for(int i = 0; i < a.size(); i++)
{
t += a[i] * b;
res.push_back(t % 10);
t /= 10;
}
while(t)
{
res.push_back(t % 10);
t /= 10;
}
return res;
}
vector<int> div(vector<int> &a, int b)
{
vector<int> res;
int r = 0;
for(int i = a.size() - 1; i >= 0; i--)
{
r = 10 * r + a[i];
if(r >= b)
{
res.push_back(r / b);
r %= b;
}
else res.push_back(0);
}
vector<int> res2;
for(int i = res.size() - 1; i >= 0; i--)
res2.push_back(res[i]);
while(res2.back() == 0 && res2.size() > 1) res2.pop_back();
return res2;
}
int com(vector<int> &a, vector<int> &b)
{
if(a.size() != b.size()) return a.size() - b.size();
else
{
for(int i = a.size() - 1; i >= 0; i--)
if(a[i] != b[i]) return a[i] - b[i];
return 0;
}
}
int main()
{
cin >> n;
for(int i = 0; i <= n; i++)
cin >> a[i].l >> a[i].r;
sort(a + 1, a + n + 1, cmp);
t = m(t, a[0].l);
for(int i = 1; i <= n; i++)
{
vector<int> res = div(t, a[i].r);
if(com(ans, res) < 0) ans = res;
t = m(t, a[i].l);
}
for(int i = ans.size() - 1; i >= 0; i --)
cout << ans[i];
}