Codeforces Round 276 (Div. 1)
A
Bits
Codeforces
1700
原题
←B →
翻译中…

Let's denote as image the number of bits set ('1' bits) in the binary representation of the non-negative integer $*x*$.

翻译中…

You are given multiple queries consisting of pairs of integers $*l*$ and $*r*$. For each query, find the $*x*$, such that $*l* ≤ *x* ≤ *r*$, and image is maximum possible. If there are multiple such numbers find the smallest of them.

翻译中…

Input

翻译中…

The first line contains integer $*n*$ — the number of queries ($1 ≤ *n* ≤ 10000$).

翻译中…

Each of the following $*n*$ lines contain two integers $*l*_{*i*}, *r*_{*i*}$ — the arguments for the corresponding query ($0 ≤ *l*_{*i*} ≤ *r*_{*i*} ≤ 10^{18}$).

翻译中…

Output

翻译中…

For each query print the answer in a separate line.

翻译中…

Note

翻译中…

The binary representations of numbers from 1 to 10 are listed below:

翻译中…

$1_{10} = 1_{2}$

翻译中…

$2_{10} = 10_{2}$

翻译中…

$3_{10} = 11_{2}$

翻译中…

$4_{10} = 100_{2}$

翻译中…

$5_{10} = 101_{2}$

翻译中…

$6_{10} = 110_{2}$

翻译中…

$7_{10} = 111_{2}$

翻译中…

$8_{10} = 1000_{2}$

翻译中…

$9_{10} = 1001_{2}$

翻译中…

$10_{10} = 1010_{2}$

翻译中…

样例

Input #1
3
1 2
2 4
1 10
Output #1
1
3
7
InputCopy OutputCopy
题目信息
题号
484A
时间限制
1 s
内存限制
256 MB
标签
位运算
构造

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。