#P7207. [COCI 2019/2020 #3] Sob

[COCI 2019/2020 #3] Sob

Description

You are given two positive integers N,MN, M.

Now you need to combine numbers from the sets A={0,1,2,,N1}A=\{0,1,2,\cdots,N-1\} and B={M,,M+N1}B=\{M,\cdots,M+N-1\}, and select NN ordered pairs (xi,yi)(x_i,y_i). The requirements are:

  • xiAx_i \in A, yiBy_i \in B, and xi&yi=xix_i \& y_i = x_i (&\& denotes the bitwise AND operation).
  • All xix_i are pairwise distinct, and all yiy_i are pairwise distinct.

Input Format

Input two integers N,MN, M.

Output Format

Output a total of NN lines.

On the ii-th line, output two integers xi,yix_i, y_i, where xiA,yiBx_i \in A, y_i \in B.

It can be proven that a solution satisfying the conditions always exists.

1 3
0 3
3 5
0 7
1 5
2 6
5 10
0 12
1 13
2 10
3 11
4 14

Hint

Constraints and Notes

Subtask Score Constraints and Notes
11 1010 NN is an integer power of 22
22 2929 N+MN+M is an integer power of 22
33 3939 N+M1000N+M \le 1000
44 3232 None

For 100%100\% of the testdata, 1NM,N+M1061 \le N \le M, N+M \le 10^6.

Explanation

This problem uses a self-written Special Judge. You are welcome to hack it (you can send a private message or post directly).

The scoring of this problem follows the original COCI problem settings, with a full score of 110110.

This problem is translated from COCI2019-2020 CONTEST #3 T5 Sob .

Translated by ChatGPT 5