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



Sample input:
4 1


Sample output:
2 3

Submission status: Wrong Answer

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

cnt1 = M
cnt2 = M+1
for i in range(M):
    print(cnt1,cnt2)
    cnt1-=1
    cnt2+=1

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m = [int(i) for i in input().split()]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
  
kouho = list(set(list(range(1,n+1))) - set(make_divisors(n)))
kouho.sort(reverse=True)
kouho.append(1)

l = 1
r = n + 1
count = 0
for i in kouho:
  if l+i < r:
    print(l, l+i)
    r = l+i
    l += 1
    count += 1
  if count == m:
    break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split(" "))

x = a//2 - b + 1
y = a//2 + b

for i in range(b):
    print(x , y)
    x, y = x+1, y-1

Submission status: Wrong Answer

Solution code:
def main():
    n,m = map(int, input().split())
    ans = []
    if n % 2 != 0:
      n -= 1
    if m > 1:
        for i in range(m):
            ans.append([1+i, n-i])
        for i in ans:
            print(i[0], i[1])
    else:
        print(n//2, n//2+1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

n, m = map(int, input().split())
"""
arr_tmp = np.array(list(range(1,n+1)))
arr = np.array([np.roll(arr_tmp, -1*i) for i in range(n)])
print(arr)

p_list = list(itertools.combinations(list(range(1,n+1)), 2))

for p in p_list:
    print(p, abs(p[0]-p[1]))
    
"""
for i in range(m):
    print('{} {}'.format(i+1, n-i))


"""
n=5,m=2

ABCDE
12345
23451
34512
45123
51234
"""

Submission status: Wrong Answer

Solution code:
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
    # sys.setrecursionlimit(100000)
    INF = int(1e9)
    mod = int(1e9)+7

    n,m=mdata()
    for i in range(1,m+1):
        print(i,n-i)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
n,m = map(int,input().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
i = list(map(int, input().split()))
for j in range(1,i[1]+1):
    print(j, i[0]-j)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
#1,2,3,4,...,n
#m個用意されてる
for i in range(1, m+1):
	print(n//2+1-i, n//2+i)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n,m=mii()



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

Submission status: Wrong Answer

Solution code:

import sys
# sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
# arr = [[int(el) for el in input().split()] for i in range(n)]


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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

N,M = Ints()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
x,y=1,n
for i in range(m):
  print(x,y)
  x+=1;y-=1

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
s = 0
small = n//2
big = small + 1
for i in range(m):
    print(small-s,big+s)
    s += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

num_1 = 1
num_2 = m*2

for i in range(m):
    print(str(num_1) + " " + str(num_2))
    num_1 += 1
    num_2 -= 1

Submission status: Wrong Answer

Solution code:
#author: raghav_0901
from math import *

mod = (10**9) + 7


def _in():
    return [int(x) for x in input().split(' ')]


if __name__ == "__main__":
    n, m = _in()
    j = (n - 1) // 2
    for i in range(1, m + 1):
        print(j, n - j + 1)
        j = j - 1

Submission status: Wrong Answer

Solution code:
(n, m) = map(int, raw_input().split())

p, q = 1, n

for i in xrange(m):
    print p, q
    p += 1
    q -= 1

Submission status: Wrong Answer

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
if n%2:
  for i in range(m):
    print(i+1,n-i-1)
else:
  for i in range(m):
    print(1,n-i)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

     # n:odd, m:odd
     # n:even, m:odd
     first = n // 2
     second = first + 1
     for i in range(m):
          print('{} {}'.format(first - i, second + i))

     # n:odd, m:even
     # n:even, m:even


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
l=1
if n%4==0 or n%2==1:
    r=n
else:
    r=n-1
d=1
for i in range(m):
    print(l,r)
    l+=1
    r-=1

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces


def main():
    n,m = na()
    if n%2 == 1:
        n -= 1
    cnt = 0
    while m > 0:
        print(1+cnt, n-cnt)
        cnt += 1
        m -= 1
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

last = 0
for i in range(1,m+1):
    print(last+1, last+i+1)
    last = last+i+1

Submission status: Wrong Answer

Solution code:
nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]

for i in range(m):
  print(str(i+1)+' '+str(n-i))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N,M=mis()
    for m in range(M):
        print(m+1, N-m)

main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math as mt
import collections as cc
I=lambda:list(map(int,input().split()))
n,m=I()
for i in range(1,m+1):
    print(i,i+n//2)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ans_i = n//2
ans_j = ans_i+1
for i in range(m):
    print(ans_i, ans_i+1)
    ans_i -= 1
    ans_j += 1

Submission status: Wrong Answer

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

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

left = 0
right = n-1
for _ in range(m):
    print(nl[left], nl[right])
    left += 1
    right -= 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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())




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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
j = 1
for i in range(M):
    print(str(j) +" " + str(N))
    j+=1
    N-=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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):
        print(i+1,N-M+1+i)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

prime = [2]

n = 2
while len(prime) < M:
  for p in prime:
    n += 1
    if n % p == 0:
      break
    if n**2 > p:
      prime.append(n)
      break

prime = [1] + prime[:-1]

empty = [True] * N


for p in prime[::-1]:
  i = 0
  while not(empty[i] and empty[i + p]):
    i += 1
  empty[i] = False
  empty[i+p] = False
  print(i+1, i+p+1)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
#1,2,3,4,...,n
#m個用意されてる
for i in range(1, min(m+1, (n-1)//2+1)):
	print(n//2+1-i, n//2+i)

Submission status: Wrong Answer

Solution code:
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:
    print (1, N - 1)
    for i in range(M - 1):
        print (i + 3, N - 2 - i)

Submission status: Wrong Answer

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

a = n // 2
for i in range(m):
  print(str(a-i) + ' ' + str(a+1+i) )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m = list(map(int, input().split()))
flag = 0

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

Submission status: Wrong Answer

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

while m >0:
    print(int(m), int(n-m+1))
    m -= 1

Submission status: Wrong Answer

Solution code:
import math
n,m = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int):
    if N % 2 == 1:
        s = N // 2
        for i in range(M):
            v = i * 2 + 1
            print(s, s + v)
            #print(s, s + v, v, N - v)
            s -= 1
    else:
        s = N // 2
        for i in range(M // 2):
            v = i * 2 + 1
            print(s, s + v)
            #print(s, s + v, v, N - v)
            s -= 1
        s = 1
        for i in range(M - (M // 2)):
            v = N - s - s
            print(s, N - s)
            #print(s, N - s, v, N - v)
            s += 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))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
point = 1
for turn in range(1,m+1):
    print(point,point+turn)
    point = point+turn+1
    turn += 1

Submission status: Wrong Answer

Solution code:
import sys

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


def solve():
    N, M = map(int, rl().split())
    
    last = N if N % 2 == 0 else N - 1
    left = [i for i in range(1, N // 2 + 1)]
    right = [i for i in range(last, N // 2, -1)]
    
    ans = []
    for ans_i in zip(left, right):
        ans.append(ans_i)
    
    for ans_i in ans[len(ans) - M:]:
        print(*ans_i)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
a = 1
b = N
for i in range(M):
    print(a,b)
    a+=1
    b-=1

Submission status: Wrong Answer

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

i = 1
j = N
for k in range(M):
  print(i, j)
  i += 1
  j -= 1

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
for i in range(m):
	print(1,2+i)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
N, M = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]

s=N//2
g=s+1
count=0
while count<M:
    if (g-s)!=N-(g-s):
        print(s,g)
        count+=1
    s-=1
    g+=1

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
for i in range(m):
  print(i+1, n-i-1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, m = LI()
    ans = []
    v = n
    d = defaultdict(int)
    d[0] = 1
    d[n] = 1
    if n & 1: v -= 1
    for i in range(n):
        if d[4 * i + 2]: continue
        if d[v - i - 1]: continue
        ans.append((i + 1, v))
        d[v - i - 1] = 1
        v -= 1
    for a in ans[:m]:
        print(*a)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

ans = []
max_ = 2 * m

for i in range(m):
    ans.append((i + 1, max_ - i))
    
if (n - 2 * m) % 2 == 0:
    ans[0] = (n, ans[0][1])

for i in ans:
    print(*i)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8


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

    a, b = [None] * M, [None] * M
    for i in range(M):
        a[i] = i+1
        b[i] = N-i
    
    for i in range(M):
        print(a[i], b[i])


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = [[n//2,n//2+1]]
    for _ in range(m-1):
        v = ans[-1]
        new = [v[0]-1,v[1]+1]
        if new[0] == 0:
            new[0] = n
        if new[1] == n+1:
            new[1] = 1
        ans.append(new)
    for a in ans:
        print(*a)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor

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

    start = 1
    end = N if N % 2 == 0 else N - 1

    for m in range(M):
        print("{} {}".format(start, end))
        start += 1
        end -= 1

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=lambda x:int(math.floor(x)),lambda x:int(math.ceil(x))
from functools import reduce;gcd=lambda*x:reduce(math.gcd,x);lcm=lambda*x:reduce(lambda x,y:(x*y)//gcd(x,y),x,1)
from collections import deque
Yes=lambda b:print("Yes"if b else"No");YES=lambda b:print("YES"if b else"NO")
is_even=lambda x:True if x%2==0 else False

def is_palindrome(s):
  n=len(s);b=True
  for i in range(int(0.5*n)):
    if s[i]!=s[n-i-1]:b=False
  return b

def main():
  n,m = ints()
  l = floor(n*0.5)
  for i in range(m):
    print(l-i,l+1+i)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

stage = 1
i = 2
pl = [False] * n
pair = [["1","2"]]
pl[0] = True
pl[1] = True
while stage < m:
    if n % i != 0:
        i2 = i
        while pl[i2] or pl[(i2+i)%n]:
            i2 = (i2+1) % n
        stage += 1
        pair.append([str(i2+1), str((i2+i)%n+1)])
        pl[i2] = True
        pl[(i2+i)%n] = True 
    i += 1

for p in pair:
    print(" ".join(p))

Submission status: Wrong Answer

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

def diff(i,j):
  if j<i:
    i,j = j,i
  return min( j-i, n+i-j )

def get_diff(i, d):
  left = i-d if i-d>0 else i-d+ n
  right = i +d if i+d<=n else i+d-n
  return left, right

paired = []
used = set([])
d = 1
while len(used) < m*2:
  for i in range(1, n+1):
    if i in used:
      continue
    l,r = get_diff(i, d)
    if l not in used:
      print(i,l)
      used.add(i)
      used.add(l)
      d += 1
    elif r not in used:
      print(i,r)
      used.add(i)
      used.add(r)
      d += 1
  d += 1

Submission status: Wrong Answer

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

a = N//2
b = a+1

for _ in range(M):
    print(a, b)
    a -= 1
    b += 1

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

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

def print2Num(x,y):
	print(str(x) + " " + str(y))

N, M = input_multiple_number()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
i = list(map(int, input().split()))
n = i[0]
m = i[1]

for num in range(m):
    print(n - num, num + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
for i in range(m):
  print(1,n-i)

Submission status: Wrong Answer

Solution code:
def main():
    n, m = map(int, input().split())
    for i in range(1, m+1):
        print(i, n-i+1)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
	N,M = map(int, input().split())
	ans = []

	l = N//2
	r = l+1

	for _ in range(M):
		print('{} {}'.format(l,r))
		l -= 1
		r += 1
		if l == 0:
			l = N
		if r == N+1:
			r = 0

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
for p1 in range(1, M+1):
    p2 = M*2+1-p1
    print(p1, p2)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
t=1
for i in range(1,m+1):
    print(i,n-i+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n,m=mii()

a=1
b=(n//2)*2
c=(a+b)//2
a=c
b=c+1


for i in range(m):
    print(a+i,b-i)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)


def main():
    N, M = map(int, input().split())
    for i in range(1, M + 1):
        print(i, N + 1 - i)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
e = 0

for i in range(m):
  if n / 2 == 2 * i + 1:
    e = 1
  print(str(n // 2 - i) + " " + str(n // 2 + 1 + i + e))