Perfect match
Hard
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
You are given two integers n and m. Construct such pairs (x, y) from sets A = {0, 1, 2, ..., n − 1} and B = {m, ..., m + n − 1} so that all pairs (x, y) (x ∈ A and y ∈ B) satisfies the condition x & y = x (Here & stands for the bitwise AND operation)
Input
Two integers n and m (1 ≤ n ≤ m, n + m ≤ 10^6
).
Output
Print n lines. In the line i print two integers x[i]
and y[i]
. x[i]
must be in A and y[i]
in B. Each of these pairs that you output must be a matching pair, as specified in the problem statement.
0 ≤
x[i]
≤ n − 1 and for any i ≠ j should bex[i]
≠x[j]
m ≤
y[i]
≤ m + n − 1 and for any i ≠ j should bey[i]
≠y[j]
Examples
Input #1
Answer #1
Input #2
Answer #2
Note
It can be proved that a solution always exists.
Submissions 246
Acceptance rate 11%