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):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    if m&1:
        k = (m>>1)+1
        for i in range(k):
            print(i+1,m+1-i)
        for i in range(k-1):
            print(m+2+i,2*m+1-i)
    else:
        k = m>>1
        for i in range(k):
            print(i+1,m+1-i)
        for i in range(k):
            print(m+i+2,2*m-i+1)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
def func(x):
    while True:
        if x <= 0:
            x += N
        else:
            break
    return x


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

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

else:
    a = 1
    b = 2
    for i in range(M):
        print(func(a), func(b))
        a -= 1
        b += 1
        if b == int(2 + N / 4):
            a -= 1

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

Solution (Python):
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
 

from collections import deque
def solve(N, M):
    ans = []
    if N & 1:
        tops = deque(xrange(1, 2 * M + 1))
        while tops:
            ans.append([tops.popleft(), tops.pop()])
 
    else:
        
        
        odds = (M + 1) // 2
        evens = M - odds
        i = odds
        d = 1
        for m in range(1, odds + 1):
            ans.append([i, i+d])
            i -= 1
            d += 2
        i = 2 * odds + evens
        d = 2
        for m in range(1, evens + 1):
            ans.append([i, i+d])
            i -= 1
            d += 2
            
 
    for row in ans:
        print "{} {}".format(*row)

solve(*rrm())

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

Solution (Python):
import math
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from heapq import heapify, heappop, heappush
from itertools import chain, combinations, permutations, product
from typing import List, Dict



sys.setrecursionlimit(10**5 + 1)
input = sys.stdin.readline
write = sys.stdout.write


def read_item(cls=int):
    return cls(input())


def read_n_item(cls=int) -> list:
    return [cls(s) for s in input().split()]


def list2d(row, col, init_val=0) -> List[list]:
    return [[init_val] * col for _ in range(row)]


MOD = 10**9 + 7



N, M = read_n_item()
if N & 1:
    for i in range(1, M+1):
        print(i, N-i+1)
