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:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N, M = Scanner.map_int()
    for i in range(M):
        print(i + 1, N - i)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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())
ans = []
d = N
if N%2 == 1:
    N -= 1
for m in range(M):
    ans.append([m+1,m+d])
    d -= 2
for e in ans:
    print(*e)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


s = 0
b = 1
used = set()
for i in range(M):
    for i in range(N):
        if i not in used:
            s = i
            break
    print(s%N+1, (s+b)%N+1)
    # print(s+1, (s+b)+1)
    used.add(s)
    used.add(s+b)
    b += 1

Submission status: Wrong Answer

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


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


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

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

l = 1
r = 2

for i in range(m):
    print(str(l)+" "+str(r))
    l += 2
    r += 2
    if l >= n+1:
        l = 1
    if r >= n+1:
        r = 1

    if l == r:
        r += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


n, m = inpl()
ans = []
j = 2
m=m//2*2+1
for i in range(m-1, -1,-1):
    print("{} {}".format(i + 1, i + j))
    j+=2

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


n, m = inpl()
ans = []
j = 2
m=m*2//2+1
for i in range(m-1, -1,-1):
    print("{} {}".format(i + 1, i + j))
    j+=2

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)
            s -= 1
    else:
        s = N // 2
        for i in range(M // 2 + 1):
            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 + 1)):
            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:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a=1
b=2*m

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

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

	


if __name__ == '__main__':
	main()

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 = []
    for i in range(m + 1):
        if (4 * i + 2) == n: continue
        ans.append((i + 1, n - i))
    for a in ans[:m]:
        print(*a)
    return


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

Submission status: Wrong Answer

Solution code:
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


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


def llmi(n):
    return [lmi() for _ in range(n)]


N, M = lmi()


def validate(ans):
    battled = set()
    for n in range(N):
        for x, y in ans:
            p1 = (x + N - n) % N
            p2 = (y + N - n) % N
            b = frozenset([p1, p2])
            # print(b)
            if b in battled:
                return False
            battled.add(b)
    return True


def solve():
    ans = []
    for i in range(M):
        ans.append((i + 1, 2*M - i))
        print(*ans[-1])
    return ans


solve()
# print(validate(solve()))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

MOD = 10**9+7

n,m = get_nums_l()
if n%2 == 0:
    n -= 1

for l in range(1,m+1):
    r = n - l + 1
    print(l, r)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,M = LI()

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m = list(map(int,input().split()))
for i in range(m):
    print("{x} {y}".format(x=n//2-i,y=n//2+1+i))

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(i+1,N-i)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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



resolve()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
n = list(range(1, N+1))
for i, j in zip(n[::2][:M], n[1::2][:M]):
    print(i, j)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(N: int, M: int):
    for i in range(M):
        print(i+1,N-i)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
from collections import *
n,m = map(int,input().split())
d = dict()
st,off = 1,1
for i in range(m):
	print(st,st+off)
	d[st] = 1
	d[st+off] = 1
	off += 1
	while(st in d):
		st += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def func(A, B, x):
    import math
    return math.floor(A * x / B) - A * math.floor(x / B)

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

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




main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = [[1, N]]
l, r = 1, N
for n in range(2, M + 1):
    l += 1
    r -= 1
    ans.append([l, r])

for l, r in ans:
    print(l, r)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
a = 1
b = N - 1
for _ in range(M):
    print(a, b)
    a += 1
    b -= 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:
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 = map(int,input().split())
ans = []
i = 1
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:
import sys

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

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
L = [[1,N-1]]
for i in range(1,M):
    L.append([L[0][0]+i,L[0][1]-i])

for i in L:
    print(" ".join(map(str,i)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


# 
# (0,M),(1,M+2), ... (M//2, 2M)
# (M//2+1, M+1), ...

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

def factorize(n):
    ## 素因数分解
    # arr = factorize(20)
    # arr == [[2, 2], [5, 1]]
    
    result = []
    tmp = n
    for k in range(2, int(n ** 0.5) + 1):
        cnt = 0
        while tmp % k == 0:
            cnt += 1
            tmp //= k
        if cnt > 0:
            result.append([k, cnt])
    if tmp != 1:
        result.append([tmp, 1])
    return result

def divisorize(n):
    ## 約数
    # arr = factorize(20)
    # arr == [2, 4, 5, 10, 20]
    f = factorize(n)
    divisors = [1]
    for k in range(len(f)):
        num_divisors = len(divisors)
        for i in range(1, f[k][1] + 1):
            for j in range(num_divisors):
                divisors.append(divisors[j] * f[k][0] ** i)
    return sorted(divisors)

n, m = list(map(int, input().split()))
d = divisorize(n)[1:]

links = []
dones = []
i = 1
for k in range(1, n + 1):
    if k not in d:
        for i in range(1, n + 1):
            if i in dones:
                continue
            ne = (i + k)%n
            if ne == 0:
                ne = n
            if ne not in dones:
                links.append((i, ne))
                dones.append(i)
                dones.append(ne)
                i += 1
                break
for i in range(m):
    print(links[i][0], links[i][1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
ans = [[] for _ in range(m)]

for i in range(m):
    ans[i].append(i+1)
for i in range(m):
    ans[m-1-i].append(m+i+1)
for i in range(m):
    print(*ans[i])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


n, m = inpl()
ans = []
j=2
for i in range(m-1, -1,-1):
    print("{} {}".format(i + 1, i + j))
    j+=2

Submission status: Wrong Answer

Solution code:
n,m = list(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())

ansl = []

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

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

Submission status: Wrong Answer

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

k = n-1
for i in range(m):
    a = i+1
    b= k-i
    print(a,end=" ")
    print(b)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    t = N // 2
    if N % 2 == 1:
        m = N // 2
    else:
        m = -1 + (N // 2)
    l = []
    for i in range((m//2)+1):
        l.append((i+1, M-i+1))
    for i in range(m//2):
        l.append((N-i, N-M+1+i))
    i = 0
    while i < M:
        if l[i][0] == l[i][1]:
            continue
        print(l[i][0], l[i][1])
        i += 1
main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
import fractions

n, m = [int(x) for x in stdin.readline().rstrip().split()]

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

MOD = 10**9+7

n,m = get_nums_l()

for l in range(1,m+1):
    r = n - l + 1
    print(l, r)

Submission status: Wrong Answer

Solution code:
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

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


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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())


for i in range(M):
    print("{} {}".format(N // 2 - i, N // 2 + 1 + N % 2 + 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())

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if (n & 1):
    n -= 1
left = 1
right = n
for _ in range(m):
    print(left, right)
    left += 1
    right -= 1

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)

def solve(N, M):
    K = N // 2
    i = K
    j = K + 1
    ans = []
    for _ in range(M):
        ans.append(str(i) + " " + str(j))
        i -= 1
        j += 1
    return "\n".join(ans)


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a%2 == 1:
    a = a-1

for i in range(b):
    print(str(i+1) + ' ' + str(a-i))

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()
    if n & 1: n -= 1
    ans = []
    for i in range(m + 1):
        if (4 * i + 2) == n: continue
        ans.append((i + 1, n - i))
    for a in ans[:m]:
        print(*a)
    return


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