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):
N ,M = map(int,input().split())
array = []
if N % 2 == 1:
    for i in range(1,(N-1)//2 + 1):
        array.append([i,N-i])
    for i in range(M):
        print(*array[i])
else:
    for i in range(1,N//2):
        if i <= N//4:
            array.append([i,N+1-i])
        else:
            array.append([i,N-i])
    for i in range(M):
        print(*array[i])

Solution (Python):
N,M=map(int, input().split())
D=[]
E=[]
if M%2==0:
  if N%2==0:
    N-=1
  a=(N+1)//2
  for i in range(a//2):
    D.append((i+1,a-i))
  for d,e in D:
    E.append((d+a,e+a-1))
else:
  if N%2==0:
    N-=1
  a=N//2
  for i in range(a//2):
    D.append((i+1,a-i))
  for d,e in D:
    E.append((d+a+1,e+a))
  E.append((a+1,N))
F=D+E
for i in range(M):
  print(*F[i])

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7






























N, M = getNM()
A = []
B = []
if N % 2 != 0:
    for i in range(M):
        A.append(i + 1)
        B.append(N - i)
else:
    for i in range(M):
        A.append(i + 1)
        if i <= ((N // 4) - 1):
            B.append(N - i)
        else:
            B.append(N - i - 1) 
for i in range(M):
    print(A[i], B[i])

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

diffs = [False] * N

a = 1
b = N
for _ in range(M):
    while True:
        diff0 = b-a
        diff1 = (N+a-b)
        if not diffs[diff0] and not diffs[diff1]:
            break
        b-=1
    diffs[diff0] = True
    diffs[diff1] = True
    print(str(a) + ' ' + str(b))
    a += 1
    b -= 1
    if b-a == (N+a-b):
        b-=1

Solution (Python):
n, m = map(int, input().split())
if m == 1:
    print(1, 2)
    exit()
l1 = 1
l2 = m + 2
f = True
for length in range(m, 0, -1):
    if f:
        print(l1, l1 + length)
        l1 += 1
        f = not f
    else:
        print(l2, l2 + length)
        l2 += 1
        f = not f

Solution (Python):
n, m = map(int, input().split())
if m == 1:
    print(1, 2)
    exit()
l1 = 1
l2 = m + 2
f = True
for length in range(m, 0, -1):
    if f:
        print(l1, l1 + length)
        l1 += 1
        f = False
    else:
        print(l2, l2 + length)
        l2 += 1
        f = True

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

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

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

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

if n % 2 == 1:
    for i in range(m):
        print(n - i, i + 1)
else:
    used = [False] * (n + 1)
    offset = 0
    for i in range(m):
        a = n - (i + offset)
        b = i + offset + 1
        d = min(a - b, n - (a - b))
        if used[d] or a - b == n - (a - b):
            offset = 1
        used[d] = True
        print(n - i, i + offset + 1)

Solution (Python):
from collections import deque

n, m = map(int, input().split())

x = deque(range(1, n + 1))
aaa = []
bbb = []
flag = True

if n % 2 == 1:
    for i in range(m):
        a = x.popleft()
        aaa.append(a)
        b = x.pop()
        bbb.append(b)

else:
    for i in range(m):
        
        a = x.popleft()
        aaa.append(a)
        b = x.pop()
        bbb.append(b)
        if x[-1] - x[0] <= n // 2 and flag:
            a = x.popleft()
            flag = False

for aa, bb in zip(aaa, bbb):
    print(aa, bb)

Solution (Python):
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,M = MI()

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

Solution (Python):
from collections import deque

n, m = map(int, input().split())

x = deque(range(1, n + 1))
aaa = []
bbb = []
flag = True

if n % 2 == 1:
    for i in range(m):
        a = x.popleft()
        aaa.append(a)
        b = x.pop()
        bbb.append(b)

else:
    for i in range(m):
        
        a = x.popleft()
        aaa.append(a)
        b = x.pop()
        bbb.append(b)
        if x[-1] - x[0] <= n // 2 and flag:
            a = x.popleft()
            flag = False

for aa, bb in zip(aaa, bbb):
    print(aa, bb)

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

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


N,M = MI()

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

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

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

if N % 2 == 1:
    for i in range(1, M + 1):
        l = i
        r = N - i
        print(l, r)
else:
    flag = False
    l = 1
    r = N - 1
    cnt = 0
    while cnt < M:
        if not flag and r - l <= N // 2:
            r -= 1
            flag = True
        print(l, r)
        l += 1
        r -= 1
        cnt += 1

Solution (Python):
N, M = map(int, input().split())
if N%2==0:
    r = N
    f = True
    for i in range(M):
        if f and i*4+2 >= N:
            r -= 1
            f = False
        print(1+i, r)
        r -= 1
else:
    for i in range(M):
        print(1+i, N-i)

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

k = 1
k_even = n//2+1
p_even = k_even+1

def rotate(s,diff):
    if s + diff < 1:
        return s+diff+n
    elif s + diff > n:
        return s+diff-n
    return s+diff

for i in range(m+1):
    if i != 0 and i % 2 == 0:
        print(rotate(k,-(i//2)),rotate(k,i//2))

    if i % 2 == 1:
        print(rotate(k_even,-(i//2)),rotate(p_even,i//2))

Solution (Python):
from collections import deque
from itertools import product
import sys
import math

sys.setrecursionlimit(200000)
input = sys.stdin.readline


def read():
    N, M = map(int, input().strip().split())
    return N, M


def solve(N, M):
    H = (N-1) // 2
    LL = 0
    LR = (H // 2) * 2 + 1
    RL = N - (H - H//2) * 2
    RR = N
    pairs = []
    while LR - LL > 1:
        pairs.append((LL+1, LR))
        LL += 1
        LR -= 1
    while RR - RL > 1:
        pairs.append((RL+1, RR))
        RL += 1
        RR -= 1
    for i in range(M):
        print(*pairs[i])


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)

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

a = n //2
b = a + 1
abset = set()

for i in range(m):
    print(a,b)
    abset.add(b-a)
    abset.add(n-b+a)
    a -= 1
    b += 1
    if n % 2 == 0 and (b - a == abs(n - b + a) or b - a in abset or n - b + a in abset):
        b += 1

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

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

Solution (Python):
from math import ceil

n, m = (int(x) for x in input().split())
if n % 2 == 1:
    for i in range(1, m + 1):
        print(i, n - i)
else:
    k = (n - 2) // 2
    l = ceil(k / 2)
    ANS = []
    for i in range(1, l+1):
        ANS.append((i, n - i + 1))
    for i in range(l+2, k+2):
        ANS.append((i, n - i + 2))
    for a, b in ANS[:m]:
        print(a, b)

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy


import heapq

n,m = list(map(int, input().split()))

p = m // 2
for i in range(p):
    print(p-i,p+2+i)

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

Solution (Python):

from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N, M = LI()
    if N % 2 == 1:
        for i in range(1, M+1):
            print(i, N - i)
    else:
        for i in range(1, M + 1):
            x = i
            y = N - i + 1
            if y - x > (x - y) % N:
                print(x, y)
            else:
                print(x, y - 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 2 * (i + 1) <= m + 1:
            print(i + 1, n - i)
        else:
            print(i + 1, n - i - 1)

Solution (Python):
N, M = [int(_) for _ in input().split()]
l = 1
r = N
ans = []
for _ in range(M - M // 2):
    ans += [l, r]
    l += 1
    r -= 1
if (r - l) % 2 == (l + N - r) % 2:
    r -= 1
for _ in range(M // 2):
    ans += [l, r]
    l += 1
    r -= 1
ans = ans[:2 * M]
print('\n'.join(f'{a} {b}' for a, b in zip(ans[::2], ans[1::2])))

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

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

Solution (Python):
def main():
    N, M = list(map(int, input().split()))
    ans = list()
    if N % 2 == 1:
        for k in range(min(N // 2, M)):
            ans.append((k + 1, N - k))
    else:
        K = N // 2 - 1
        for k in range((K + 1) // 2):
            if len(ans) >= M:
                break
            ans.append((k + 1, N - k))
        for k in range(K // 2):
            if len(ans) >= M:
                break
            b = N - (K + 1) // 2 - k
            a = b - 2 * (K // 2 - k)
            ans.append((a, b))
    for row in ans:
        print('{} {}'.format(row[0], row[1]))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n,m = map(int, input().split())
    r = m//2
    s = 1
    e = 2*r+1
    for _ in range(r):
        print(s,e)
        s += 1
        e -=1
    
    s = n-2*(m-r)+1
    e = n
    for _ in range(m-r):
        print(s,e)
        s += 1
        e -=1


if __name__ == '__main__':
    main()

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

Solution (Python):


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

ans = []
delta = 0
visited = set()


for i in range(M):
    L = 1+i
    R = N-i
    diff = (R - delta) - L
    
    if (2*diff == N) or \
       (diff in visited) or ((N - diff) in visited):
       
        delta = 1
    
    ans.append( [L, R - delta] )
    visited |= {diff , (N - diff)}


for nums in ans:
    print(*nums)

Solution (Python):






def main():
    N,M = map(int, input().split())
    i = 1
    for m in range(M):
        if N%2 == 0 and i%2 == 1 and i >= N/2:
            i += 1
        print(M-m,M-m+i)
        i += 2
    

main()

Solution (Python):

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve(N, M):
    ans = []
    now = 0
    for d in range(M, 0, -2):
        ans.append((now, now + d))
        now += 1

    now = M + 1
    for d in range(M - 1, 0, -2):
        ans.append((now, (now + d) % N))
        now += 1

    return ans


def main():
    N, M = map(int, input().split())
    ans = solve(N, M)
    for x in ans:
        print(f"{x[0] + 1} {x[1] + 1}")


if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):
def main():
    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 n-2*i-1 > n//2:
                print(i+1, n-i)
            else:
                print(i+1, n-i-1)

if __name__ == "__main__":
    main()

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

for i in range(1, M+1):
  a = N+1 - i
  if N % 2 == 0 and i > (N // 4):
    a -= 1
  print(i, a)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    if m % 2 == 0:
        rem = m
        for i in range(m // 2):
            print(i + 1, m + 1 - i)
            rem -= 1
            if rem == 0:
                return
        for i in range(n):
            print(m + 2 + i, 2 * m + 1 - i)
            rem -= 1
            if rem == 0:
                return
    else:
        rem = m
        for i in range((m - 1) // 2):
            print(i + 1, m - i)
            rem -= 1
            if rem == 0:
                return
        for i in range(n):
            print(m + 1 + i, 2 * m + 1 - i)
            rem -= 1
            if rem == 0:
                return


if __name__ == '__main__':
    main()

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

n,m = map(int,readline().split())

l=1
r=n
used = set()
while len(used) < m * 2:
  diff = r - l
  rdiff = n - diff
  if diff == rdiff:
    r -= 1
    continue
  if diff in used:
    r -= 1
    continue
  print(l,r)
  used.add(diff)
  used.add(rdiff)
  l += 1
  r -= 1

Solution (Python):
N, M = map(int, input().split())
odd_l = 1
odd_r = M
even_l = M + 1
even_r = 2 * M + 1
i = 0
while i < M:
    print(even_l, even_r)
    i += 1
    if i == M:
        break
    print(odd_l, odd_r)
    i += 1
    odd_l += 1
    odd_r -= 1
    even_l += 1
    even_r -= 1

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

if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split())
piv = N//4+(N%4==3)
pairs = [(str(piv-i), str(piv+1+i)) for i in range(N//4+(N%4==3))]
piv = N - N//4 + (N%4==0)
pairs += [(str(piv-1-i), str(piv+1+i)) for i in range(N//4-(N%4==0))]
for pair in pairs[:M]:
    print(' '.join(pair))

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, m = map(int, input().split())
if n % 2 == 0:
    n -= 1
ans = []
left_range = n//2
right_range = n//2 - 1
left1 = 1
right1 = 1 + left_range
left2 = right1 + 1
right2 = left2 + right_range

while True:
    if left1 >= right1:
        break
    ans.append([left1, right1])
    left1 += 1
    right1 -= 1

while True:
    if left2 >= right2:
        break
    ans.append([left2, right2])
    left2 += 1
    right2 -= 1
    
for i in range(m):
    print(*ans[i])

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

if __name__ == "__main__":
    main()

Solution (Python):
N,M=map(int,input().split())
sets=[]
if N%2==1:
    for i in range(M):
        sets.append((i+1,i+1+(N-3-2*i)+1))
elif N%2==0:
    count=0
    kukan=[]
    for i in range(N//2-1):
        kukan.append(count)
        count+=2
        if count==N//2 or count==N//2-1:
            count+=1
    kukan.reverse()
    for i in range(M):
        sets.append((i+1,i+1+kukan[i]+1))
for set1 in sets:
    print(set1[0],set1[1])

Solution (Python):
n, m = map(int, input().split())
if m % 2 == 1:

    cnt = 0

    for i in range(m // 2):
        num1 = 1 + i
        num2 = m - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
    for i in range(m // 2 + 1):
        num1 = m + 1 + i
        num2 = 2 * m + 1 - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
else:
    cnt = 0

    for i in range(m // 2):
        num1 = 1 + i
        num2 = m + 1 - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
    for i in range(m // 2):
        num1 = m + 2 + i
        num2 = 2 * m + 1 - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()

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

right = 2*m+1

if m%2 == 0:
    for i in range(m//2):
        print(1+i, 1+m-i)
        print(2+m+i, right-i)

else:
    center = m+1
    for i in range(m//2):
        print(1+i, center-i)
        print(center+1+i, right-i)
    print(m//2+1, m//2+2)

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

n = 2*M+1

if M%2==1:
    for i in range(1, M//2+1):
        print('{} {}'.format(i,M+1-i))
    for i in range(1, (M+1)//2+1):
        print('{} {}'.format(M+i,2*M+2-i))

else:
    for i in range(1, M//2+1):
        print('{} {}'.format(i,M+2-i))
    for i in range(1, M//2+1):
        print('{} {}'.format(M+i+1,2*M+2-i))

Solution (Python):
import sys
def main():
    N,M=tuple(map(int,sys.stdin.readline().split()))
    if M%2==1:
        m1,m2=M//2,M//2+1
        for i in range(m1):
            l,r=i+1,M-i
            print(str(l)+' '+str(r))
        for i in range(m2):
            l,r=M+1+i,2*M+1-i
            print(str(l)+' '+str(r))
    else:
        m=M//2
        for i in range(m):
            l,r=i+1,M+1-i
            print(str(l)+' '+str(r))
        for i in range(m):
            l,r=M+2+i,2*M+1-i
            print(str(l)+' '+str(r))
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 math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

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

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

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

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

Solution (Python):
def main():
    n, m = map(int, input().split())
    if n & 1:
        for i in range(m):
            print(i+1, n-i)
    else:
        i = 0
        flag = False
        for i in range(m):
            if n-2*i-1 > n//2:
                print(i+1, n-i)
            else:
                print(i+1, n-i-1)

if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split())
for i in range(M, 0, -2):
    cur_start = (M - i) // 2
    print(cur_start + 1, cur_start + i + 1)
start = M + 2
for i in range(M -1, 0, -2):
    cur_start = start + (M -  1 - i) // 2
    print(cur_start, cur_start + i)

Solution (Python):
def resolve():
    N,M = map(int,input().split())
    if N % 2 == 1:
        for i in range(M):
            print(str(i+1) + " " + str(N-i))
    else:
        for i in range((M-1) // 2 + 1):
            print(str(i+1) + " " + str(N-i))
        for i in range((M-1) // 2 + 1 , M):
            print(str(i+1) + " " + str(N-i-1))
resolve()

Solution (Python):
n, m = map(int, input().split())
if n%2 == 1:
    a = 1
    b = n+1
    ans = []
    for i in range(m):
        a += 1
        b -= 1
        ans.append((a, b))
else:
    a = 1
    b = n+1
    S = set()
    ans = []
    for i in range(m):
        a += 1
        b -= 1
        r = min(b-a, n-(b-a))
        if r in S or r == n//2:
            b -= 1
            r = min(b-a, n-(b-a))
        ans.append((a, b))
        S.add(r)
for i in range(m):
    print(*ans[i])

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    used = set()
    Ans = [None for _ in range(M)]
    left = 1
    right = N
    for i in range(M):
        if right - left in used or 2 * (right - left) == N: right -= 1
        Ans[i] = (left, right)
        diff = right - left
        used |= {diff, N - diff}
        left += 1
        right -= 1
    for i in range(M): print(*Ans[i], sep=" ")

    return 0

if __name__ == "__main__":
    solve()

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


else:
    for i in range(m):
        if i <= (m+1)//2-1:
            ans.append((i+1, n-i))
        else:
            ans.append((i+1, n-i-1))

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

Solution (Python):

printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
if n%2==1:
    for i in range(1,m+1):
        print('{} {}'.format(i,n-i))
elif n%4==0:
    e = min(m+1,n//4)
    for i in range(1,e):
        print('{} {}'.format(i,n//2-i))
    if m>=n//4:
        for i in range(m-n//4+1):
            print('{} {}'.format(n-1-i,n//2+i))
else:
    e = min(m+1,n//4+1)
    for i in range(1,e):
        print('{} {}'.format(i,n//2-i+1))
    if m>=n//4+1:
        for i in range(m-n//4):
            print('{} {}'.format(n-1-i,n//2+i+1))

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

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

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

oddflag=True
for i in range(1,m+1):
	mid=(1+n)//2
	if oddflag:
		oddflag = False
		print(i//2 + 1 , n - i//2)
	else:
		oddflag = True
		print(mid + i//2, mid - i//2)

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

Solution (Python):
N,M=map(int,input().split())
a=M//2
b=M-a
c=1
d=2*a+1
for i in range(a):
  print(c,d)
  c+=1
  d-=1
e=2*a+2
f=2*M+1
for i in range(b):
  print(e,f)
  e+=1
  f-=1

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

even = m // 2
odd = m - even

odd_left = 1
odd_right = 2 * odd

even_left = odd_right + 1
even_right = even_left + 2 * even

for _ in range(odd):
    print(odd_left, odd_right)
    odd_left += 1
    odd_right -= 1

for _ in range(even):
    print(even_left, even_right)
    even_left += 1
    even_right -= 1

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

if N%2==1:
  for i in range(M):
    print(str(i+1) + " " + str(N-(i+1)))
else:
  flag = False
  l = 1
  r = N-1
  cnt = 0
  while cnt < M and l < r:
    if not flag and r-l <= N//2:
      r -= 1
      flag = True
    print(str(l) + " " + str(r))
    l += 1
    r -= 1
    cnt += 1