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())
if (m & 1):
    if n & 1:
        left_1 = 1
        right_1 = n // 2
        for _ in range(m // 2):
            print(left_1, right_1)
            left_1 += 1
            right_1 -= 1
        left_2 = (n // 2) + 1
        right_2 = n
        for _ in range(m // 2, m):
            print(left_2, right_2)
            left_2 += 1
            right_2 -= 1
    else:
        left_1 = 1
        right_1 = n // 2 - 1
        for _ in range(m // 2):
            print(left_1, right_1)
            left_1 += 1
            right_1 -= 1
        left_2 = (n // 2) + 1
        right_2 = n
        for _ in range(m // 2, m):
            print(left_2, right_2)
            left_2 += 1
            right_2 -= 1
else:
    if n & 1:
        left_1 = 1
        right_1 = n // 2
        for _ in range(m // 2):
            print(left_1, right_1)
            left_1 += 1
            right_1 -= 1
        left_2 = (n // 2) + 1
        right_2 = n
        for _ in range(m // 2, m):
            print(left_2, right_2)
            left_2 += 1
            right_2 -= 1
    else:
        left_1 = 1
        right_1 = n // 2 - 1
        for _ in range(m // 2):
            print(left_1, right_1)
            left_1 += 1
            right_1 -= 1
        left_2 = (n // 2) + 1
        right_2 = n
        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:
    print(1, n)
    exit()
if n % 2 == 1:
    for i in range(m):
        print(i+1, n-i-1)
else:
    j = 1
    for i in range((m-1)//2+1):
        print(j, n - i)
        j += 1
    j += 1
    for i in range((m-1) // 2+1, m):
        print(j, n - i)
        j += 1

Solution (Python):


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

l, r = 1, n
for i in range(m):
    if 2 * (r - l) == n or 2 * (r - l + 1) == n:
        l += 1
    print(l, r)
    l, r = l + 1, r - 1

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

odd = (m + 1) // 2
even = m - odd

l = 1
r = 2 * odd
while l < r:
    print(l, r)
    l += 1
    r -= 1

l = n - 2 * even
r = n
while l < r:
    print(l, r)
    l += 1
    r -= 1

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



a = 1
if M%2 == 1:
    
    for i in range(M,0,-2):
        print(str(a) + ' ' + str(a+i))
        a+=1
    a = N
    
    for i in range(M-1, 1, -2):
        print(str(a) + ' ' + str(a - i))
        a-=1
elif M%2 == 0:
    
    for i in range(M-1,0,-2):
        print(str(a) + ' ' + str(a+i))
        a+=1
    a = N
    
    for i in range(M, 1, -2):
        print(str(a) + ' ' + str(a - i))
        a-=1

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    ans = [[] for j in range(M)]

    if N % 2:
        for i in range(M):
            ans[i].append(i + 1)
            ans[i].append(N - i - 1)
    else:
        memo = 0
        f = False
        for i in range(M):
            memo = i
            if (i + 1) * 4 >= N:
                f = True
                break
            ans[i].append(i + 1)
            ans[i].append(N - i - 1)

        if f:
            for j in range(memo, M):
                ans[j].append(j + 1)
                ans[j].append(N - j - 2)
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    ans = [[] for j in range(M)]

    if N % 2:
        for i in range(M):
            ans[i].append(i + 1)
            ans[i].append(N - i - 1)
    else:
        memo = 0
        for i in range(M):
            memo = i
            if (i + 1) * 4 >= N:
                break
            ans[i].append(i + 1)
            ans[i].append(N - i - 1)
            memo += 1

        for j in range(memo, M):
            ans[j].append(j + 1)
            ans[j].append(N - j - 2)
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main()

Solution (Python):
N,M = map(int,input().rstrip().split(" "))
ans = []
K = (N - 1) // 2
if K % 2 == 0:
    for i in range(K // 2):
        ans.append([K // 2 - i,K // 2 + i + 1])
    for i in range(K // 2):
        ans.append([N - K // 2 -1  - i,N - K // 2 + i + 1])
else:
    for i in range(K // 2 + 1):
        ans.append([K // 2 + 1 - i,K // 2 + i + 2])
    for i in range(K // 2):
        ans.append([N - K // 2 - 1  - i,N - K // 2 + i + 1])
for i in range(M):
    print(str(ans[i][0]) + " " + str(ans[i][1]))

Solution (Python):

INF = 2**62-1

def read_int_n():
    return list(map(int, input().split()))

def slv(N, M):
    if N % 2 != 0:
        ans = [(i+1, N-i) for i in range(M)]
    else:
        ans = [(i+1 +(1 if i+1 > N//4 else 0), N-i) for i in range(M)]

    for a in ans:
        print(*a)


def main():
    N, M = read_int_n()
    (slv(N, M))



if __name__ == '__main__':
    main()

Solution (Python):

INF = 2**62-1

def read_int_n():
    return list(map(int, input().split()))

def slv(N, M):
    if N % 2 != 0:
        ans = [ (i+1, N-i) for i in range(M)]
    else:
        ans = []
        for i in range(M):
            l = i+1
            r = N-i
            if l > N //4:
                l += 1

            ans.append((l, r))

    for a in ans:
        print(*a)


def main():
    N, M = read_int_n()
    (slv(N, M))



if __name__ == '__main__':
    main()

Solution (Python):
from collections import *
n,m = map(int,input().split())
d = dict()
i,j = 1,n
for y in range(m):
	if(n%2 == 0 and i == (m+1)//2+1):
		i += 1
	print(i,j)
	i += 1
	j -= 1

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]





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

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

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

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

if n % 2 or m < n//4:
  for i in range(m):
    print(i+1, n-i)
else:
  for i in range(n//4):
    print(i+1, n-i)
  for i in range(n//4, m):
    print(i+1, n-i-1)

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

Solution (Python):
n,m=map(int,input().split())
left=m//2
right=(m+1)//2

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


for i in range(right):
    print(2*left+1+i+1,2*left+1+2*right-i)

Solution (Python):

import sys

def main():
    N, M = map(int, input().split())
    
    if M % 2 == 1:
        for i in range(M//2):
            print(i+1,M-i)
        for j in range(M//2 + 1):
            print(M+1+j,2*M+1-j)
    else:
        for i in range(M//2):
            print(i+1, M+1-i)
        for j in range(M//2):
            print(M+2+j,2*M+1-j)

if __name__ == '__main__':
    main()

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

Solution (Python):
n,m = map(int,input().split())
if(n%2==1):
    for i in range(1,m+1):
        print(' '.join(map(str,[i,n+1-i])))
    exit()

m1,m2 = (m+1)//2 ,m//2
sum1 = 1 + n//2
sum2 = (n//2+1) + (n-1)
for i in range(m1):
    print(' '.join(map(str,[1+i,n//2 -i])))
for i in range(m2):
    print(' '.join(map(str,[n//2+1+i,n-1-i])))

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

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
if n % 2:
    for i in range(m):
        print(i+1, n-i-1)
else:
    flag = False
    for i in range(m):
        if not flag and (n-i-1) - (i+1) <= n // 2:
            flag = True
        if flag:
            print(i+1, n-i-2)
        else:
            print(i+1, n-i-1)

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

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

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%2==0:
            print(i//2+1,n-i//2)
        else:
            print(n//2-i//2-1,n//2+i//2+1)

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

if N %2 == 0:
    L1 = list(range(1,N//2+1))
    L2 = list(range(N//2+1,N+1))
    L = len(L1)
    i = 0
    j = 0
    
    for m in range(M):
        if m %2 == 0:
            ans.append([L1[L//2-1-i],L1[L//2+i]])
            i += 1
        else:
            ans.append([L2[L//2-1-j], L2[L//2+1+j]])
            j += 1

else:
    for i in range(1,M+1):
        ans.append([i,N+1-i])

for a in ans:
    print(*a)

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

l = 1
r = n
cnt = 0
dp = [False] * (n+1)
while cnt < m:
    if dp[r-l]: r -= 1
    if r-l == (l-r)%n: r-=1
    print(l,r)
    dp[r-l] = True
    dp[(l-r)%n] = True
    r -= 1
    l += 1
    cnt += 1

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

Solution (Python):
def main():
    from collections import deque
    N, M = (int(i) for i in input().split())
    if N % 2 == 0:
        A = deque([i+1 for i in range(N)])
        for i in range(1, M+1):
            if (N-i)-i > N//2:
                print(A[i], A[N-i])
            else:
                print(A[i], A[N-i-1])
    else:
        A = deque([i for i in range(N)])
        for i in range(1, M+1):
            print(A[i], A[N-i])


if __name__ == '__main__':
    main()

Solution (Python):
X = str(input())
N = int(X.split(' ')[0])
M = int(X.split(' ')[1])



if N % 2 ==1:

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

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

    pairs = []
    a = 1
    for d in range(M, 0, -2):
        pairs.append((a, a + d))
        a += 1

    a = 1 + M + 1
    for d in range(M - 1, 0, -2):
        pairs.append((a, a + d))
        a += 1

    for pair in pairs:
        print(*pair)


if __name__ == '__main__':
    main()

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()

ans = list2d(M, 2, 0)
cnt = 1
for i in range(M//2):
    ans[i][0] = cnt
    cnt += 1
cnt += 1
for i in range(M//2-1, -1, -1):
    ans[i][1] = cnt
    cnt += 1
for i in range(M//2, M):
    ans[i][0] = cnt
    cnt += 1
for i in range(M-1, M//2-1, -1):
    ans[i][1] = cnt
    cnt += 1

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

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

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

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

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


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

    """
    奇数人のときは１飛ばし、３飛ばし、５飛ばし、、、とすればよい。
    偶数人のときは１飛ばし、３飛ばし、、、で途中から偶数飛ばしに切り替えるとよい。
    （「カークマンの組み分け」を参照）
    構成問題苦手だ。。。
    """

    if N % 2 == 1:
        cnt = 0
        for l in range(1, N // 2 + 1):
            r = N - l + 1
            print("{} {}".format(l, r))
            cnt += 1
            if cnt == M: return
    else:
        cnt = 0
        for l in range(1, N // 4 + 1):
            r = N - l + 1
            print("{} {}".format(l, r))
            cnt += 1
            if cnt == M: return
        for l in range(N // 4 + 1, N // 2):
            r = N - l
            print("{} {}".format(l, r))
            cnt += 1
            if cnt == M: return

    

if __name__ == "__main__":
    main()

Solution (Python):

import sys
import math
import numpy as np
import itertools


n,m = (int(i) for i in input().split())

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

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    N,M=map(int,readline().split())
    a=1
    b=N-1
    if N%2==1:
        for _ in range(M):
            print(a,b)
            a+=1
            b-=1
    else:
        flag=False
        for _ in range(M):
            if flag==False and b-a<=N//2:
                flag=True
                b-=1
                print(a,b)
                a+=1
                b-=1
            else:
                print(a,b)
                a+=1
                b-=1

if __name__=="__main__":
    main()

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

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

if n % 2 == 0:
    i = 1
    while i <= m:
        a_i = str(i)
        
        if i <= (n - 2) // 4:
            b_i = str(n - i)
        else:
            b_i = str(n - i - 1)
        
        print(a_i + " " + b_i)
        i += 1
        
elif n % 2 == 1:
    for i in range(1, m + 1):
        a_i = str(i)
        b_i = str(n - i)
        
        print(a_i + " " + b_i)

Solution (Python):
import sys
N, M = [int(x) for x in input().split()]

s = 1
e = 2 * -(-M // 2)
for _ in range(M):
    if s >= e:
        s = N - 2 * (M // 2)
        e = N
    print(s, e)
    s += 1
    e -= 1

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

Solution (Python):
import sys
N, M = [int(x) for x in input().split()]

s = []; e = [];
s.append(1)
e.append(2 * -(-M // 2)) 
s.append(N - 2 * (M // 2))
e.append(N)

n = 0
while True:
    for i in range(2):
        if n >= M: sys.exit()
        print(s[i], e[i])
        s[i] += 1
        e[i] -= 1
        n += 1

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):
N, M = map(int, input().split())

if M % 2 == 1:
    ll, lr, rl, rr = 1, M, M+1, M*2+1
    for i in range(M//2):
        print(ll+i, lr-i)
    for i in range(M//2+1):
        print(rl+i, rr-i)
else:
    ll, lr, rl, rr = 1, M+1, M+2, M*2+1
    for i in range(M//2):
        print(ll+i, lr-i)
        print(rl+i, rr-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):
n,m=map(int,input().split())
for i in range(m):
  if n%2==0 and 2*m-i-i-1>=n//2:
    print(i+1,2*m-i+1)
  else:
    print(i+1,2*m-i)

Solution (Python):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m=n1()

if n%2==0:
    if m>=2:
        e=n//2
        s=1
        l=e-s
        c=0
        while e>s and c<m:
            print(s,e)
            s+=1
            e-=1
            c+=1
        e=n
        s=n-l+1
        while e>s and c<m:
            print(s,e)
            s+=1
            e-=1
            c+=1
    else:
        print(1,2)
else:
    if m>=2:
        e=n//2+1
        s=1
        l=e-s
        c=0
        while e>s and c<m :
            print(s,e)
            s+=1
            e-=1
            c+=1
        e=n
        s=n-l+1
        while e>s and c<m:
            print(s,e)
            s+=1
            e-=1
            c+=1
    else:
        print(1,2)

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

Solution (Python):
def main():
    n, m = map(int, input().split())
    p = (m+1)//2
    q = m//2
    l = 0
    r = 2*p-1
    for i in range(p):
        print(l+1, r+1)
        l += 1
        r -= 1
    l = 2*p
    r = l+2*q
    for i in range(q):
        print(l+1, r+1)
        l += 1
        r -= 1


main()

Solution (Python):
n,k=map(int,input().split())
ans=[]
a=1
b=n
s=set()
for _ in range(k):
  s.add(abs(a-b))
  s.add(abs(n+a-b)%n)
  ans.append([a,b])
  a+=1
  b-=1
  if abs(a-b) in s or abs(n+a-b)%n in s or abs(a-b)==abs(n+a-b):
    b-=1
for i in range(k):
  print(*ans[i])

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
half=n//2
lst=[]
if n%2==1:
    for i in range(m):
        lst.append([half-i,half+i+1])
else:
    for i in range(m):
        if i%2==0:
            lst.append([half-i//2,half+i//2+1])
        else:
            lst.append([1+i//2,n-1-i//2])

for i in range(m):
    print(*lst[i])

Solution (Python):
n,k=map(int,input().split())
ans=[]
if n%2==1:
  a=1
  b=n
  for _ in range(k):
    ans.append([a,b])
    a+=1
    b-=1
else:
  a=1
  b=n
  s=set()
  for _ in range(k):
    s.add(abs(a-b))
    s.add(abs(n+a-b)%n)
    ans.append([a,b])
    a+=1
    b-=1
    if abs(a-b) in s or abs(n+a-b)%n in s or abs(a-b)==abs(n+a-b):
      b-=1
for i in range(k):
  print(*ans[i])

Solution (Python):
import math
import fractions
import collections
import itertools
import pprint
N,M=map(int,input().split())




l=[]
maemin=1
usiromax=N
for i in range(M,0,-1):
    if i%2==0:
        l.append([maemin,maemin+i])
        maemin=maemin+1
    else:
        l.append([usiromax-i,usiromax])
        usiromax=usiromax-1


for i in range(M):
    print(*l[i],sep=" ")

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, M = map(int, rl().split())
    
    left = [i for i in range(M)]
    right = [2 * M - 1 - v for v in left]
    
    for i in range(M // 2):
        right[i] -= 2 * M + 1
    
    for i in range(M):
        left[i] %= N
        left[i] += 1
        right[i] %= N
        right[i] += 1
    
    for a, b in zip(left, right):
        print(a, b)


if __name__ == '__main__':
    solve()

Solution (Python):
import sys

sys.setrecursionlimit(100000000)


def main():
    n, m = map(int, input().split())
    res = []
    
    if m % 2 == 0:
        half_m = int(m / 2)
        for i in range(half_m):
            res.append((half_m - i, half_m + 1 + i))
            res.append((m + half_m - i, m + half_m + 2 + i))
    else:
        half_m = int(m / 2)
        for i in range(half_m):
            res.append((half_m - i, half_m + 2 + i))
            res.append((m + half_m + 1 - i, m + half_m + 2 + i))
        res.append((m + 1, m + 2 * half_m + 2))

    for r in res:
        print(str(r[0]) + " " + str(r[1]))


main()

Solution (Python):


n, m=  [int(i) for i in input().split()]
for i in range(0,m):
  if n-2*i-1>n/2 or n%2==1:
    print(i+1,n-i)
  else:
    print(i+1,n-i-1)

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()

a,b = 1,n-(n%2)
for i in range(m):
    if n%2 == 0 and i == (m+1)//2:
        a += 1
    print(a,b)
    a,b = a+1, b-1

Solution (Python):
N,M = map(int,input().split())
start = 1
end = M
while True:
  if start>=end:
    break
  print(start,end)
  start+=1
  end-=1
  
start = M+1
end = 2*M+1
while True:
  if start>=end:
    break
  print(start,end)
  start = start+1
  end = end-1

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

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

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
half=n//2
lst=[]

if n%2==0:
    for i in range(m):
        if i%2==0:
            lst.append([1+i//2,n-i//2])
        else:
            lst.append([half-i//2,half+i//2+2])
else:
    for i in range(m):
        lst.append([half-i,half+i+1])

for i in range(m):
    print(*lst[i])

Solution (Python):
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


N,M = nm()
used = [0] * N

start = 0
if N % 2 != 0:
    s = (N-1)//2
else:
    s = N//2 - 1 

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

Solution (Python):
import math

n, m = map(int, input().split())
c = 0
f = [math.floor(n/2), math.floor(n/2) + 1]
if n % 2 == 0:
    while c < m:
        c += 1
        if c == math.floor(n/4) + 1:
            if (f[1] + 1) % n == 0:
                f[1] = n
            else:
                f[1] = (f[1] + 1) % n
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n
else:
    while c < m:
        c += 1
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n

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

ans = []
n = M // 2
m = 2 * n + 1
l = 2 * M + 1
for i in range(n):
    ans.append([i + 1, m - i])

for i in range(M - n):
    ans.append([m + i + 1, l - i])

for v in ans:
    print(*v)

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

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

half=N//2

if half%2==0:
    for i in range(half//2):
        ans.append((i+1,half-i))
    for j in range(half//2):
        ans.append((half+1+j,N-j))
else:
    for i in range(half//2):
        ans.append((i+1,half-i))
    for j in range(half//2+1):
        ans.append((half+1+j,N-j))


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

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

cnt = 0

l = 0
k = M
while cnt < M and k > 0:
    print(l + 1, l + k + 1)
    cnt += 1
    l += 1
    k -= 2

l = M + 1
k = M - 1
while cnt < M:
    print(l + 1, l + k + 1)
    cnt += 1
    l += 1
    k -= 2