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

    left = 1
    right = M*2
    for _ in range(M):
        print(left, right)
        left += 1
        right -= 1


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import random

def rand_ints_nodup(a, b, k):
  ns = []
  while len(ns) < k:
    n = random.randint(a, b)
    if not n in ns:
      ns.append(n)
  return ns

N, M = map(int, input().split())
a = rand_ints_nodup(1, 2 * M, 2 * M)
for i in range(M):
	print(a[2 * i], a[2 * i + 1])

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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


if __name__ == '__main__':
    main()

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:
import sys
import math

# 総当りができる組み合わせを探す
if __name__ == '__main__':
    n, m = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    c = n // 2
    for i in range(m):
        print(c-i, c+i+1)

Submission status: Wrong Answer

Solution code:
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
if N % 2:
    for k in range(1,M+1):
        print(k, 2*k)
elif M % 2 == 0:
    m = M // 2
    for k in range(m):
        print(k+1, 4*m+1-k)
    for k in range(m):
        print(m+1+k, 3*m-k)
else:
    m = M // 2
    for k in range(m):
        print(k+1, 4*m+3-k)
    print(m+1, 3*m+2)
    for k in range(m):
        print(m+2+k, 3*m+1-k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 = [[i + 1, None] for i in range(m)]
    v = n
    j = m + 1
    for i in range(m):
        ans[i][1] = j
        j += 1
    for a in ans:
        print(*a)
    return


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

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

    used = set()
    for m in range(M):
        print("{} {}".format(start, end))
        fdiff = end - start
        bdiff = N - fdiff
        used.add(fdiff)
        used.add(bdiff)

        start += 1
        end -= 1

        fdiff = end - start
        bdiff = N - fdiff
        if fdiff in used:
            start += 1

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = list(map(int, input().split()))
    if N % 2 == 1:
        for i in range(M):
            print(i + 1, N - i - 1)
            
    else:
        A = [False] * N
        t = 0
        A[0] = A[-1] = True
        print(1, N)
        for i in range(1, M):
            while A[t]:
                t += 1
            A[t] = True
            if A[(t + i + 1) % N]:
                print("Fail")
                return
            A[(t + i + 1) % N] = True
            print(t + 1, t + i + 2)

main()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ans = []
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:
# coding: utf-8
import sys

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

# M個用意する対戦場の数字の差が異なるようにする
N, M = lr()
answer = [[0, 0] for _ in range(M)]
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 or N - (cur - answer[i][0]) in used:
        cur += 1
    answer[i][1] = cur
    diff = answer[i][1] - answer[i][0]
    used.add(diff)
    used.add(N-diff)
    cur += 1

for a in answer:
    print(*a)

Submission status: Wrong Answer

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

for i in range(m):
    print('{} {}'.format(i+1, n))

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
a=[0 for i in range(M)]
b=[0 for i in range(M)]
for k in range(M):
    a[k]=int((k+1)*(1+math.sqrt(5))/2)
    b[k]=a[k]+k+1
    a[k]%=N
    b[k]%=N
for i in range(M):
    print(a[i]+1,b[i]+1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n,m=MI()
    l=[]
    x=(n//2)
    y=x+1
    l.append([x,y])
    for i in range(1,m):
        l.append([x-i,y+i])
    l.sort(key=lambda x: x[0])
    for i in range(m):
        print(*l[i])

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
dat = []
for i in range(m):
    dat.append([i+1])
#print(dat)
for i in range(m):
    dat[m - 1 - i].append(n - i)
#for i in range(m):
#    dat[m - 1 - i].append(m+i+1)
#print(dat)
for a,b in dat:
    print(a,b)

Submission status: Wrong Answer

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

if n % 2 == 0:
    S = set()
    for i in range(m):
        a = i
        b = n - i - 1
        while b - a in S or a - b + n in S:
            b -= 1
        S.add(b - a)
        S.add(a - b + n)
        print(a + 1, b + 1)
else:
    for i in range(m):
        print(i + 1, m * 2 - i)

Submission status: Wrong Answer

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

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+1
    for i in range(M):
        if nowR-nowL==OUT:
            nowR-=1
        elif nowR-nowL==2:
            nowR-=1
        print(nowL,nowR)
        nowL+= 1
        nowR-=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())

a = [str(i) for i in range(1,N+1)]
b = [str(i) for i in range(N,0,-1)]

for i in range(M):
    print(a[i] + ' ' + b[i])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# process
ans = []
t = 1
for i in range(M):
    ans.append((t, N-t))
    t += 1

# output
[print(a, b) for a, b in ans]

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:
N,M = map(int,input().split())
if N%2 == 1:
    for i in range (M):
        print(i + 1,N - i)
elif N%4 == 0:
    if M >= N//4 + 1:
        for i in range(N//4):
            print(i + 1,N - i)
        for j in range(M - N//4):
            print(N//4 + j + 1,N - N//4 - j - 1)
    else:
        for i in range(M):
            print(i + 1,M - i)
else:
    k = (N - 2)//4
    if M >= k + 1:
        for i in range(k):
            print(i + 1,N - i)
        for j in range(M - k):
            print(k + j + 1,N - k - j -1)
    else:
        for i in range(M):
            print(i + 1,M - i)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N,M=(int(x) for x in input().rstrip('\n').split())
a = 1
b = N
check = 0
for i in range(1,M+1):
  print(a,b)
  a += 1
  b -= 1
  if b-a == N/2 + 1:
    if check == 0:
      b -= 1
      check += 1
  elif b-a == N/2:
    if check ==0:
      b -= 1
      check += 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, 2*m-i)
else:
    for i in range(m):
        print(i+1, n-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 - 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())
result = []
x = [i for i in range(1, 2*m+2)]
for i in range(m):
    result.append([x[i], x[-i-1]])
for j in result:
    print(*j)

Submission status: Wrong Answer

Solution code:
n, m = [int(x) for x in input().split()]
if n % 2 == 0:
    temp = n // 2
    for i in range(m):
        print(temp - i, temp + i + 1)
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:
    A = list(range(1, N))
else:
    A = list(range(1, N+1))
i = 1
while (len(A) >1) and i<=M:
    print(A.pop(0), A.pop())
    i+=1

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n%2 == 1:
    d = list(range(1, n+1))
    from collections import deque
    d = deque(d)
    ans = [0]*m
    for i in range(m):
        a = d.popleft()
        b = d.pop()
        ans[i] = (a, b)
    for i in range(m):
        print(*ans[i])

else:
    d = list(range(1, n+1))
    from collections import deque
    d = deque(d)
    ans = [0]*m
    for i in range(m):
        a = d.popleft()
        b = d.pop()
        if b-a == n//2:
            a = n//2
            b = n//2+1
        ans[i] = (a, b)
    for i in range(m):
        print(*ans[i])

Submission status: Wrong Answer

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

a = 1
diff = 1
non_used = [True]*(N+1)
for i in range(M):
    if a + diff <= N:
        print(a, a+diff)
        non_used[a] = False
        non_used[a+diff] = False
    else:
        print(a, a+diff-N)
        non_used[a] = False
        non_used[a+diff-N] = False
    diff += 1
    while not non_used[a]:
        a += 1

Submission status: Wrong Answer

Solution code:
i = list(map(int, input().split()))
n = i[0]
m = i[1]
dif = n -2*m
for num in range(0,m):
    print(n - num*dif, num*dif + 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,2*m-i)
else:
    k=n//2
    for i in range(m):
        a=k-i
        b=k+1+i
        c=1 if 2*i+1>k else 0
        print(a,b+c)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
ans = []
if N % 2 == 1:
    N -= 1
    a = N // 2
    b = N // 2 + 1
    ans.append([a,b])
    for i in range(M):
        a -= 1
        b += 1
        ans.append([a,b])
else:
    a = N // 2
    b = N // 2 + 1
    ans.append([a,b])
    c = 1
    d = N - 1
    ans.append([c,d])
    for i in range(M):
        a -= 1
        b += 1
        ans.append([a,b])
        c += 1
        b -= 1
        ans.append([c,d])
for i in range(M):
    print('{0} {1}'.format(ans[i][0],ans[i][1]))

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
a = list(range(1, (n + 1) // 2))

k = 1
c = 0
d = []
for i in a[::-1]:
    while True:
        if k not in d:
            if k + i not in d:
                print(k, k+i)
                c += 1
                d.append(k)
                d.append(k + i)
                k += 1
                break
        k += 1
    if c == m:
        break

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
res = []
for k in range(1, M + 1):
  res.append((k, N - k))
for r in res: print(*r)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
flag = [False]*(10**6)
plu_flag = [False]*(10**6)
plu = 1
for i in range(1,N+1):
  if M==0:
    break
  if (flag[i])or(flag[i+plu]):
    continue
  if (plu_flag[plu])or(plu_flag[N-plu]):
    plu+=1
    continue
    
  plu_flag[plu]=True
  plu_flag[N-plu]=True
  flag[i]=True
  flag[i+plu]=True
  print(i,i+plu)
  plu+=1
  M-=1

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
out = []
for i in range(m):
    out.append([i + 1, n - i])
# print(out)
if len(out) > 1 and n == m:
    out[0][1], out[1][1] = out[1][1], out[0][1]
for i, j in out:
    print(i, j)

Submission status: Wrong Answer

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

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+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
        if N % 2 == 0 and M > 1 and N > M*2+1:
            print(N//2 - j, N//2 +2+j)
        else:
            print(N//2 - j, N//2 +1+j)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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())
dat = []
for i in range(m):
    dat.append([i+1])
#print(dat)
for i in range(m):
    dat[i].append(m+i+1)
#for i in range(m):
#    dat[m - 1 - i].append(m+i+1)
#print(dat)
for a,b in dat:
    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//2-i, n//2+i+1)
else:
  for i in range(m):
    print(n//2-i-1, n//2+i+1)

Submission status: Wrong Answer

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
Ans=[]
ct=0
S=set()
flag=True
for i in range(1,n):
  if i!=1 and (n%i==0 and n//i==2):
    continue
  elif flag and n-i not in S and i not in S:
    Ans.append([1,i+1])
    ct+=1
    S.add(i)
    S.add(n-i)
    if ct==m:
      flag=False
for a in Ans:
  print(*a)

Submission status: Wrong Answer

Solution code:
import random
N,M = map(int, input().split())
player=[i for i in range(1,N+1)]
dis=[]
for i in range(M):
    q=True
    while q:
        a=random.sample(player,2)
        x=a[0]
        y=a[1]
        if abs(x-y) not in dis:
            print(x,y)
            dis.append(abs(x-y))
            dis.append(N-abs(x-y))
            player.remove(x)
            player.remove(y)
            q=False

Submission status: Wrong Answer

Solution code:
from sys import stdin


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


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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	n = int(N // 2)
	if N % 2 == 0:
		cnt = 0
		jud = 0
		for i in range(M + 1):
			if 4 * i + 2 == N:
				jud = 1
			else:
				if jud == 0:
					print(n - i, n + 1 + i)
				else:
					print(n - i + 1, n + 1 + i)
				cnt += 1
			if cnt == M:
				break

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


	


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# process
ans = []
t = 1
for i in range(M):
    ans.append((t, N-t+1))
    t += 1

# output
[print(a, b) for a, b in ans]

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    n, m = map(int, input().split())

    left = n // 2
    right = left + 1
    for i in range(m):
        print("{0} {1}".format(left, right))
        left -= 1
        right += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve(n,m):
    Ans=[]
    if n%2==1:
        for i in range(1,m+1):
            Ans.append((i,n-i))
        return Ans
    if m==1:
        return ((1,n),)
    a=1; b=n
    d1=n-1; d2=1
    while d1>d2:
        Ans.append((a,b))
        a+=1; b-=1
        d1-=2; d2+=2
    b-=1
    while a<=m:
        Ans.append((a,b))
        a+=1
        b-=1
    return Ans
    
def main():
    n,m=map(int,input().split())
    Ans=solve(n,m)
    for ans in Ans:
        print(*ans)
    
if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

s = 1
f = 2 * m
ans = []
for i in range(m):
    ans.append(f"{s} {f}")
    s += 1
    f -= 1
print("\n".join(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
a = 1
b = N-1
for i in range(M):
    print(str(a) + " " + str(b))
    a += 1
    b -= 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 - i)
elif N%4 == 0:
    if M >= N//4 + 1:
        for i in range(N//4):
            print(i + 1,N - i)
        for j in range(M - N//4):
            print(N//4 + j + 1,N - N//4 - j - 1)
    else:
        for i in range(M):
            print(i + 1,M - i)
else:
    k = (N - 2)//4
    if M >= k + 2:
        for i in range(k):
            print(i + 1,N - i)
        for j in range(M - k):
            print(k + j + 1,N - k - j -1)
    else:
        for i in range(M):
            print(i + 1,M - i)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N,M=(int(x) for x in input().rstrip('\n').split())
a = 1
b = N
check = 0
for i in range(1,M+1):
  print(a,b)
  a += 1
  b -= 1
  if b-a == N/2 + 1:
    if check != 0:
      b -= 1
      check += 1
  elif b-a == N/2:
    if check !=0:
      b -= 1
      check += 1

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)

def solve(N, M):
    K = N // 2
    k = 1
    i = K
    used_k = set()
    ans = []
    for _ in range(M):
        ans.append(str(i) + " " + str(i+k))
        i -= 1
        used_k.add(k)
        used_k.add(N-k)
        while k in used_k:
            k += 2

    return "\n".join(ans)

if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    print(solve(N, M))

Submission status: Wrong Answer

Solution code:
import math
N,M = map(int,input().split())
b = math.ceil(((N+1)/2))
a = b-1
for i in range(M):
    print(str(a) +" " + str(b))
    a-=1
    b+=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
a, b = n // 2, (n // 2) + 1
for _ in range(m):
    print(a, b)
    a, b = a - 1, b + 1

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

aa = n//2
bb = aa+1

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

    for i in range(m):
        print(aa,bb)

        if i == 0:
            aa-=2
        else:
            aa-=1
        if aa==0:
            aa=n
        bb+=1
        if bb>=n+1:
            bb=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	n = int(N // 2)
	if N % 2 == 0 and N % 4 != 0:
		cnt = 0
		jud = 0
		for i in range(M + 1):
			if 4 * i + 2 == N:
				jud = 1
			else:
				if jud == 0:
					print(n - i, n + 1 + i)
				else:
					print(n - i + 1, n + 1 + i)
				cnt += 1
			if cnt == M:
				break

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


	


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#code
N,M=map(int,input().split())
if(False):
    p1=N//2
    p2=N//2+1
    print(p1,p2)
    p1-=1
    p2+=1
    M-=1
    while M:
        print(p1,p2)
        p1-=1
        p2+=1
        M-=1
else:
    p1=1
    p2=N-1
    print(p1,p2)
    p1+=1
    p2-=1
    M-=1
    while M:
        print(p1,p2)
        p1+=1
        p2-=1
        M-=1

Submission status: Wrong Answer

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

a = n // 2
ans = []
for i in range(m):
  ans.append(str(a-i) + ' ' + str(a+1+i))
for i in range(m):
  print(ans[m-1-i])

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if(n % 2 == 0):
    c = 0
    i = 0
    while(c < m):
        if(n-2*i-1 != n // 2):
            print(i+1,n-i)
            c += 1
        i += 1

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

Submission status: Wrong Answer

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

period = set(range(N))

for i in range(M):
  j = i
  #print(i)
  #print(period)
  while j < (N - 2) - j:
    if j != (N - 2) - j and {j, (N - 2) - j} <= period:
      print(f'{j + 1} {(N - 2) - j + 1}')
      period -= {j, (N - 2) - j}
      #print(period)
      break
    j += 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-i)
else:
    for i in range(M):
        print(i+1,N-M+1+i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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


if __name__ == '__main__':
    main()