#include <bits/stdc++.h>
#define maxN 52
#define maxP 402
#define maxQ 4
#define inf 2000000000
#define e 0.00000001
using namespace std;
int dp[2][maxP * 2 + 2][maxP * 2 + 2], n;
int ipow[maxQ], ppow3, ppow5, Pow3, Pow5;
int x1, Y1, z1, ans, sol[maxP];
int Div(int &a, int x, int y)
{
int res = 0;
while (a % x == 0)
{
++ res;
a /= x;
}
return res;
}
inline int cmp(double x, double y)
{
if(x - y >= e)
return 1;
if(y - x >= e)
return -1;
return 0;
}
void mul(int A[], int B)
{
int i, t = 0;
for (i = 1; i <= A[0] || t; i++, t /= 10)
A[i] = (t += A[i] * B) % 10;
A[0] = i - 1;
}
void read()
{
int a, b, i, j, t, x, y;
freopen("aliens.in", "r", stdin);
scanf("%d", &n);
for (i = 0; i < maxP * 2; ++ i)
for (j = 0; j < maxP * 2; ++ j)
{
dp[0][i][j] = -inf;
dp[1][i][j] = -inf;
}
dp[0][maxP][maxP] = dp[1][maxP][maxP] = 0;
ppow3 = Pow3 = ppow5 = Pow5 = maxP;
t = 0;
for (i = 1; i <= n; ++ i)
{
scanf("%d %d", &a, &b);
t = !t;
ipow[0] = ipow[1] = ipow[2] = 0;
ipow[0] = Div(a, 2, 0) - Div(b, 2, 0);
ipow[1] = Div(a, 3, 1) - Div(b, 3, 1);
ipow[2] = Div(a, 5, 2) - Div(b, 5, 2);
if (ppow3 > ppow3 + ipow[1])
ppow3 += ipow[1];
if (Pow3 < Pow3 + ipow[1])
Pow3 += ipow[1];
if (ppow5 > ppow5 + ipow[2])
ppow5 += ipow[2];
if (Pow5 < Pow5 + ipow[2])
Pow5 += ipow[2];
for (x = ppow3; x <= Pow3; ++ x)
for (y = ppow5; y <= Pow5; ++ y)
dp[t][x][y] = max(dp[!t][x][y], dp[!t][x - ipow[1]][y - ipow[2]] + ipow[0]);
}
}
void solve()
{
int i, j, t = n & 1;
x1 = inf;
for(i = maxP; i <= Pow3; i++){
for(j = maxP; j <= Pow5; j++){
if(dp[t][i][j] != -inf){
if(x1 == inf || (x1 != inf && dp[t][i][j] >= 0 && cmp(dp[t][i][j] * log(2) + (i - maxP) * log(3) + (j - maxP) * log(5) , dp[t][x1][Y1] * log(2) + (x1 - maxP) * log(3) + (Y1 - maxP) * log(5)) == 1)){
x1 = i; Y1 = j;
z1 = dp[t][i][j];
}
}
}
}
}
void write()
{
int i;
freopen("aliens.out", "w", stdout);
sol[++ sol[0]] = 1;
x1 -= maxP;
Y1 -= maxP;
for (i = 1; i <= z1; ++ i)
mul(sol, 2);
for (i = 1; i <= x1; ++ i)
mul(sol, 3);
for (i = 1; i <= Y1; ++ i)
mul(sol, 5);
for (i = sol[0]; i >= 1; -- i)
printf("%d", sol[i]);
}
int main()
{
read();
solve();
write();
return 0;
}