#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;

P p[300];
int n;
void exec()
{
	cin >> n;
	if(n==0)exit(0);
	for(int i=0;i<n;i++){
		cin >> p[i].first >> p[i].second;
	}
	sort(p,p+n);
	priority_queue<T, vector<T>, greater<T> > l0, l1;
	int m0=0;
	int m1=0;
	for(int i=0;i<n;i++){
		int a=p[i].first;
		int b=p[i].second;
		l0.push(T(a,a,b));
		m0=a;
	}
	while(l0.size()||l1.size()){
		if(l1.size()==0||(l0.size()&&l0.top()<l1.top())){
			T t=l0.top();
			//cout << "0 " << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << endl;
			l0.pop();
			get<0>(t)=m1=max(m1,get<0>(t)+get<1>(t));
			l1.push(t);
		}
		else
		{
			T t=l1.top();
			//cout << "1 " << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << endl;
			l1.pop();
			get<2>(t)--;
			if(get<2>(t)<=0){
				continue;
			}
			get<0>(t)=m0=max(m0,get<0>(t)+get<1>(t));
			l0.push(t);
		}
	}
	cout << m1 << endl;
}
int main() {
	while(1)exec();
}