#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int data[100][4];
int total;

int find(int x) {

	int k,small,j = -1;
	small = 50000;

	for(k=0;k<total;k++) {
		if(data[k][0] <= x && data[k][1] > 0) {
			if(small >= data[k][1]) {
				small = data[k][1];
				j = k;
			}
		}
	}
	return j;
}


void run() {

	int i, j, k, l, m;
	for(i = 0;;i++) {
		if(i%10 == 0) {
			j = find(i);
		}
		if(j<0)
			break;
		data[j][1]--;
		if(data[j][1] == 0) {
			data[j][2] = i + 1;
			data[j][3] = i - data[j][0] + 1;
//			printf("task %d,start %d,end %d \n",j,data[j][0],data[j][2]);
		}
	}
	l = 0;
	for(i=0;i<total;i++) {
		l+=data[i][3];
	}
	printf("%d\n",l/total);
}

int main() {
	int x, y;
	while(scanf("%d", &total) == 1 && total) {
		for(int i = 0; i < total; i++)  {
			scanf("%d%d", &x, &y);
			data[i][0] = x; data[i][1] = 10*y;
		}
		run();
	}
}