else:
    used = [False] * (N+1)
    left, right = 1, N
    cnt = 0
    for i in range(1, N//2+1):
        if cnt == M:
            break
        l_d = right-left
        r_d = left+N-right
        if not used[right-left] and not used[left+N-right] and l_d != r_d:
            used[right-left] = used[left+N-right] = True
            print(left, right)
            cnt += 1
            left += 1
            right -= 1
        else:
            left += 1

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

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

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

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

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

cand=list(range(1,n+1))

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

n_odd = m//2
start = ans[-1][1]+n_odd
for i in range(1,n_odd+1):
    ans.append((start-i+1,start+i+1))

for aa in ans:
    print(*aa)

Solution (Python):
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json

import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    
    N, M = [int(a) for a in input().split()]

    D = (M - 1) // 2 + 1
    D2 = M - D

    for ii in range(M):

        if ii % 2 == 0:
            j = (ii) // 2
            a = D - 1 - j
            b = a + 2 * j + 1
        else:
            j = (ii - 1) // 2
            a = 2 * D + (D2 - 1 - j)
            b = a + 2 * j + 2
        print(a + 1, b + 1)


if __name__ == "__main__":
    main()

Solution (Python):
import sys


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


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


if __name__ == "__main__":
    main()

Solution (Python):

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

ans = []

if(n%4==2):
    mmax = n//2 - 1
    for i in range(mmax//2):
        j = 1 + 2*i
        left = n//2 - i
        ans.append([left,left+j])
    for ii in range(mmax//2):
        i = ii + mmax//2
        j = 2+2*i
        left = n//2 - i
        ans.append([left,left+j])
elif(n%4==0):
    mmax = n//2 -1
    for i in range(mmax//2+1):
        j = 1 + 2*i
        left = n//2 - i
        ans.append([left,left+j])
    for ii in range(mmax//2):
        i = ii + mmax//2 + 1
        j = 2+2*i
        left = n//2 - i
        ans.append([left,left+j])
else:
    mmax = n//2
    for i in range(mmax):
        j = 2*i+1
        left = n//2-i
        ans.append([left,left+j])



for i in range(m):
    print(ans[i][0],ans[i][1])

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

anss = []
if N % 2:
    for x in range(1, N+1):
        y = N-x
        if x >= y:
            break
        anss.append((x, y))
else:
    K1 = (N-1)//2
    K2 = K1-1

    for x in range(1, K1+1):
        y = K1+2-x
        if x >= y:
            break
        anss.append((x, y))
    for x in range(1, K2+1):
        y = K2+2-x
        if x >= y:
            break
        anss.append((K1+1+x, K1+1+y))

print('\n'.join(map(lambda x: str(x[0])+' '+str(x[1]), anss[:M])))

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

used = [False] * N

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

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

Solution (Python):
N, M = list(map(int, input().split()))
A = [i + 1 for i in range(N)]
mid = N//2
ans = []
for i in range(M+1//2):
    ans.append([A[mid - i], A[mid + 1 + i]])
    ans.append([A[-1 - i], A[1 + i]])
for i in range(M):
    print(*ans[i])

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, min(n//4+1, m+1)):
        print(i, n - i + 1)
    for i in range(n//4+1, m+1):
        print(i, n - i)

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

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



cnt = 0
i = 0
j = M
while i+1 < j and cnt < M:
    print(i+1, j)
    i += 1
    j -= 1
    cnt += 1

i = M
j = 2*M+1
while i+1 < j and cnt < M:
    print(i+1, j)
    i += 1
    j -= 1
    cnt += 1

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict
from sys import exit
import math


def main():
    n, m = getList()
    if n % 2 == 0:
        mx = (n-2) // 2
    else:
        mx = n // 2

    a,b,c,d = 1, 1+mx-1, n - mx, n
    diff = 0
    cnt = 0
    while(True):
        print(c+diff, d-diff)
        cnt += 1
        if cnt == m:
            return
        print(a+diff, b-diff)
        cnt += 1
        if cnt == m:
            return
        diff += 1
    
    

if __name__ == "__main__":
    main()

Solution (Python):

import os
import sys
from io import BytesIO, IOBase


def main():
    n,m=map(int,input().split())

    if n%2:
        for i in range(1,m+1):
            print(i,2*m-i+1)
    else:
        i,j=1,n
        a=[]
        while i<=n//4:
            a.append([i,j])
            i,j=i+1,j-1
        j-=1
        while i<j:
            a.append([i,j])
            i,j=i+1,j-1
        for i in range(m):
            print(a[i][0],a[i][1])
        




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")


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:
    M1 = -(-M//2)
    M2 = M - M1
    for j in range(M1):
        print(j+1,N-j)
    for k in range(M2):
        print(int(N/2-1-k),int(N/2+1+k))

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

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

Solution (Python):


def run():
    N, M = map(int, input().split())
    left1 = 1
    left2 = M
    right1 = N -M
    right2 = N
    for idx, i in enumerate((range(1,M,2))):
        print('{} {}'.format(left1+idx, left2-idx))
    for idx, _ in enumerate(range(M+1, 2*M+1, 2)):
        print('{} {}'.format(right1+idx, right2-idx))

if __name__ == "__main__":
    run()

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

for i in range(min(M, N // 4)):
    print("{} {}".format(i + 1, N - i))

center = (N + 1) // 2

for i in range(max(0, M - N // 4)):
    print("{} {}".format(center - i - 1, center + i + 1))

Solution (Python):
n,m=list(map(int,input().split()))
mm=int((m+1)/2+0.01)
for i in range(mm):
  print(1+i,2*mm-i)
for i in range(m-mm):
  print(2*mm+i+1,2*m-i+1)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m = map(int,input().split())
    
    if n & 1: 
        left = 1
        right = n - 1
        for _ in range(m):
            print(left, right)
            left += 1
            right -= 1
        return

    
    left = 1
    right = n // 2 - 1
    while left < right:
        print(left, right)
        m -= 1
        if m == 0:
            return
        left += 1
        right -= 1

    left = n // 2
    right = n - 1
    while left < right:
        print(left, right)
        m -= 1
        if m == 0:
            return
        left += 1
        right -= 1
resolve()

Solution (Python):
n, m = map(int, input().split())
x = (n + 1) // 2
cnt_l = -(-m // 2)
cnt_r = m // 2
ans = []
for i in range(cnt_l):
    ans.append((i+1, x-i))
for i in range(cnt_r):
    ans.append((x+1+i, 2*x-i-1))

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

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

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

ans = []
diff = M
now = 1
while diff >= 1:
  ans.append([now, now+diff])
  diff -= 2
  now += 1

diff = M-1
now = N
while diff >= 1:
  ans.append([now-diff, now])
  diff -= 2
  now -= 1

for a in ans:
  print(*a)

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:
  c = 0
  for i in range(1,(n//4)+1):
    print(i,n+1-i)
    c += 1
    if c == m:
      exit()
  j = n//2
  while True:
    print(j,n+2-j)
    c += 1
    if c == m:
      exit()
    j -= 1

Solution (Python):
N,M = map(int,input().split())
x,y = 1, N
used = [False for i in range(N+1)]
for i in range(M):
	if N % 2 == 0 and ((y-x) == N // 2 or used[y-x]):
		y -= 1
		print(x,y)
	else:
		print(x,y)
	used[y-x] = True
	used[N-(y-x)] = True
	x += 1
	y -= 1

Solution (Python):
import math
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(min(M,N//4)):
    print(i+1,N//2-i)
  for i in range(max(M-N//4,0)):
    print(N//2+1+i,N-1-i)

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

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

    ans = [None for _ in range(m)]
    used = set()
    a = 1
    b = n
    good = True
    for i in range(m):
        if b - a == n - (b - a):
            a += 1
            b -= 1
        ans[i] = (a, b)
        if (b - a) in used:
            good = False
            break
        else:
            used.add(b - a)
        if (n - (b - a)) in used:
            good = False
            break
        else:
            used.add(n - (b - a))
        a += 1
        b -= 1

    if not good:
        ans = [None for _ in range(m)]
        used = set()
        a = 1
        b = n-1
        good = True
        for i in range(m):
            if b - a == n - (b - a):
                a += 1
                b -= 1
            ans[i] = (a, b)
            if (b - a) in used:
                good = False
                break
            else:
                used.add(b - a)
            if (n - (b - a)) in used:
                good = False
                break
            else:
                used.add(n - (b - a))
            a += 1
            b -= 1

    if not good:
        ans = [None for _ in range(m)]
        used = set()
        a = 1
        b = n
        good = True
        dec = False
        for i in range(m):
            if b - a == n - (b - a):
                b -= 1
            if not dec and ((b - a) in used or (n - (b - a)) in used):
                b -= 1
            ans[i] = (a, b)
            if (b - a) in used:
                good = False
                break
            else:
                used.add(b - a)
            if (n - (b - a)) in used:
                good = False
                break
            else:
                used.add(n - (b - a))
            a += 1
            b -= 1


    for i in range(m):
        print(ans[i][0], ans[i][1])

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    used = set()
    left = 1
    right = N
    for i in range(M):
        if right - left not in used:
            if N - (right - left) not in used and N - (right - left) != right - left:
                print(left, right)
                used |= {right - left}
                used |= {N - (right - left)}
                left += 1
                right -= 1
            else:
                print(left, right - 1)
                used |= {right - left - 1}
                used |= {N - (right - left - 1)}
                left += 1
                right -= 2
        else:
            print(left, right - 1)
            used |= {right - left - 1}
            used |= {N - (right - left - 1)}
            left += 1
            right -= 2

    return 0

if __name__ == "__main__":
    solve()

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

if n % 2 == 0:
    if n % 4 == 0:
        flag = True
        for i in range(m):
            if i == n//4:
                flag = False
            if flag == True:
                print(i+1,n-i)
            else:
                print(i+1,n-i-1)
    else:
        flag = True
        for i in range(m):
            if n-i - (i+1) == n//2:
                flag = False
            if flag == True:
                print(i+1,n-i)
            else:
                print(i+1,n-i-1)
else:
    for i in range(m):
        print(i+1,n-i)

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

Solution (Python):
N, M = map(int, input().split())
li = []
if N&1 == 1:
    a, b = 1, N-1
    li.append([a, b])
    for i in range(min(M-1,(N-1)//2-1)):
        a += 1
        b -= 1
        li.append([a,b])
else:
    a, b = 1, N
    li.append([a,b])
    for i in range(min(M-1,(N-1)//2-1)):
        a += 1
        b -= 1
        if b - a <= N+a-b and - b + a + N+a-b <= 2:
            b -= 1
        li.append([a,b])
for x in li:
    print(*x)

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

ansl = []

start = n // 2
end = n // 2 + 1
for i in range(m):
    if n % 2 == 0 and end - start + 2 * i >= n // 2:
        ansl.append((start - i-1, end + i))
    else:
        ansl.append((start-i, end+i))

for a,b in sorted(ansl):
    print(a,b)

Solution (Python):
N, M = map(int, input().split())
ans = []
l1 = 1
l2 = 1 + M + 1
for i in range(M):
    now = M - i
    if i % 2 == 0:
        ans.append([l1, l1 + now])
        l1 += 1
    else:
        ans.append([l2, l2 + now])
        l2 += 1
for row in ans:
    print(row[0], row[1])

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

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

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

    check=0
    for a,b in ANS:
        if a!=b:
            print(a,b)
            check+=1

        if check==M:
            break

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

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

last_odd, last_even = m, m-1

if last_odd % 2 ==0:
    last_odd, last_even = last_even, last_odd
    

oddl = 1
oddr = oddl + last_odd

evenl = oddr + 1
evenr = evenl + last_even

while oddl < oddr:
    print(oddl, oddr)
    oddl += 1
    oddr -=1
while evenl < evenr:
    print(evenl, evenr)
    evenl += 1
    evenr -= 1

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

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

Solution (Python):
n,m=map(int,input().split())
ans=[1]*n
for i in range(1,n):
  if ans[i]==1:ans[n-i]=0
c=0
x=[]
for i in range(1,n):
  if ans[i]==1:
    if len(x)%2==0:x.append(n-i)
    else:x.append(i)
x.sort(reverse=1)
for i in range(m):print(i+1,i+1+x[i])

Solution (Python):
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
input = sys.stdin.readline


def inp():
    return int(input())


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


N, M = inpl()

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

            print(a, b)

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

Solution (Python):
n,m=map(int,input().split())
b=m//2
a=m-b

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

Solution (Python):
N , M = map(int,input().split())
if N % 2 != 0:
    start = 1
    end = N
    for i in range(M):
        print(start,end)
        start += 1
        end -= 1
else:
    start = 1
    end = N
    judge = True
    for i in range(M):
        print(start,end)
        start += 1
        end -= 1
        if (end - start) <= N // 2 and judge:
            start += 1
            judge = False

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

if N % 2:
    for a in range(1, M + 1):
        b = N - a
        print(a, b)
else:
    even = min(N // 4, M)
    odd = M - even
    for a in range(1, 1 + even):
        b = N + 1 - a
        print(a, b)
    for a in range(even + 1, M + 1):
        b = N - a
        print(a, b)

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

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

z = (N-1)//2
left = z//2
right = z - left

Ans = []
for i in range(left):
    Ans.append((i, i-2*(i+1)))
ss = 2*left+2*right-1
for i in range(right):
    st = left + i
    Ans.append((st, ss-st))

AA = []
for a, b in Ans[:M]:
    AA.append((a%N+1, b%N+1))

print('\n'.join(['{} {}'.format(*a) for a in AA]))

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

Solution (Python):
def examA():
    K = I()
    A, B = LI()
    for i in range(A,B+1):
        if i%K==0:
            print("OK")
            return
    print("NG")
    return

def examB():
    X = I()
    now = 100
    ans = 0
    while(now<X):
        ans += 1
        now += now//100
    print(ans)
    return

def examC():
    N, M, Q = LI()

    ans = 0
    print(ans)
    return

def examD():
    A, B, N = LI()
    if N>=B-1:
        ans = (A*(B-1))//B
    else:
        ans = (A*N)//B
    print(ans)
    return

def examE():
    N, M = LI()
    ans = []
    if N%2==1:
        for i in range(N // 2):
            ans.append((i + 1, N - i))
    else:
        flag = False
        for i in range(N // 2):
            if N-i-(i+1)<=N//2:
                flag = True
            if flag:
                ans.append((i+1,N-i-1))
            else:
                ans.append((i + 1, N - i))
    
    for v in ans[:M]:
        print(" ".join(map(str,v)))
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examE()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
n, m = map(int, input().split())
odd = m if m%2 else m-1 
even = m-1 if m%2 else m 
mid = 1 + odd + 1 

for i in range(1, (1+odd)//2+1):
    print(i, i+odd)
    odd -= 2
    
for i in range(mid, mid + even//2):
    print(i, i+even)
    even -= 2

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

Solution (Python):
n,m = map(int,input().split())
ANS = [[0] * 2 for i in range(m)]

a = 0
b = 1
c = 0
f = 1
for i in range(m):
    if n%2 == 0 and (c+2) > n//2 and f == 1:
        b = (b+1) % n
        f = 0
    ANS[i] = [a, b]
    c += 2
    a = (a-1) % n
    b = (b+1) % n
    

for i in range(m):
    print(ANS[i][0]+1, ANS[i][1]+1)

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

N, M = map(int, input().split())
ans = []
a = N
b = 1
if N % 2 == 1:
    while a != b and M > 0:
        ans.append((a, b))
        a -= 1
        b += 1
        M -= 1
else:
    a = N
    b = 1
    for i in range(((N-2)//2+1)//2):
        if M == 0:
            break
        ans.append((a, b))
        a -= 1
        b += 1
        M -= 1
    a -= 1
    for i in range(((N-2)//2)//2):
        if M == 0:
            break
        ans.append((a, b))
        a -= 1
        b += 1
        M -= 1
for a, b in ans:
    print(a, b)