Emuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in packing the boxes inside other boxes.

From the top view each magical box looks like a square with side length equal to 2<sup class="upper-index">*k*</sup> (*k* is an integer, *k* ≥ 0) units. A magical box *v* can be put inside a magical box *u*, if side length of *v* is strictly less than the side length of *u*. In particular, Emuskald can put 4 boxes of side length 2<sup class="upper-index">*k* - 1</sup> into one box of side length 2<sup class="upper-index">*k*</sup>, or as in the following figure:

Emuskald is about to go on tour performing around the world, and needs to pack his magical boxes for the trip. He has decided that the best way to pack them would be inside another magical box, but magical boxes are quite expensive to make. Help him find the smallest magical box that can fit all his boxes.
The first line of input contains an integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>), the number of different sizes of boxes Emuskald has. Each of following *n* lines contains two integers *k*<sub class="lower-index">*i*</sub> and *a*<sub class="lower-index">*i*</sub> (0 ≤ *k*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>, 1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>), which means that Emuskald has *a*<sub class="lower-index">*i*</sub> boxes with side length 2<sup class="upper-index">*k*<sub class="lower-index">*i*</sub></sup>. It is guaranteed that all of *k*<sub class="lower-index">*i*</sub> are distinct.
import math
t=int(input())
ans=-1
maxi=-1
for i in range(t):
    k,a=map(int,input().split())
    h=k+math.ceil(math.log(a,4))
    ans=max(ans,h)
    maxi=max(maxi,k)
print(max(ans,maxi+1))
