Problem:
 Score : 500 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.)  N players will participate in this competition, and they are given distinct integers from 1 through N .
The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).
You cannot assign the same integer to multiple playing fields.
The competition consists of N 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 1 to its integer. If it becomes N+1 , change it to 1 .   You want to ensure that no player fights the same opponent more than once during the N 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  1 \leq M  M \times 2 +1 \leq N \leq 200000         Input Input is given from Standard Input in the following format:  N  M       Output Print M lines in the format below.
The i -th line should contain the two integers a_i and b_i assigned to the i -th playing field.  a_1  b_1  a_2  b_2  :  a_M  b_M         Sample Input 1 4 1      Sample Output 1 2 3  Let us call the four players A, B, C, and D, and assume that they are initially given the integers 1 , 2 , 3 , and 4 , respectively.    The 1 -st round is fought by B and C, who has the integers 2 and 3 , respectively. After this round, A, B, C, and D have the integers 2 , 3 , 4 , and 1 , respectively.    The 2 -nd round is fought by A and B, who has the integers 2 and 3 , respectively. After this round, A, B, C, and D have the integers 3 , 4 , 1 , and 2 , respectively.    The 3 -rd round is fought by D and A, who has the integers 2 and 3 , respectively. After this round, A, B, C, and D have the integers 4 , 1 , 2 , and 3 , respectively.    The 4 -th round is fought by C and D, who has the integers 2 and 3 , respectively. After this round, A, B, C, and D have the integers 1 , 2 , 3 , and 4 , respectively.    No player fights the same opponent more than once during the four rounds, so this solution will be accepted.       Sample Input 2 7 3      Sample Output 2 1 6
2 5
3 4

Solution (Python):
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)

MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

N,M = MI()
for i in range(M):
    if N%4==0 and i >= N/4:
        print((-i)%N + 1,3+i)
    elif N%2==0 and 2*i+1 >= N/2:
        print((-i)%N + 1,3+i)
    else:
        print((-i)%N + 1,2+i)

Solution (Python):
N, M = map(int, input().split())


l, r = 1, N // 2
while M and l < r :
  print(l, r)
  l += 1
  r -= 1
  M -= 1
  

l, r = N // 2 + 2 - N % 2, N
while M :
  print(l, r)
  l += 1
  r -= 1
  M -= 1

