atcoder#ABC165E. [ABC165E] Rotation Matching

[ABC165E] Rotation Matching

Score : 500500 points

Problem Statement

You are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.) NN players will participate in this competition, and they are given distinct integers from 11 through NN. The arena has MM playing fields for two players. You need to assign each playing field two distinct integers between 11 and NN (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of NN rounds, each of which proceeds as follows:

  • For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.
  • Then, each player adds 11 to its integer. If it becomes N+1N+1, change it to 11.

You want to ensure that no player fights the same opponent more than once during the NN rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.

Constraints

  • 1M1 \leq M
  • M×2+1N200000M \times 2 +1 \leq N \leq 200000

Input

Input is given from Standard Input in the following format:

NN MM

Output

Print MM lines in the format below. The ii-th line should contain the two integers aia_i and bib_i assigned to the ii-th playing field.

a1a_1 b1b_1

a2a_2 b2b_2

::

aMa_M bMb_M

4 1
2 3

Let us call the four players A, B, C, and D, and assume that they are initially given the integers 11, 22, 33, and 44, respectively.

  • The 11-st round is fought by B and C, who has the integers 22 and 33, respectively. After this round, A, B, C, and D have the integers 22, 33, 44, and 11, respectively.
  • The 22-nd round is fought by A and B, who has the integers 22 and 33, respectively. After this round, A, B, C, and D have the integers 33, 44, 11, and 22, respectively.
  • The 33-rd round is fought by D and A, who has the integers 22 and 33, respectively. After this round, A, B, C, and D have the integers 44, 11, 22, and 33, respectively.
  • The 44-th round is fought by C and D, who has the integers 22 and 33, respectively. After this round, A, B, C, and D have the integers 11, 22, 33, and 44, respectively.

No player fights the same opponent more than once during the four rounds, so this solution will be accepted.

7 3
1 6
2 5
3 4