#15857. [SNCPC2019] Coolbits

    ID: 15857 传统题 3000ms 256MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>P9649贪心2019O2优化陕西进制省赛/邀请赛

[SNCPC2019] Coolbits

[SNCPC2019] Coolbits

题目描述

Given $n$ intervals $[l_1, r_1], [l_2, r_2], \dots, [l_n, r_n]$, one must select an integer from each of the intervals and calculate their bitwise and value $b$. What's the maximum possible $b$ one can get?

输入格式

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

The first line contains an integer nn (1≤n≤1051 \le n \le 10^5), indicating the number of intervals.

For the following nn lines, the ii-th line contains two integers lil_i and rir_i (0≤li≤ri≤1090 \le l_i \le r_i \le 10^9), indicating the ii-th interval.

It's guaranteed that the sum of nn of all test cases will not exceed 10610^6.

输出格式

For each test case output one line containing one integer, indicating the maximum possible $b$ one can get.
2
3
0 8
2 6
3 9
1
1 100
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. 标签: P9649|贪心|2019|O2优化|陕西|进制|省赛/邀请赛

来源

P9649|[SNCPC2019] Coolbits