Solution (Python):
def main():
    N,M=map(int,input().split())
    if N%2!=0:
        for i in range(1,M+1):
            print(i,N-i+1)
    else:
        for i in range(1,(M+1)//2+1):
            print(i,N-i+1)
        for i in range((M+1)//2+1,M+1):
            print(i,N-i)
if __name__=='__main__':
    main()

Solution (Python):
n,m = map(int,input().split())
ans=[]
if m%2==1:
  for i in range(m//2):
    print(i+1,m-i)
  for i in range(m//2+1):
    print(m+1+i,2*m+1-i)
else:
  for i in range(m//2):
    print(i+1,m-i+1)
  for i in range(m//2):
    print(m+2+i,2*m+1-i)

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M = map(int, readline().split())

    if N % 2 == 1:
        for i in range(M):
            print(i + 1, N - i)
    else:
        for i in range(M):
            if i < M / 2:
                print(i + 1, N - i)
            else:
                print(i + 2, N - i)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import deque

def main():
    N, M = map(int, input().split())

    table_num = deque()
    if N % 2 == 1:
        for i in range(1, M+1):
            table_num.append('%s %s' % (i, N-i))

    else:
        for i in range(1, M+1):
            if i <= N // 4:
                table_num.append('%s %s' % (i, N+1 - i))

            else:
                table_num.append('%s %s' % (i, N - i))
    
    for i_table in table_num:
        print(i_table)
    
    return

if __name__ == '__main__':
    main()

Solution (Python):

def resolve():
    N, M = map(int, input().split())
    if N%2==1:
        for i in range(1, M+1):
            a, b = i, N-i
            print(a, b)
    else:
        for i in range(1, M+1):
            a, b = i, N - i
            
            if b-a <= N//2:
                a += 1
            print(a, b)

if __name__ == "__main__":
    resolve()

Solution (Python):

import sys


def solve(N: int, M: int):
    if M % 2 == 0:
        for m in range(1, M+1):
            if m % 2 == 1:
                k = (m+1) // 2
                print(k, M+1-k)
            elif m % 2 == 0:
                k = m // 2
                print(M+k, 2*M+2-k)
    if M % 2 == 1:
        for m in range(1, M+1):
            if m % 2 == 1:
                k = (m+1) // 2
                print(k, M+2-k)
            elif m % 2 == 0:
                k = m // 2
                print(M+1+k, 2*M+2-k)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    solve(N, M)

if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())

if N % 2 == 0:
    N -= 1

li = []
i, j = 1, (N + 1) // 2
while i < j:
    li.append((i, j))
    i += 1
    j -= 1
i, j = N, (N + 3) // 2
while i > j:
    li.append((j, i))
    i -= 1
    j += 1

for m in range(M):
    print(li[m][0], li[m][1])

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
ge = []
l = 1
r = n-1
for i in range(m):
    if i%2:
        ge.append(l)
    else:
        ge.append(r)
    l += 1; r -= 1
ge.sort(reverse = True)
for i in range(m):
    print(i+1,i+1+ge[i])

Solution (Python):
N, M = map(int, input().split())

M_f = M * 2 + 1
if M % 2 != 0:
    for i in range(0, M // 2):
        print(i + 1, (M) - i)
    for i in range(0, M // 2 + 1):
        print(M + 1 + i, M_f - i)
else:
    for i in range(0, M // 2):
        print(i + 1, (M + 1) - i)
    for i in range(0, M // 2):
        print(M + 2 + i, M_f - i)

Solution (Python):
N, M = map(int, input().split())

for i in range((M+1)// 2):
    print(1+i, (M+1)//2*2 - i)

for j in range(M//2):
    print((M+1)//2*2+1 + j, 2*M + 1 - j)

Solution (Python):
N,M=map(int, input().split())
d=set()
a,b=1,N
for _ in range(M):
    print(a,b)
    d.add(b-a)
    d.add(N-b+a)
    a+=1
    b-=1
    while b-a in d or N-b+a in d or b-a == N-b+a: b-=1

Solution (Python):
n, m = map(int, input().split())
if n % 2 != 0:
    for i in range(m):
        print(i + 1, n - i)
else:
    for i in range(m):
        if i < m / 2:
            print(i + 1, n - i)
        else:
            print(i + 1, n - i - 1)

Solution (Python):
N, M = map(int, input().split())
if M & 1:
    print(M, M+1)
m=M//2
for i in range(m):
    print(i+1, (-2-i)%N+1)
    print(i+m+1, 2*M-m-i)

Solution (Python):
N,M=map(int,input().split())

a,b=1,N//2
c,d=N//2+1,N
if N%2==0:
    a+=1
i=0
while i<M:
    if i<M:
        print(c,d)
        i+=1        
        c,d=c+1,d-1
    else:
        break
    if i<M:
        print(a,b)
        a,b=a+1,b-1
        i+=1
    else:
        break

Solution (Python):
N,M=map(int,input().split())
if N%2==1:
    for i in range(1,M+1):
        a,b=i,N-i+1
        print(a,b)
else:
    t=0
    for i in range(1,M+1):
        a,b=i,N-i
        if (a-1)+(N+1-b)>=b-a:
            t=1
        a+=t
        print(a,b)

Solution (Python):
N,M=map(int,input().split())
if N%2==1:
    for i in range(1,M+1):
        a,b=i,N-i
        print(a,b)
else:
    for i in range(1,M+1):
        a,b=i,N-i
        if b-a<=N//2:
            a+=1
        print(a,b)

Solution (Python):
N, M = map(int, input().split())

A = list(range(M))
B = list(range(M, 2*M))[::-1]
B = [-2-i for i in range(M//2)] + B[M//2:]

for a, b in zip(A, B):
    print(a % N + 1, b % N + 1)

Solution (Python):
def e_rotation_matching():
    N, M = [int(i) for i in input().split()]

    if N % 2 == 1:
        ans = [(left, N - left) for left in range(1, (N // 2) + 1)]
    else:
        ans = []
        flag = False
        left, right = 1, N - 1
        while left < right:
            if not flag and right - left <= N // 2:
                right -= 1
                flag = True
            ans.append((left, right))
            left += 1
            right -= 1
    return '\n'.join([f'{a} {b}' for a, b in ans[:M]])

print(e_rotation_matching())

Solution (Python):
N,M = map(int, input().split())
ans = []
if N%2==1:
  for i in range(2,N//2+2):
    ans.append((i,N+2-i))
else:
  l = 2
  r = N
  while r-l>N//2:
    ans.append((l,r))
    l += 1
    r -= 1
  l += 1
  while r>l:
    ans.append((l,r))
    l += 1
    r -= 1
for i in range(M):
  print(*ans[i])

Solution (Python):
n,m = map(int, input().split())
a = (n-1) // 2
d = 1
memo = set([])
for i in range(m):
    if n-d in memo or 2*d == n:
        d += 1
    memo.add(d)
    print(a, a+d)
    a -= 1
    d += 2

Solution (Python):
N, M = map(int, input().split())

if N & 1:
    for m in range(1, M+1):
        print(m, N-m)

    exit()

n1, n2 = N//2, N//2
cnt = 0
for n in range(N//2):
    if n+1 >= N//2-n:
        break
    print(n+1, N//2-n)
    cnt += 1
    if cnt == M:
        exit()

for n in range(N//2):
    if n+1 >= N//2-n-1:
        break
    print(n+1+N//2, N-n-1)
    cnt += 1
    if cnt == M:
        exit()

Solution (Python):
n, m = map(int, input().split())

if n % 2 == 1:
    for i in range(1, m+1):
        print(i, n-i)
else:
    for i in range(1, m+1):
        if (n - i - i) > (n // 2):
            print(i, n-i)
        else:
            print(i+1, n-i)

Solution (Python):
N,M=map(int,input().split())
l=1
r=N
dis=set()
if N%2==1:
    for i in range(M):
        print(l,r)
        l=l+1
        r=r-1
else:
    for _ in range(M):
        print(l,r)
        a,b=r-l,N+l-r
        dis.add(a)
        dis.add(b)
        l=l+1
        r=r-1
        if r-l in dis or N+l-r in dis or r-l==N+l-r:
            r=r-1

Solution (Python):



N, M = list(map(int, input().split()))


def solve1():
    return [(i + 2, N - i) for i in range(M)]        



def solve2():
    t = (N - 2) // 4
    l = [(i + 2, N - i) for i in range(t)]
    n = (N - 2) // 2 - t
    l = l + [(N // 2 + 1 + i, N // 2 - i) for i in range(n)]
    return l[:M]


def main():
    l = solve1() if N % 2 else solve2()
    for ans in l:
        print(*ans)
    

if __name__ == "__main__":
    main()

Solution (Python):
n, m = map(int, input().split())
for i in range(1, m+1):
    a, b = i, n-i+1
    if not n % 2 and b-a <= n//2: print(a, b-1)
    else: print(a, b)

Solution (Python):
n, m = map(int, input().split())

if n%2:
  k1, k2 = n//2, n//2+1
  for i in range(m):
    print(k1, k2)
    k1 -= 1
    k2 += 1
else:
  key = [False]*(n)
  key[0] = True
  for i in range(1, n):
    if i == n//2-1 or key[i-1] or key[n-2-i]:
      continue
    key[i] = True
  k1, k2 = n//2, n//2+1
  count = 0
  for i in range(n-1):
    if key[i]:
      print(k1, k2)
      count += 1
    if i%2:
      k1 -= 1
    else:
      k2 += 1
    if count == m:
      break

Solution (Python):
n,m = map(int,input().split())
a = 0
for i in range(m):
    if n % 2 == 0 and n % 4 != 0 and n-4*i-2 == 0:
        a = 1
    elif n % 4 == 0 and i == (n//2-1) // 2 + 1:
        a = 1
    print('{} {}'.format(i+1, n-i-a))

Solution (Python):
n,m=map(int,input().split())
diffs=set()
idxs=set()
i=1
diff=n-1
cnt=0
while 1:
    if i>m:
      break
    while (diff in diffs and n-diff in diffs) or (i+diff in idxs) or (diff==n-diff):
        diff-=1
    diffs.add(n-diff)
    diffs.add(diff)
    idxs.add(i+diff)
    print(i,i+diff)
    i+=1

Solution (Python):
n, m = map(int, input().split())
if n % 2 != 0:
    for i in range(m):
        print(i + 1, n - i)
else:
    for i in range(m):
        if i < m / 2:
            print(i + 1, n - i)
        else:
            print(i + 1, n - i - 1)

Solution (Python):
n,m=map(int,input().split())
if n%2==1:
    [print(i+1,n-i) for i in range(m)]
else:
    [print(i+1,n-i) if i<m/2 else print(i+1,n-i-1) for i in range(m)]

Solution (Python):
N,M = map(int, input().split())

M1 = M//2
M2 = M-M1

for i in range(M1):
    a=i+1
    b=2*M1+1-i
    print(a,b)
for i in range(M2):
    a=i+1
    b=2*M2-i
    print(2*M1+1 + a,2*M1+1 + b)

Solution (Python):
n, m = map(int, input().split())

a = (n - 1) // 2
d = 1
memo = set([])
cnt = 0
for i in range(m):

    if (n - d in memo) or (2*d == n):
        cnt += 1
        d += 1
    memo.add(d)
    if cnt > 1 or a < 1 or a+d > n:
        print(1/0)
    print(a, a+d)
    a -= 1
    d += 2

Solution (Python):
import sys
import math
input = lambda:sys.stdin.readline().strip()
n,m = map(int,input().split())
k = 0
j = 0
for i in range(m):
    if n%2==0 and ((n-j)-(i+1))*2<=n and k==0:
        j+=1
        k+=1
    print(i+1,n-j)
    j+=1

Solution (Python):
n, m = map(int, input().split())

if n % 2 == 1:
    a = [i for i in range(1, m+1)]
    b = [i for i in reversed(range(m+1, 2*m+1))]
    ab = [(x, y) for x, y in zip(a, b)]
else:
    ab = []
    x, y = (n-1)//2, n//2
    if x % 2 != 0:
        x, y = y, x

    evenl = 1
    evenr = x
    while evenl < evenr:
        ab.append((evenl, evenr))
        evenl += 1
        evenr -= 1

    oddl = x+1
    oddr = n-1
    while oddl < oddr:
        ab.append((oddl, oddr))
        oddl += 1
        oddr -= 1

    ab = ab[:m]


for a, b in ab:
    print(a, b)

Solution (Python):
import sys
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    cl = []
    for i in range(M//2):
        cl.append((i+1,(M//2)*2+1-i))
    for i in range(-(-M//2)):
        l = (M//2)*2+i+2
        cl.append((l,l+(-(-M//2)-i)*2-1))
    
    for i in range(M):
        print(*cl[i])
    
if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, M = map(int, input().split())
res = []

def solve(l, r):
  global res
  if r <= l: return
  res.append((l, r))
  solve(l + 1, r - 1)


solve(1, M + 1)
solve(M + 2, M * 2 + 1)
for r in res: print(*r)

Solution (Python):
n,m=map(int,input().split())
g=m//2
k=m-g
for i in range(m):
    if i%2==1:
        a=n-g-((i+1)//2)
        b=a+i+1
        print(a,b)
    else:
        a=k-(i//2)
        b=a+i+1
        print(a,b)

Solution (Python):
n, m = map(int,input().split())

if n%2 == 1:
    for i in range(m):
        print(n//2-i,n//2+i+1)
else:
    ni = 1
    l = 1
    r = n
    while ni <= n//4 and ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1
    r -= 1
    while ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1

Solution (Python):
n, m = map(int, input().split())

if m%2 == 0:
    gu_max, ki_max = m, m-1
else:
    gu_max, ki_max = m-1, m
gu_start = 1
ki_start = 1 + gu_max + 1

for sa in range(m)[::-1]:
    sa += 1
    if sa%2 == 0:
        print(gu_start, gu_start+sa)
        gu_start += 1
    else:
        print(ki_start, ki_start+sa)
        ki_start += 1

Solution (Python):
n,m = map(int,input().split())
if n%2 ==1:
    for i in range(1,m+1):
        print(i,n-i)
else:
    left_end = 1+m if m%2 == 1 else m
    left_start = left_end//2
    right_start = left_end+m//2
    for i in range(1,m+1):
        if i%2 == 1:
            print(left_start,left_start+i)
            left_start-=1
        else:
            print(right_start,right_start+i)
            right_start-=1

Solution (Python):
N, M = map(int, input().split())
assert 2*M+1 <= N

if M % 2 == 1:
    step_m1 = M
    step_m2 = M - 1
else:
    step_m1 = M - 1
    step_m2 = M
assert step_m1 + 1 + step_m2 + 1 <= N
ans = []
a = 0
for step in range(step_m1, -1, -2):


    ans.append([a+1, a+step+1])
    a += 1
a = step_m1 + 1
for step in range(step_m2, 0, -2):


    ans.append([a+1, a+step+1])
    a += 1
print('\n'.join(map(lambda L: ' '.join(map(str, L)), ans)))

Solution (Python):
def e_rotation_matching():
    
    import numpy as np
    N, M = [int(i) for i in input().split()]

    A = np.arange(M)  
    B = 2 * M - 1 - A  
    
    B[:M // 2] -= (2 * M + 1)

    A %= N  
    B %= N
    A += 1  
    B += 1
    return '\n'.join([f'{a} {b}' for a, b in zip(A.tolist(), B.tolist())])

print(e_rotation_matching())

Solution (Python):
def main():
    n,m=map(int,input().split())
    if n%2==1:
        x=[f"{i+1} {n-i}" for i in range(m)]
        print(" ".join(x))
    else:
        x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
        print(" ".join(x))

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n,m=map(int,input().split())
    if n%2==1:
        x=[f"{i+1} {n-i}" for i in range(m)]
        print(" ".join(x))
    else:
        x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
        print(" ".join(x))

if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split())
if n%2==1:
    x=[f"{i+1} {n-i}" for i in range(m)]
    print(" ".join(x))
else:
    x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
    print(" ".join(x))

Solution (Python):
N, M = map(int, input().split())
if M%2 != 0:
    center = M + 1
else:
    center = M
c = center//2
d = (center + 1 + 2*M + 1) // 2

i = 0
while i < c:
    print(c-i, c+1+i)
    i += 1
j = 0
while i < M:
    print(d-(j+1), d+(j+1))
    i += 1
    j += 1

Solution (Python):
n, m = map(int, input().split())

from collections import deque

l = deque([i for i in range(1, n + 1)])

if n % 2 ==0:
    for i in range(1, m + 1):
        a, b = l.popleft(), l.pop()
        if (b - a) == n / 2 or (len(l) < n // 2 and (b-a) % 2 == 1):
            b = l.pop()
        print(a, b)
else:
    for i in range(1, m + 1):
        print(i, n - i)

Solution (Python):
n,m=map(int,input().split())
if n%2==1:
    x=""
    for i in range(m):
        x+=f"{i+1} {n-i} "
    print(x)
else:
    x=""
    for i in range(m):
        x+=(f"{i+1} {n-i} " if i<m/2 else f"{i+1} {n-i-1}\n")
    print(x)

Solution (Python):
n,m=map(int,input().split())
if n%2==1:
    x=""
    for i in range(m):
        x+=f"{i+1} {n-i}\n"
    print(x)
else:
    x=""
    for i in range(m):
        x+=(f"{i+1} {n-i}\n" if i<m/2 else f"{i+1} {n-i-1}\n")
    print(x)

Solution (Python):

"""
各頂点を円形に並べた時に、距離が等しくならないようにm個の辺を張れば良い。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,m = map(int,readline().split())
mod = n
lst1 = []
for i in range(m):
    lst1.append(i)

lst2 = []
for i in range(m):
    lst2.append(2*m-1-lst1[i])

for i in range(m//2):
    lst2[i] -= 2*m+1

for i,j in zip(lst1,lst2):
    print(i%mod+1,j%mod+1)

Solution (Python):
N, M = map(int,input().split())
if N%2 == 1:
    for i in range(1,M+1):
        print(i,N+1-i)
else:
    for i in range(1,M+1):
        if i == N//4+1:
            break
        print(i,N+1-i)
        if i == M:
            quit()
    for j in range(i,M+1):
        print(j+1,N+1-j)

Solution (Python):
n,m=map(int,input().split())
if n%2==1:
    [print(i+1,n-i) for i in range(m)]
else:
    [print(i+1,n-i) if i<m/2 else print(i+1,n-i-1) for i in range(m)]

Solution (Python):
n,m=map(int,input().split())
if n%2==1:
    
    x=[f"{i+1} {n-i}" for i in range(m)]
    print(" ".join(x))
else:
    
    x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
    print(" ".join(x))

Solution (Python):
n,m=map(int,input().split())
if n%2==1:
    
    x=[f"{i+1} {n-i}" for i in range(m)]
    print("\n".join(x))
else:
    
    x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
    print("\n".join(x))

Solution (Python):
n,m=map(int,input().split())
if n%2==1:
    x=["{} {}".format(i+1,n-i) for i in range(m)]
    
    print(" ".join(x))
else:
    x=["{} {}".format(i+1,n-i) if i<m/2 else "{} {}".format(i+1,n-i-1) for i in range(m)]
    
    print(" ".join(x))

Solution (Python):
n,m=map(int,input().split())
if n%2==1:
    x=[f"{i+1} {n-i}" for i in range(m)]
    print(" ".join(x))
else:
    x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
    print(" ".join(x))

Solution (Python):
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())

    if N % 2 == 0:
        for i in range(M):
            x = i + 1
            y = N - i - 1
            if y - x > (N - y + x):
                print(x, y)
            else:
                print(x, y - 1)
    else:
        for i in range(M):
            print(i + 1, N - i)


if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split());[print(i+1,n-i-((i>=m/2)&~n)) for i in range(m)]

Solution (Python):
n,m=map(int,input().split());[print(i+1,n-i-((i>=m/2)&~n)) for i in range(m)]

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
def main():
    n,m = map(int,input().split())
    x = m//2
    y = m - x
    for i in range(x):
        print(i+1,2*x+1-i)
    for i in range(y):
        print(2*x+2+i,2*x+2*y+1-i)
    
if __name__ == "__main__":
    main()

Solution (Python):
n,m = map(int,input().split())
if m%2 == 1:
    a = 1
    b = a+2*(m//2)+2
    for i in range(m//2+1):
        print(a,a+2*(m//2-i)+1)
        a += 1
    for i in range(m//2):
        print(b,b+2*(m//2-i))
        b += 1
else:
    a = 1
    b = a+2*(m//2)+1
    for i in range(m//2):
        print(a,a+2*(m//2-i))
        a += 1
    for i in range(m//2):
        print(b,b+2*(m//2-i-1)+1)
        b += 1

Solution (Python):


N, M = map(int, input().split())

if N%2:
    for i in range(M):
        print(i+1, N-(i))
else:
    for i in range(M):
        if (i+1)+(N-(N-(i+1))) < N-(i+1)-(i+1):
            print(i+1, N-(i+1))
        else:
            print(i+2, N-(i+1))

Solution (Python):
import sys
N,M = map(int,input().split())


if N%2 == 1:
    for i in range(1,M+1):
        print(i,N-i+1)

elif N%4 == 0:
    total = 0
    count = 1
    for i in range(N//4,0,-1):
        print(i,i+count)
        count += 2
        total += 1
        if total >= M:
            sys.exit()
    count = 2
    for i in range(3*(N//4)-1,N//2,-1):
        print(i,i+count)
        count += 2
        total += 1
        if total >= M:
            sys.exit()
else:
    total = 0
    count = 1
    for i in range(N//4,0,-1):
        print(i,i+count)
        count += 2
        total += 1
        if total >= M:
            sys.exit()
    count = 2
    for i in range(3*(N//4),N//2-1,-1):
        print(i,i+count)
        count += 2
        total += 1
        if total >= M:
            sys.exit()

Solution (Python):
n, m = map(int, input().split())
mod = lambda x:x%n+1
for i in range((m+1)//2):
    print(mod(-i-(m+1)//2), mod(i+1-(m+1)//2))
for i in range(m//2):
    print(mod(-i+m//2), mod(i+2+m//2))

Solution (Python):
N, M = map(int, input().split())

for i in range(M//2):
    print(i+1, M-i)

for i in range((M+1)//2):
    print (M+1+i,2*M+1-i)

Solution (Python):
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    n,m = map(int,input().split())
    ans = [[0]*2 for _ in range(m)]
    cnt = 1
    if n%2 == 1:
        for i in range(m):
            ans[i][0] = cnt
            cnt += 1
        for i in range(m - 1,-1,-1):
            ans[i][1] = cnt
            cnt += 1
        for i in range(m):
            print(*ans[i])
    else:
        for i in range(m):
            ans[i][0] = cnt
            cnt += 1
        cnt = n
        flag = True
        for i in range(m):
            if flag and cnt - ans[i][0] <= n//2:
                flag = False
                cnt -= 1
            ans[i][1] = cnt
            cnt -= 1
        for i in range(m):
            print(*ans[i])
if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, read().split())
if n % 2 == 1:
    for i in range(1, m + 1):
        print(i, n - i)
else:
    x, y = 0, 0
    for i in range(m):
        a, b = 2 * i, n - 2 * (i + 1)
        if a == b or (a == y and b == x):
            n -= 1
        x, y = a, b
        print(i + 1, n - i)

Solution (Python):
N, M = map(int, input().split())

ans = []
if M%2 == 0:
    for i in range(1, M//2+1):
        ans.append([i, M+1-i])
        ans.append([M+i, 2*M+2-i])
else:
    for i in range(1, M//2+1):
        ans.append([i, M+1-i])
    for i in range(1, (M+1)//2+1):
        ans.append([M+i, 2*M+2-i])

for i in range(len(ans)):
    print(*ans[i])

Solution (Python):
n, m = map(int, input().split())

def out(s, e):
    while s < e:
        print("{} {}".format(s, e))
        s += 1
        e -= 1

odd = m % 2
out(1, m + odd)
out(m + 1 + odd, 2 * m + 1)

Solution (Python):
n, m = map(int, input().split())

def out(s, e):
    while s < e:
        print("{} {}".format(s, e))
        s += 1
        e -= 1

if m % 2 == 0:
    out(1, m)
    out(m + 1, 2 * m + 1)
else:
    out(1, m + 1)
    out(m + 2, 2 * m + 1)

Solution (Python):
n, m = map(int, input().split())
if m%2 == 0:
  x = m//2
  y = m//2
else:
  x = m//2
  y = m//2+1
for i in range(x):
  print(i+1, 2*x+1-i)
for i in range(y):
  print(i+2*x+2, 2*y+2*x+1-i)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,m=MI()
    if n%2:
        for i in range(m):
            print(1+i,n-i)
    else:
        i=1
        j=n//2
        while m and i<j:
            print(i,j)
            i+=1
            j-=1
            m-=1

        i=n//2+2
        j=n
        while m and i<j:
            print(i,j)
            i+=1
            j-=1
            m-=1

main()

Solution (Python):
n,m=map(int,input().split())
for i in range(m):print(i+1,n-i-((i>=m/2)&~n))

Solution (Python):
n,m=map(int,input().split())
for i in range(m):print(i+1,n-i-((i>=m/2)&~n))

Solution (Python):
N, M = map(int, input().split())

def sol(N):
    if N == 1:
        return []

    N += 1
    ans = [[] for _ in range(N)]

    K = 0
    for i, n in enumerate(range(1, N // 2)):
        ans[i].append(n)
        K += 1
    for i, n in enumerate(range(N // 2, N - 1)):
        ans[K - 1 - i].append(n)

    return ans

if N % 2 == 1:
    ans = sol(N)
    for a in ans[:M]:
        print(*a)
else:
    L = N // 2
    ans = []

    if L % 2 == 0:
        for a in sol(L + 1):
            if len(a) == 0:
                continue
            ans.append(a)
        for a in sol(L - 1):
            if len(a) == 0:
                continue
            a[0] += L + 1
            a[1] += L + 2
            ans.append(a)
        for a in ans[:M]:
            print(*a)
    else:
        for a in sol(L):
            if len(a) == 0:
                continue
            ans.append(a)
        for a in sol(L):
            if len(a) == 0:
                continue
            a[0] += L
            a[1] += L + 1
            ans.append(a)
        for a in ans[:M]:
            print(*a)

Solution (Python):
n,m=map(int,input().split())
for i in range(m):
    print(i+1,n-i-((i>=m/2)&~n))

Solution (Python):
n,m=map(int,input().split())
for i in range(m):
    print(i+1,n-i-((i>=m/2) & ~n))

Solution (Python):
def main():
    N, M = map(int, input().split())
    l = 1
    r = N - 1
    if N % 2 == 0:
        flag = True
        for i in range(M):
            if r - l <= N // 2 and flag:
                l += 1
                flag = False
            print(l,r)
            l += 1
            r -= 1
    else:
        for i in range(M):
            print(l,r)
            l += 1
            r -= 1

if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split())
if n%2==1:
    for i in range(m):
        print(i+1,n-i)
else:
    for i in range(m):
        if i<m/2:
            print(i+1,n-i)
        else:
            print(i+1,n-i-1)

Solution (Python):
n, m = map(int, input().split())
if m & 1:
    if n & 1:
        left_1 = 1
        right_1 = n // 2
        left_2 = (n // 2) + 1
        right_2 = n
    else:
        left_1 = 1
        right_1 = n // 2 - 1
        left_2 = (n // 2) + 1
        right_2 = n
else:
    if n & 1:
        left_1 = 1
        right_1 = n // 2
        left_2 = (n // 2) + 1
        right_2 = n
    else:
        left_1 = 1
        right_1 = n // 2 - 1
        left_2 = (n // 2) + 1
        right_2 = n
for _ in range(m // 2):
    print(left_1, right_1)
    left_1 += 1
    right_1 -= 1
for _ in range(m // 2, m):
    print(left_2, right_2)
    left_2 += 1
    right_2 -= 1

Solution (Python):
n, m = map(int, input().split())
if (m & 1):
    if n & 1:
        left_1 = 1
        right_1 = n // 2
        left_2 = (n // 2) + 1
        right_2 = n
    else:
        left_1 = 1
        right_1 = n // 2 - 1
        left_2 = (n // 2) + 1
        right_2 = n
else:
    if n & 1:
        left_1 = 1
        right_1 = n // 2
        left_2 = (n // 2) + 1
        right_2 = n
    else:
        left_1 = 1
        right_1 = n // 2 - 1
        left_2 = (n // 2) + 1
        right_2 = n
for _ in range(m // 2):
    print(left_1, right_1)
    left_1 += 1
    right_1 -= 1
for _ in range(m // 2, m):
    print(left_2, right_2)
    left_2 += 1
    right_2 -= 1