P7207 [COCI 2019/2020 #3] Sob

Background

On a pitch-black Christmas Eve night, a huge reindeer broke in and said to our hero: "I will not leave until you solve this problem."

Description

You are given two positive integers $N, M$. Now you need to combine numbers from the sets $A=\{0,1,2,\cdots,N-1\}$ and $B=\{M,\cdots,M+N-1\}$, and select $N$ ordered pairs $(x_i,y_i)$. The requirements are: - $x_i \in A$, $y_i \in B$, and $x_i \& y_i = x_i$ ($\&$ denotes the bitwise AND operation). - All $x_i$ are pairwise distinct, and all $y_i$ are pairwise distinct.

Input Format

Input two integers $N, M$.

Output Format

Output a total of $N$ lines. On the $i$-th line, output two integers $x_i, y_i$, where $x_i \in A, y_i \in B$. It can be proven that a solution satisfying the conditions always exists.

Explanation/Hint

#### Constraints and Notes | Subtask | Score | Constraints and Notes | | :----------: | :----------: | :----------: | | $1$ | $10$ | $N$ is an integer power of $2$ | | $2$ | $29$ | $N+M$ is an integer power of $2$ | | $3$ | $39$ | $N+M \le 1000$ | | $4$ | $32$ | None | For $100\%$ of the testdata, $1 \le N \le M, N+M \le 10^6$. #### Explanation This problem uses a self-written [Special Judge](https://www.luogu.com.cn/paste/462bmlh1). 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 $110$.** **This problem is translated from [COCI2019-2020](https://hsin.hr/coci/archive/2019_2020/) [CONTEST #3](https://hsin.hr/coci/archive/2019_2020/contest3_tasks.pdf) _T5 Sob_ .** Translated by ChatGPT 5