#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62)/2000;
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
using vi=vector<ll>;


template< class T >
struct CumulativeSum2D {
  vector< vector< T > > data;

  CumulativeSum2D(int W, int H) : data(W + 1, vector< int >(H + 1, 0)) {}

  void add(int x, int y, T z) {
    ++x, ++y;
    if(x >= data.size() || y >= data[0].size()) return;
    data[x][y] += z;
  }

  void build() {
    for(int i = 1; i < data.size(); i++) {
      for(int j = 1; j < data[i].size(); j++) {
        data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
      }
    }
  }

  T query(int sx, int sy, int gx, int gy) {
    return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
  }
};

bool isOK(ll mid,vector<ll>&T,vector<ll>&A){
	ll n=T.size();
	ll a=A[0]*mid;
	ll t=T[0]*mid;
	rep(i,n-1){
		// cout<<i<<" "<<t<<" "<<a<<endl;
		ll t1=t/T[i+1]*T[i+1];
		ll a1=t/T[i+1]*A[i+1];
		// cout<<"t1="<<t1<<" a1="<<a1<<endl;
		if(a1<=a and a1!=0 and t1!=0){
			//ok
			// cout<<"OK"<<endl;
			a=a1;
			t=t1;
			continue;
		}
		t1=a/A[i+1]*T[i+1];
		a1=a/A[i+1]*A[i+1];
		// cout<<"t1="<<t1<<" a1="<<a1<<endl;
		if(t1>t or t1==0 or a1==0)return false;
		// cout<<"OK"<<endl;
		t=t1;
		a=a1;
	}
	// cout<<t<<" "<<a<<endl;
	return true;
}

bool solve(){
	// cout<<INF<<endl;
	ll n;cin>>n;
	vector<ll>T(n);
	vector<ll>A(n);
	rep(i,n)cin>>T[i]>>A[i];
	reverse(all(T));
	reverse(all(A));
	ll right=(1LL<<62)/(A[0]+T[0]);
	// cout<<right<<endl;
	ll left=0;
	while(right-left>1){
		ll mid=(right-left)/2+left;
		if(isOK(mid,T,A))right=mid;
		else left=mid;
	}
	cout<<(A[0]+T[0])*right<<endl;

	return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 256