Public Judge

pjudge

Límite de tiempo: 1 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#21686. 【NOIP Round #2】Making Money

Estadísticas

Let $\text{ctz}(x)$ be the number of trailing zeros in the binary representation of $x$, for example, $\text{ctz}(1001000_2)=3$.

Let $\text{ppc}(x)$ be the number of ones in the binary representation of $x$, for example, $\text{ppc}(1001000_2)=2$.

A number is defined as a "good number" if and only if $\text{ctz}(x)=\text{ppc}(x)$.

Given $Q$, there are $Q$ queries. Each query provides an interval $[l,r]$, and you need to find any good number in $[l,r]$, or determine that no such number exists.

Input

The first line contains a positive integer $Q$.

Each of the next $Q$ lines contains two positive integers $l$ and $r$.

Output

For each query, output one line. If there exists a good number in the interval $[l,r]$, output any such good number; otherwise, output $-1$.

Examples

Input 1

5
38 47
57 86
23 24
72 83
32 33

Output 1

-1
68
-1
-1
-1

Input 2

See the provided files.

Output 2

See the provided files.

Constraints

This problem uses bundled subtasks.

For all data, it is guaranteed that $1\le Q\le 10^5$ and $1\le l\le r\le 10^9$.

Subtask ID Special Properties Score
$1$ $1\le l\le r\le 10^7$ $24$
$2$ $l,r$ are chosen randomly in $[1,10^9]$ $34$
$3$ None $42$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.