#include<iostream>
using namespace std;
int main(){
int n;
cin >> n;
int small;
int t;
for(int i = 1 ; i <= n ; i ++){
int w , d;
cin >> w >> d;
t = (d - 1) * 7 + 1 + w;
if(i == 1){
small = t;
}else{
if(small > t){
small = t;
}
}
}
cout << small;
return 0;
}