# Magical Boxes

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 k ( 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 k - 1 into one box of side length 2 k, 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.

Input

The first line of input contains an integer n (1 ≤ n ≤ 105), the number of different sizes of boxes Emuskald has. Each of following n lines contains two integers k i and a i (0 ≤ k i ≤ 109, 1 ≤ a i ≤ 109), which means that Emuskald has a i boxes with side length 2 k i. It is guaranteed that all of k i are distinct.

Output

Output a single integer p, such that the smallest magical box that can contain all of Emuskald’s boxes has side length 2 p.

Examples

input

20 31 5

output

3

input

10 4

output

1

input

21 102 2

output

3

Note

Picture explanation. If we have 3 boxes with side length 2 and 5 boxes with side length 1, then we can put all these boxes inside a box with side length 4, for example, as shown in the picture.

In the second test case, we can put all four small boxes into a box with side length 2.

Solution:

#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>

using namespace std;

int n, i, a, b, ans;

int main() {
scanf("%d", &n);
ans = 0;
for (i=0;i<n;i++) {
scanf("%d %d", &a, &b);
if (a+1 > ans) ans = a+1;
b--;
while (b > 0) {
a++;
b >>= 2;
}
if (a > ans) ans = a;
}
printf("%d\n", ans);
return 0;
}