{"problem":{"name":"[SNCPC2019] Coolbits","description":{"content":"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 ca","description_type":"Markdown"},"platform":"Luogu","limit":{"time_limit":3000,"memory_limit":262144},"difficulty":{"LuoguStyle":"P3"},"is_remote":true,"is_sync":true,"sync_url":null,"sign":"LGP9649"},"statements":[{"statement_type":"Markdown","content":"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?\n\n## Input\n\nThere are multiple test cases. The first line of the input contains an integer $T$, indicating the number of test cases. For each test case:\n\nThe first line contains an integer $n$ ($1 \\le n \\le 10^5$), indicating the number of intervals.\n\nFor the following $n$ lines, the $i$-th line contains two integers $l_i$ and $r_i$ ($0 \\le l_i \\le r_i \\le 10^9$), indicating the $i$-th interval.\n\nIt's guaranteed that the sum of $n$ of all test cases will not exceed $10^6$.\n\n## Output\n\nFor each test case output one line containing one integer, indicating the maximum possible $b$ one can get.\n\n[samples]\n\n## Note\n\nFor the first sample test case, one can select 7, 6 and  7 from the three intervals and get their bitwise and value 6.","is_translate":false,"language":"English"}],"meta":{"iden":"LGP9649","tags":["贪心","2019","O2优化","陕西","进制","省赛/邀请赛"],"sample_group":[["2\n3\n0 8\n2 6\n3 9\n1\n1 100\n","6\n100\n"]],"created_at":"2026-03-03 11:09:25"}}