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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

while i < int(N/2):
    i += 1
    if N % 2 == 0:
        if i == N / 2:
            break
        print(f"{i+1} {N-i}")
    else:
        print(f"{i} {N-i}")

Submission status: Wrong Answer

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

done = 0
i = 1
while done < m:
	a, b = i, n-i+1
	diff1 = b - a
	diff2 = a - b + n
	if diff1 == diff2:
		pass
	else:
		print(a, b)
		done += 1
	i += 1

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().rstrip().split(" "))
ans = [[False for _ in range(N)] for _ in range(N)]

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

Submission status: Wrong Answer

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


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

else:
    a=1
    b=n
    sa=[]
    usiro=m//2
    mae=usiro
    if(m%2==1):
        mae+=1
    for i in range(mae):
        sa.append(n-i*2-1)
    for i in range(usiro):
        sa.append((usiro-i)*2)
    for i in range(m):
        gosha=n-i
        print(gosha-sa[i],gosha)

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-i)
else:
    cnt = 0
    for i in range(m):
        if abs(i+1-(n-i)) == n//2:
            cnt = 1
        print(i+1,n-i-cnt)

Submission status: Wrong Answer

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

i = 0
while i < m:
    if n%2 == 0 and n-i-1-(i+1) == n/2:         
        n -= 1
    print(i+1,n-i-1)
    i += 1

Submission status: Wrong Answer

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

    if m == 1:
        print('2 3')
        exit()

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, m = [int(x) for x in input().split()]
if(n % 2 == 0):
    used = [False for i in range(n)]
    for i in range(1, m+1):
        for j in range(n):
            if not(used[j] or used[(j+i) % n]):
                print(j+1, (j+i) % n+1)
                used[j] = True
                used[(i+j) % n] = True
                break

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
cnt=0
i=1
d=0
while cnt<m:
    a,b=i,n-(i+d)+1
    if b-a != n-b+a:
        print(a,b)
        i += 1
        cnt += 1
    else:
        print(a,b-1)
        d += 1
        i += 1
        cnt += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import sys

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

