#include <bits/stdc++.h>
#define maxN 52
#define maxP 402
#define maxQ 4
#define inf 2000000000
using namespace std;
int dp[2][maxP * 2 + 2][maxP * 2 + 2], n;
int ipow[maxN][maxQ], pow3, pow5;
int x1, Y1, z1, ans, sol[maxP];
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;
freopen("aliens.in", "r", stdin);
scanf("%d", &n);
for (i = 1; i <= n; ++ i)
{
scanf("%d %d", &a, &b);
while (a % 2 == 0)
{
++ ipow[i][0];
a /= 2;
}
while (a % 3 == 0)
{
++ ipow[i][1];
a /= 3;
}
while (a % 5 == 0)
{
++ ipow[i][2];
a /= 5;
}
while (b % 2 == 0)
{
-- ipow[i][0];
b /= 2;
}
while (b % 3 == 0)
{
-- ipow[i][1];
b /= 3;
}
while (b % 5 == 0)
{
-- ipow[i][2];
b /= 5;
}
pow3 += ipow[i][1];
pow5 += ipow[i][2];
}
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;
}
void solve()
{
int i, t, x, y;
t = 0;
ans = -inf;
for (i = 1; i <= n; ++ i)
{
for (x = max(0, ipow[i][1]); x < 2 * maxP - 3 && x - ipow[i][1] < 2 * maxP - 3; ++ x)
for (y = max(0, ipow[i][2]); y < 2 * maxP - 3 && y - ipow[i][2] < 2 * maxP - 3; ++ y)
if (dp[t][x - ipow[i][1]][y - ipow[i][2]] != -inf || dp[t][x][y] != -inf)
{
if (dp[1 - t][x][y] < dp[t][x - ipow[i][1]][y - ipow[i][2]] + ipow[i][0])
dp[1 - t][x][y] = dp[t][x - ipow[i][1]][y - ipow[i][2]] + ipow[i][0];
if (dp[1 - t][x][y] < dp[t][x][y])
dp[1 - t][x][y] = dp[t][x][y];
int x2 = dp[1 - t][x][y],
y2 = x,
z2 = y;
if (ans < (x2 * log(2) + y2 * log(3) + z2 * log(5)) && x2 >= 0 && y2 >= maxP && z2 >= maxP)
{
ans = x2 * log(2) + y2 * log(3) + z2 * log(5);
x1 = x2;
Y1 = y2 - maxP;
z1 = z2 - maxP;
}
}
t = 1 - t;
}
}
void write()
{
int i;
freopen("aliens.out", "w", stdout);
sol[++ sol[0]] = 1;
for (i = 1; i <= x1; ++ i)
mul(sol, 2);
for (i = 1; i <= Y1; ++ i)
mul(sol, 3);
for (i = 1; i <= z1; ++ i)
mul(sol, 5);
for (i = sol[0]; i >= 1; -- i)
printf("%d", sol[i]);
}
int main()
{
read();
solve();
write();
return 0;
}