logo AlgoBeat OnlineJudge
登录 注册

#209238. [SNCPC2019] Coolbits

内存限制:256 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Given intervals , one must select an integer from each of the intervals and calculate their bitwise and value . What's the maximum possible one can get?

输入格式

There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:

The first line contains an integer (), indicating the number of intervals.

For the following lines, the -th line contains two integers and (), indicating the -th interval.

It's guaranteed that the sum of of all test cases will not exceed .

输出格式

For each test case output one line containing one integer, indicating the maximum possible one can get.

样例

样例输入 1

2
3
0 8
2 6
3 9
1
1 100

样例输出 1

6
100

数据范围与提示

For the first sample test case, one can select 7, 6 and 7 from the three intervals and get their bitwise and value 6.