N, M = MAP()

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
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%4 == 2:
        action = -(-N//4)
    for _ in range(M):
        print(ans1, ans2)
        ans1 -= 1
        ans2 += 1
        if ans1 == action:
            ans2 += 1
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
ans = []
i = 1
if N % 2 == 0:
    s = set()
    d = 1
    D = list(range(N,N-M,-1))
    F = list(range(1,M+1))
    start = D[0]
    D.remove(start)
    D = D[::-1]
    E = [start]
    E.extend(D)
    for e, f in zip(E,F):
        print(f,e)




else:
    for m in range(M):
        ans.append([i,N+1-i])
        i+= 1
        
    for a in ans:
        print(*a)

Submission status: Wrong Answer

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

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

if n%2 == 0 and m%2 == 0:
    if n == 2*m + 1:
        print(1, n)
        left = 1
        right = n-3
        for _ in range(m-1):
            print(left, right)
            left += 1 
            right -= 1
    else:
        left = (n-2)/2
        right = (n-2)/2 + 1
        for _ in range(m):
            print(left, right)
            left -= 1
            right += 1
else:
    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 = map(int, input().split())
if m == 1:
    print(1, n)
    exit()
if n % 2 == 1:
    for i in range(m):
        print(i+1, n-i-1)
else:
    j = 2
    for i in range(m):
        print(j, n - i)
        j += 1
        if (i == 0):
            j += 1

Submission status: Wrong Answer

Solution code:
# import numpy as np
# import queue
# import heapq


def main():
    solve()


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

    if M == 1:
        print(1, 2)
        return

    ds = []

    for n in range(M//2 + 1):
        s = 2 * n + 1
        ds.append(s)

        if len(ds) < M:
            ds.append((-s) % (N-1))

    ds.sort(reverse=True)

    for i in range(M):
        p = i + 1
        d = ds[i]
        print(p, p + d)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ans_i = n//2
ans_j = ans_i+1
n_list = [0]*(n+1)
for _ in range(m):
    if n_list[ans_j-2] == 0 and n_list[ans_j-1]:
        ans_j -= 2
    if n_list[ans_i+2] == 0 and n_list[ans_i+1]:
        ans_i += 2
        
    if abs(ans_j-ans_i) == abs(n-ans_j+ans_i):
        if ans_i <= n-ans_j: ans_j += 1
        else: ans_i -= 1
    print(ans_i, ans_j)
    
    n_list[ans_i] = 1
    n_list[ans_j] = 1
    
    ans_i -= 1
    ans_j += 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())
for i in range (m):
    N =n//2
    print(N-i,N+1+i)

Submission status: Wrong Answer

Solution code:
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 - 2
    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

Submission status: Wrong Answer

Solution code:
inputLine=input()
N=int(inputLine.split(" ")[0])
M=int(inputLine.split(" ")[1])

result = []
for i in range(M):
    result.append([-1,-1])

for i in range(len(result)):
    result[i][0] = i % N + 1

    if N % 2 == 0:
        result[i][1] = N - result[i][0] + 1
    else:
        result[i][1] = N - result[i][0]

for i in range(len(result)):
    print(result[i][0], result[i][1])

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    used = [0 for _ in range(N)]
    cur = 0
    pairs = []
    if N % 2 == 1:
        for gap in range(1, M+1):
            while used[cur] or used[(cur + gap) % N]:
                cur += 1
                if cur >= N:
                    cur %= N
            pairs.append((cur, cur + gap))
            used[cur] = 1
            used[(cur+gap) % N] = 1
    else:
        a = 0
        b = N-2
        while len(pairs) < M:
            if len(pairs) == M-1:
                pairs.append((a, a+1))
                break
            pairs.append((a, b))
            a += 1
            b -= 1

    for p in pairs:
        print(p[0]+1, p[1]+1)



main()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


if N >= 4*M:
    for m in range(M):
        print(m+1, N-m)
else:
    print(1, 2)
    for m in range(2, M+1):
        print(m+1, 2*m+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

j = 0

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

Submission status: Wrong Answer

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

x = n // 2
y = x + 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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
cset=set()
tcount=0

while count<M:
    if (g-s) not in cset:
        print(s,g)
        cset.add(g-s)
        cset.add(N-(g-s))
        count+=1

    if tcount%2==0:
        s-=1
    else:
        g+=1
    tcount+=1

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
if m == 1:
    print(1,2)
elif n%2 == 1:
    l = list(range(1,n//2+1))[::-1]
#    print(l)
    for i in l[:m]:
        print(i,n-i)
else:
    for i in range(1,m):
        print(i,n-i)
    print(m,n//2)

Submission status: Wrong Answer

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

a = 1
b = N
step = 0
used = [False]*100000
for i in range(M):
    if N%2 == 0 and b-a == N/2-1:
        b = b-1
    
    print(a, b)
    
    a = a + 1
    b = b - 1
    
    
    # used[s] = True
    # used[s+b] = True

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,M=map(int,readline().split())
    a=1
    if N%2==1:
        b=N-1
    else:
        b=N
    for i in range(M):
        print(a,b)
        a+=1
        b-=1
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8


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

    a, b = [None] * M, [None] * M
    if N % 4 != 2:
        for i in range(M):
            a[i] = i+1
            b[i] = N-i
        
        for i in range(M):
            print(a[i], b[i])
    else:
        for i in range(M):
            a[i] = i+1
            b[i] = N-i
        b[-1] -= 1
        
        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 == 1:
    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:
#code
N,M=map(int,input().split())
p1=N//2
p2=N//2+1
print(p1,p2)
p1-=1
p2+=1
M-=1
while M:
    if(N%2==0 and (p2-p1)==N//2):
        p1-=1
    else:    
        print(p1,p2)
        p1-=1
        p2+=1
        M-=1

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import combinations
    n, m = map(int, input().split())
    if n % 2 == 1:
        l = n // 2
        a = 1
        b = 2 * l
        while a <= l:
            print(a, b)
            a += 1
            b -= 1
    else:
        l = n // 2
        a = 2
        b = 2 * (l - 1) + 1
        while a <= l:
            print(a, b)
            a += 1
            b -= 1


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# modint
# https://qiita.com/wotsushi/items/c936838df992b706084c

# MOD = 10**9 + 7
MOD = N

class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    # // : 商。　逆元はフェルマーの小定理を利用している
    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    # ** : 指数
    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    # x が Modint、y が通常の int の場合に、y.__add__(x) に対して、何を適用するか、定義している（→ x.__add__(y)を呼べ） 
    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def int(self):
        return self.x

A = [int(i) for i in range(N)]

B = []

for n in range(1,M+1):
    i = ModInt(n)
    x = ModInt(A[0])
    A.remove(A[0])

    y = x + i
    if y.int() in A:
        A.remove(y.int())
        B.append((x,y))
        continue

    y = x - i
    if y.int() in A:
        A.remove(y.int())
        B.append((x,y))
        continue    

for i in B:
    print(i[0].int()+1, i[1].int()+1)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
cnt = 1
cnt_ = 0
answer = []
checked = set()
while len(answer) != M:
    d = abs((N - cnt_) - cnt)
    if N - d in checked:
        cnt_ += 1
        continue
    answer.append((cnt, N - cnt_))
    checked.add(d)
    cnt += 1
    cnt_ += 1

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

Submission status: Wrong Answer

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

highest = n // 2 * 2
for i in range(0, m + 1, 2):
    print("{0} {1}".format(1 + i // 2, highest - i // 2))
    if i + 1 < m:
        print("{0} {1}".format(n // 2 - i // 2, n // 2 + 1 + i // 2))

Submission status: Wrong Answer

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



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = [[n//2+1,n//2+2]]
    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:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
if m == 1:
    print(1,2)
elif n%2 == 1:
    l = list(range(1,n//2+1))[::-1]
#    print(l)
    for i in l[:m]:
        print(i,n-i)
else:
    for i in range(1,m):
        print(i,n-1)
    print(m,n//2)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n, m = map(int, input().split())

s = 1
f = n
ans = []
d = defaultdict(lambda: False)
i = 0
while i < m:
    # print(s, f, i)
    tmp = abs(s - f)
    a, b = min(tmp, n - tmp), max(tmp, n - tmp)
    if d[a] or d[b]:
        f -= 1
        continue
    d[a] = True
    d[b] = True
    ans.append(f"{s} {f}")
    s += 1
    f -= 1
    i += 1

print("\n".join(ans))

Submission status: Wrong Answer

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

ans = []

for i in range(1,M+1):
    ans.append([i])
ans = ans[::-1]
for i in range(0,M):
    ans[i].append(M + i+1)
for x in ans:
    print(x[0],x[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    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 m % 2 == 1:
        for dist in range(m):   
            print(f"{L[dist]} {L[-1-dist]}")
    else:
        for dist in range(m // 2):
            print(f"{L[dist]} {L[-1-dist]}")
        for dist in range(m // 2):
            print(f"{L[dist]} {L[-2-dist]}")

        

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = int(n/2)
b = a+1
for i in range(m):
	if n%2 == 0 and b-a >= n/2:
		b += 1
	print(a,b)
	a -= 1
	b += 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, nowR-nowL, (nowL-nowR)%N)
        print(nowL,nowR)
        nowL+= 1
        nowR-=1
else:
    OUT = N//2
    flag = 0
    nowL = 1
    nowR = 2*M+2
    for i in range(M):
        if nowR-nowL<(nowL-nowR)%N and flag==0:
            nowR -= 1
            flag = 1
        #print(nowL,nowR, nowR-nowL, (nowL-nowR)%N)
        print(nowL,nowR)
        nowL+= 1
        nowR-=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

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

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