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 n%2==1:
    for i in range(m):
        print(i+1, n-i-1)
else:
    used = [False]*n
    next = [i+1 for i in range(m)][::-2]+[i+1 for i in range(m)][-2::-2]
    i=0
    now=0
    count=0
    while True:
        if used[now]==False and used[now+next[i]]==False:
            print(now+1, now+next[i]+1)
            count+=1
            if count==m:
                break
            used[now]=True
            used[now+next[i]]=True
            i+=1
            now+=1
        else:
            now+=1

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=[]
tmp=0
if n%2==0:
    for i in range(m):
        if i%2==1:
            lst.append([half-i//2,half+i//2+2])
        else:
            lst.append([1+i//2,n-i//2])

else:
    for i in range(m):
        lst.append([half-i,half+i+1])

for i in range(m):
    print(*lst[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(min(M,N//4)):
        print(i+1,N-i)
    for i in range(max(0,M-N//4)):
        print(N//4+i+1,N-N//4-i-1)

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=[]
tmp=0
if n%2==0:
    tmp=1
for i in range(m):
    if i%2==1:
        lst.append([half-i//2,half+i//2+2])
    else:
        lst.append([1+i//2,n-i//2])

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

Solution (Python):
n,m=map(int,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):
n, m = map(int, input().split())

s1 = 1
f1 = n // 2
s2 = f1 + 1
f2 = n
if (f1 - s1) % 2 == (f2 - s2) % 2:
    f2 -= 1
ans = []
while f1 > s1:
    ans.append(f"{s1} {f1}")
    s1 += 1
    f1 -= 1

while f2 > s2:
    ans.append(f"{s2} {f2}")
    s2 += 1
    f2 -= 1

print("\n".join(ans[:m]))

Solution (Python):



from pprint import pprint as pp
from pprint import pformat as pf

def solve_odd(n, m):
    for i in range(m):
        print(i + 1, n - (i + 1))

def solve_even(n, m):
    offset = 1
    half = int(n / 2)
    diff = half - 1
    for i in range(m):
        start = offset
        end = start + diff
        if i % 2 != 0:
            start += half
            end += half
            
            offset += 1
        print(start, end)
        
        diff -= 1



if __name__ == '__main__':
    n, m = map(int, input().split())
    if n % 2 == 0:
        solve_even(n, m)
    else:
        solve_odd(n, m)

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

if M % 2 == 0:
    m = (2 * M + 1) // 2 + 1
else:
    m = (2 * M + 1) // 2

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

j = 1
while j <= (2 * M + 1 - m) // 2:
    print(m + j, (2 * M + 1) - j + 1)
    j += 1

Solution (Python):

import sys
input = sys.stdin.readline
from collections import deque

n, m = map(int, input().split())
ans = []
front = deque([item for item in range(1, (n+1) // 2 + 1)])
back = deque([item for item in range(n // 2 + 2, n + 1)])
while len(front) > 1:
    l = front.popleft(); r = front.pop()
    ans.append((l, r))
while len(back) > 1:
    l = back.popleft(); r = back.pop()
    ans.append((l, r))
for i in range(m):
    print(*ans[i])

Solution (Python):
def solve(n, m):
    assert m * 2 + 1 <= n
    res = []

    maxi = (n - 1) / 2
    if maxi % 2 == 0:
        maxi -= 1
    p = 1
    for i in xrange(maxi, 0, -2):
        q = p + i
        res.append([p, q])
        p += 1

    p = maxi + 1 + 1
    maxi += 1
    for i in xrange(maxi, 1, -2):
        q = p + i
        if q > n:
            continue
        res.append([p, q])
        p += 1

    st1 = set()
    st2 = set()
    assert len(res) >= m
    for (a, b) in res:
        assert 1 <= a <= n
        assert 1 <= b <= n
        assert a != b
        assert not (set([a, b]) & st1)
        st1 |= set([a, b])
        diff = abs(a - b)
        assert not (set([diff, n - diff]) & st2)
        st2 |= set([diff, n - diff])
    return res[:m]

solve(9, 4)
solve(6, 2)
solve(7, 3)
solve(15, 6)
solve(12, 5)
solve(10000, 4999)

'''
for i in xrange(1, 100):
    for j in xrange(1, (i - 1) / 2 + 1):
        
        solve(i, j)
'''

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

assert m * 2 + 1 <= n

for a, b in solve(n, m):
    print a, b

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

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

Solution (Python):
def main():

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

    for i, j in lv:
        print(i, j)


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):


inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])

import math
def get_pairs(N, M):
    sizes_even, sizes_odd = sorted(list(range(0, M, 2)), reverse=True), sorted(list(range(1, M, 2)), reverse=True)
    M2_ceil = math.ceil(M/2.0)
    M2_flor = math.floor(M/2.0)
    pairs = []
    for i in range(M2_ceil):
        pairs.append([1+i, 1+i+sizes_even[i]+1])
    half = 2+sizes_even[0]
    for i in range(M2_flor):
        pairs.append([half+i+1, half+i+1+sizes_odd[i]+1])
    return pairs
pairs = get_pairs(N, M)
for pair in pairs:
    print(pair[0], pair[1])

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

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

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

Solution (Python):

''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys

def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n, m = _ia()
    ret = []
    if n % 2 == 1:
        ai, bi = 1, n
        for _ in range(m):
            ret.append(f"{ai} {bi}")
            ai+=1
            bi-=1
    else:
        ai = n // 2
        bi = ai + 1
        for _ in range(n//4):
            ret.append(f"{ai} {bi}")
            ai -= 1
            bi += 1

        rept = n - bi
        ai, bi = 1, n - 1
        for _ in range(rept):
            ret.append(f"{ai} {bi}")
            ai += 1
            bi -= 1

    return "\n".join(ret[:m])


if __name__ == "__main__":
    print(main())

Solution (Python):
import queue

def main():
    N, M = map(int, input().split())
    N = M * 2 + 1

    q = queue.Queue()
    q.put((1, 1 + M))
    q.put((N - M + 1, N))
    ans = []

    for i in range(M):
        a, b = q.get()

        ans.append(f'{a} {b}')
        q.put((a+1, b-1))
    print(*ans, sep='\n')

if __name__ == '__main__':
    main()

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

Solution (Python):
from collections import deque

N,M = map(int, input().split())
N = 2 * M + 1

lis = [i for i in range(1,N+1)]
lis1 = deque(lis[:N//2+1])
lis2 = deque(lis[N//2+1:])
if M % 2 == 0:
    
    for i in range(M//2):
        a = lis1.popleft()
        b = lis1.pop()
        print(a,b)
    for i in range(M//2):
        a = lis2.popleft()
        b = lis2.pop()
        print(a,b)
else:
    for i in range(M//2+1):
        a = lis1.popleft()
        b = lis1.pop()
        print(a,b)
    for i in range(M//2):
        a = lis2.popleft()
        b = lis2.pop()
        print(a, b)

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    r = 2*m+1
    if m%2:
        for i in range(1,m//2+1):
            ans.append([i,m+1-i])
        for i in range(m+1,(m+1+r)//2+1):
            ans.append([i,m+1+r-i])
    else:
        for i in range(1,m//2+1):
            ans.append([i,m+1-i])
        for i in range(m+1,(m+1+r)//2):
            ans.append([i,m+1+r-i])            
    for a in ans:
        print(*a)


if __name__ == "__main__":
    main()

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

Solution (Python):


n, m = [0] * 2

def format_input(filename = None):
	global n, m
	if filename == None:
		n, m = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(3, 10**5)
		m = rng(1, (n-1) // 2)
		print(n, m)

def get_answer():

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


if __name__ == '__main__':
	format_input()

	get_answer()

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

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

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

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

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

Solution (Python):



import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
a,b=list(map(int,input().split()))
b_i=a
a_i=1
for i in range(b,0,-1):
    if i%2==1:
        print(b_i-i,b_i)
        b_i-=1

    else:
        print(a_i,a_i+i)
        a_i+=1

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

Solution (Python):
from collections import defaultdict,deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


n, m = inpl()
n = 2 * m + 1

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

base=m+1
for i in range((n-m)//2):
    print(base + i, n - i)

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

if N % 2 ==  1:
    for i in range(M):
        print (i + 1, N - 1 - i)
elif N == 4:
    print (1, 2)
else:
    lst = [True] * N

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

Solution (Python):


import sys
import math



from collections import deque                
















def main():
    mod = 1000000007                
    inf = float('inf')              
    inf = 2 ** 64 - 1               
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, m = mi()
    L = [i for i in range(1, n+1)]
    if n % 2 == 1:
        for dist in range(m):   
            print(f"{L[dist]} {L[-1-dist]}")
    else:
        if (n - 2) % 4 == 0:
            tmp = (n - 2) // 4
        else:
            tmp = (n - 2) // 4 + 1
        for dist in range(m):
            if dist + 1 <= tmp: 
                print(f"{L[dist]} {L[-1-dist]}")
            else:
                print(f"{L[dist]} {L[-2-dist]}")



if __name__ == "__main__":
    main()

Solution (Python):
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

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

else:

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

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

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

            for i in range(n//2+1,n//2+n//4+1):
                print(i,j)
                j -= 1
        else:
            for i in range(1,n//4+1):
                print(i,n//2+1-i)
            j = n-1
            for i in range(n//2+1,n//2+n//4):
                print(i,j)
                j -= 1
    else:
        for i in range(1,m+1):
            print(i,n-i)
if __name__ == '__main__':
    main()

Solution (Python):


n, m = [0] * 2

def format_input(filename = None):
	global n, m
	if filename == None:
		n, m = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(3, 10**5)
		m = rng(1, (n-1) // 2)
		print(n, m)

def get_answer():
	median = n // 2

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


if __name__ == '__main__':
	format_input()

	get_answer()

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

from math import gcd

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

Solution (Python):
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n,m = l_in()






i = 1
s = set()
if n%2 == 0:
    s.add(n//2)
    j = n
    for cnt in range(m):
        while True:
            if min(j-i, n-(j-i)) in s:
                j -=1
            else:
                break
            
        print(i,j)
        s.add(min(j-i, n-(j-i)))

        i+=1
        j-=1
        
else:
    j = n-1
    for cnt in range(m):
        print(i,j)

        i+=1

        j-=1

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

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

x = int(M // 2)

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

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

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

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

end = n
dif = set()
count = 0
for i in range(1, n+1):
    while end-i in dif or n+i-end in dif or end-i == n+i-end:
        end -= 1
    print(i, end)
    dif.add(end-i)
    dif.add(n+i-end)
    end -= 1
    count += 1
    if count == m:
        break

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


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

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

Solution (Python):
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = map(int, read().split())
l = M
checked = [False] * (N + 10)

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

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

Solution (Python):

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

if N%2 == 1:
    for i in range(1,M+1):
        print(i,N+1-i)
        
else:
    f = True
    l,r = 1,N
    for i in range(1,M+1):
        print(l,r)
        l+=1
        r-=1
        if f and (4*l > N):
            l+=1
            f = False

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<N//4:
            print(i+1,N-i)
        else:
            print(i+1,N-i-1)

Solution (Python):
if __name__ == '__main__':
    from sys import stdin
    
    import math
    input = stdin.readline

    

    n, m = map(int, input().split())
    """
    a = random.randint(1, 10**6)
    b  = random.randint(1, 10**6)
    n = random.randint(1, 10**12)
    """
    
    
    for i in range(1,m+1):
        if (m-i)%2 == 1:
            print((m+1-i)//2, (m+1-i)//2+i)
        else:
            print(m+(m+2-i)//2, m+(m+2-i)//2+i)

Solution (Python):
if __name__ == '__main__':
    from sys import stdin
    
    import math
    input = stdin.readline

    

    n, m = map(int, input().split())
    """
    a = random.randint(1, 10**6)
    b  = random.randint(1, 10**6)
    n = random.randint(1, 10**12)
    """
    
    
    for i in range(1,m+1):
        if (m-i)%2 == 1:
            print((m+1-i)//2, (m+1-i)//2+i)
        else:
            print(m+(m+2-i)//2, m+(m+2-i)//2+i)

Solution (Python):


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

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

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

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

if M % 2 == 0:
    k = M // 2
    s1 = 1
    e1 = 2 * k
    s2 = 2 * k + 1
    e2 = 4 * k + 1
else:
    k = (M + 1) // 2
    s1 = 1
    e1 = 2 * k
    s2 = 2 * k + 1
    e2 = 4 * k - 1

n = 0
for _ in range(M):
    if s1 >= e1 or n >= M: break
    print(s1, e1)
    s1 += 1
    e1 -= 1
    n += 1

for _ in range(M):
    if s2 >= e2 or n >= M: break
    print(s2, e2)
    s2 += 1
    e2 -= 1
    n += 1

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

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

Solution (Python):
N, M = map(int, input().split())
f = [False]*N
l = 0
r = N+1
for i in range(M):
    l += 1
    r -= 1
    while True:
        if N % 2 == 0:
            if r-l == N//2:
                r -= 1
                continue
        if f[min(r-l, N-(r-l))]:
            r -= 1
            continue
        break
            
    f[min(r-l, N-(r-l))] = True
    print(l, r)

Solution (Python):

import sys


def solve(N: int, M: int):
    left = 1
    right = N if N%2 == 0 else N-1
    count = 0
    if N%2 == 0:
        p = set()
        while count < M:
            if right-left == N//2 or N-(right-left) in p:
                left += 1
                continue
            print(left,right)
            p.add(right-left)
            left += 1
            right -= 1
            count += 1
    else:
        while count < M:
            print(left,right)
            left += 1
            right -= 1
            count += 1
    return


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

if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
k=n//2
c=0
while c<m:
    d=c//2
    if c%2==0:
        print(k-d,k+1+d)
    else:
        print(d+1,n-1-d)
    c+=1

Solution (Python):
def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys,heapq,math
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return list(map(int, data().split()))
    out = sys.stdout.write
    
    INF = int(1e9)
    mod = int(1e9)+7

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



if __name__ == '__main__':
    main()

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

def main():
    N, M = map(int, read().split())
    ans1 = N // 2
    ans2 = N // 2 + 1
    action = 0
    if N%2 == 0:
        action = -(-N//4)
    for _ in range(M):
        print(ans1, ans2)
        ans1 -= 1
        ans2 += 1
        if ans1 == action:
            ans2 += 1
    return

if __name__ == '__main__':
    main()

Solution (Python):
n, m = list(map(int, input().split()))
c = 1
if n%2 == 1:
    aida = n//2
    flag = 0
    while m > 0:
        if flag == 0:
            print(c, c+aida)
            flag = 1
            m-=1
            aida -= 1
        else:
            print(n-c+1,n-c+1-aida)
            flag = 0
            m-=1
            aida -= 1
            c+=1
else:
    aida = n//2-1
    flag = 0
    while m > 0:
        if flag == 0:
            print(c, c+aida)
            flag = 1
            m-=1
            aida -= 1
        else:
            print(n-c+1,n-c+1-aida)
            flag = 0
            m-=1
            aida -= 1
            c+=1

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

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

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

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

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

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

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

x = 1
for i in range(m):
    a,b = ge[i]
    print(x,x+a)
    x += 1

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))


N, M = lr()
answer = [[0, 0] for _ in range(M)]
if N&1:
    for i in range(M):
        answer[i][0] = i+1

    cur = M+1
    used = set()
    for i in range(M-1, -1, -1):
        while cur - answer[i][0] in used:
            cur += 1
        answer[i][1] = cur
        diff = answer[i][1] - answer[i][0]
        used.add(diff)
        cur += 1
else:
    l = list(range(1, M+1))
    odd = [x for x in l if x&1]
    even = [x for x in l if x%2==0]
    cur = 0
    for x in odd[::-1]:
        answer[cur] = [cur+1, cur+1+x]
        cur += 1
    now = 1 + odd[-1] + 1
    for x in even[::-1]:
        answer[cur] = [now, now+x]
        now += 1
        cur += 1

for a in answer:
    if a[0] == 0:
        continue
    print(*a)