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(m):
  print(i*2+1, i*2+2)

Submission status: Wrong Answer

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

A = a//2
B = a//2+1
for i in range(b):
    print(A,B)
    A-=1
    B+=1

Submission status: Wrong Answer

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

age = (N+1)//2
sage = N//2

for i in range(M):
    if age == sage:
        age += 1

    print(str(age) + " " + str(sage))

    age += 1
    sage -= 1

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
def f(n):
    if n%N==0:
        return N
    else:
        return n%N

if N%2==1:
    for i in range(M):
        print(i+1,N-i-1)
else:
    start=1
    used=set()
    for i in range(1,M+1):
        s=f(start)
        d=f(start+i)
        while s in used or d in used:
            s=f(start)
            d=f(start+i)
            start+=1
            start%=N
        else:
            used.add(s)
            used.add(d)
            print(f(start),f(start+i))
            start = start+i+1

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)
    else:
        if i>=m//2:
            print(i+1,n-i-1)
        else:
            print(i+1,n-i)

Submission status: Wrong Answer

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

half = N//2
quarter = False
if N%2==1:
    for i in range(M):
        print(half-i,half+i+1)
else:
    for i in range(M):
        if not quarter:
            if 2*i+1 == half:
                quarter = True
                print(half-i, half+i+2)
            else:
                print(half-i, half+i+1)
        else:
            print(half-i, half+i+2)

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=N//2
b=a+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())
I = range(1,n+1)

arenas = [
(1, n-i)
for i in range(m)
]

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

#print(arenas)
#
#matches = []
#for i in range(n):
#    for a,b in arenas:
#        if a in I and b in I:
#            matches.append(tuple(sorted((a,b))))
#    arenas = [(1+a%n, 1+b%n) for a,b in arenas]
#
#print(sorted(matches))
#
#assert len(matches) == len(set(matches))
#

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n % 2 == 1:
    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 + 2:
            tmp -= 2
        else:
            tmp-= 1

Submission status: Wrong Answer

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

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

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

aki = (N-2*M)//2
for i in range(M):
    print(a[i] + ' ' + b[i+aki])

Submission status: Wrong Answer

Solution code:
x = input().split(' ')

n = int(x[0])
m = int(x[1])

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:
n, m  = map(int, input().split())
a = n // 2
d = 1
if n % 2 == 0:
    d = 2
# memo = set([])
for i in range(m):
    # if n - d in memo:
    #     d += 1
    # memo.add(d)
    print(a, a+d)
    a -= 1
    d += 2

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:
n, m = [int(i) for i in input().split(' ')]
for i in range(0, m):
  print(i + 1, n - i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#n=int(input())
n,m=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(q)]
b=(n-1)//2
a=b//2
ll=[[0,0]for i in range(b)]
ll[0]=[1,2]

if b//2==b/2:
    for i in range(1,b):
        if i//2!=i/2:
            ll[i]=[2+a-(i//2),2+a-(i//2)+i+1]
        else:
            if i==b-2:
                ll[i]=[3+b//2,3+b//2+b-2+1]
            else:
                ll[i]=[3+b//2+b-2+1-i//2,3+b//2+b-2+1-i//2+i+1]
else:
    for i in range(1,b):
        if i//2==i/2:
            ll[i]=[2+a-(i//2),2+a-(i//2)+i+1]
        else:
            if i==b-2:
                ll[i]=[3+b//2+1,3+b//2+b-1+1]
            else:
                ll[i]=[3+b//2+b-1+1-(i+1)//2,3+b//2+b-1+1-(i+1)//2+i+1]            

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

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:         
#         # print(i+1, n-i)
#         n -= 1
#     print(i+1,n-i)
#     i += 1

# entry = {i:i for i in range(n)}
# for i in range(n):
#     print(i)
#     print(entry[0],":", entry[5])
#     print(entry[1],":", entry[4])
#     print(entry[2],":", entry[3])
#     for k in entry.keys():
#         entry[k] += 1
#         entry[k] %= n


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from bisect import *
from collections import *

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import pprint

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

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
ans=[]
TF=[0 for _ in range(N)]
i=0
while len(ans)<M:
    for j in range(i+1,N):
        if 2*i%N!=2*j%N:
            ans.append([i,j])
            break
    TF[i]=TF[j]=1
    # print(TF)
    while True:
        if TF[i]:
            i+=1
        else:
            break
# print(TF)
for i,j in ans:
    print(i+1,j+1)

Submission status: Wrong Answer

Solution code:
# E - Rotation Matching

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

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

Submission status: Wrong Answer

Solution code:
def main():
    x,y = map(int,input().split())
    t=y*2-1
    for i in range(1, y+1):
        print(i , i+t)
        t-=2



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

halfPos = N//2

qPos = halfPos // 2+1

q3Pos = halfPos + qPos

for m in range(1, M+1):
  if m % 2:
    print(qPos-m//2, qPos+m//2+1)
  else:
    print(q3Pos-m//2+1, q3Pos+m//2+1)

Submission status: Wrong Answer

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

ans = []
mm = 2*M + 1
for i in range(1, M+1):
    tmp = [str(i), str(mm-i)]
    tmp = ' '.join(tmp)
    ans.append(tmp)
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
from collections import deque
from itertools import product
import sys
import math

sys.setrecursionlimit(200000)
input = sys.stdin.readline


def read():
    N, M = map(int, input().strip().split())
    return N, M


def solve(N, M):
    pairs = []
    n = N if N % 2 == 0 else N - 1
    for m in range(M):
        pairs.append((m+1, n-m))
    
    for a, b in pairs:
        print(a, b)

if __name__ == '__main__':
    inputs = read()
    solve(*inputs)

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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

ans = [[0, 0] for _ in range(M)]
for i in range(M):
    ans[i][0] = i+1
for k, j in enumerate(range(i+1, 2*M)):
    ans[-(k+1)][1] = j+1

for l in ans:
    print(*l)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

a = 1
b = 2*m

for i in range(0,m):
    print(str(a) + " " + str(b))
    a = a+1
    b = b-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:
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:
            ans1 -= 1
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,m = inpm()
    ans = []
    if m%2 == 0:
        for i in range(m):
            print(i+1,n-i)
            return
    for i in range(m):
        if i == 0:
            ans.append([1,n])
        elif i == 1:
            ans.append([n//2-1,n//2+1])
        elif i == 2:
            ans.append([n//2,n//2+3])
        elif i == 3:
            ans.append([n//2-2,n//2+2])
        else:
            ans.append([n//2-i+1,n//2+i])
    for i in range(len(ans)):
        print(*ans[i])

    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = list(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())
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-2)

Submission status: Wrong Answer

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

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 / 2 == m:
    1/0
    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, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n, m = MAP()
mx = m * 2 + 1
if n == mx:
    mx += 1
for i in range(1, m + 1):
    print(i, mx - 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 __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )
    
    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], i[1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

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

s = 1
f = n
ans = []
if n % 2 == 0:
    i = 0
    while i < m:
        # print(s, f, i)
        if abs(s - f) == n // 2:
            s += 1
            f -= 1
            continue
        ans.append(f"{s} {f}")
        s += 1
        f -= 1
        i += 1
else:
    for i in range(m):
        ans.append(f"{s} {f}")
        s += 1
        f -= 1
print("\n".join(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=list(map(int,input().split()))

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

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):
        p2+=1
    else:    
        print(p1,p2)
        p1-=1
        p2+=1
        M-=1

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
    if M == 1:
        print(1,N)
        exit()
    for i in range(1,N//2+1):
        if count < M:
            print(i,N//2+1-i)
            count += 1
        if count < M:
            print(i+N//2,N+1-i)
            count += 1

Submission status: Wrong Answer

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

center = N // 2
width = (N//2)//M
start = center
end = center + 1
for i in range(M):
    print(start, end)
    start -= width
    end += width

Submission status: Wrong Answer

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

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:         
        # print(i+1, n-i)
        n -= 1
    print(i+1,n-i)
    i += 1

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
    print(half_l, half_u)
    half_l -= 1
    half_u += 1

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = n // 2
b = a // 2
count = 0
for i in range(b):
    print(i + 1, a - i)
    count += 1
    if count == m:
        break
    else:
        print(i + a + 2, a * 2 - i + 1)
        count += 1
        if count == m:
            break
else:
    if count != m:
        print(b + 1, b + a + 1)

Submission status: Wrong Answer

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


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


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
if 4*M-2 ==N:
	print(1,'',2*M+1)
	for i in range(2,M+1):
		print(i,'',2*M+1-i)
else:
	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())
ans = []
d = N
if N%2 == 1:
    N -= 1
for m in range(M):
    if N%2 == 0 and m+d-(m+1) == N//2:
        d -= 1
    ans.append([m+1,m+d])
    d -= 2
for e in ans:
    print(*e)

Submission status: Wrong Answer

Solution code:
import itertools

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

L = list(range(1,N+1))
L2 = reversed(L)

count = 0
for a,b in zip(L,L2):
  print("{} {}".format(a,b))
  count += 1
  if count == M:
    break

Submission status: Wrong Answer

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

a = N//2
b = a+1

if b-a == N-b + a:
    b += 1

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

Submission status: Wrong Answer

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

    left = 1
    right = M*2+1
    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())
Nlist = []
for i in range(1,N+1):
    Nlist.append(i)
count = 0
for i in range(N):
    count += 1
    if count>M:
        break
    print(Nlist[i],Nlist[-(i+1)])

Submission status: Wrong Answer

Solution code:
inf = 10**15
mod = 10**9+7
n,m = map(int, input().split())
tmp = n//2
for i in range(m):
    if i % 2 == 1:
        print('{} {}'.format(tmp-i//2, tmp+1+i//2))
    else:
        print('{} {}'.format(1+i//2, n-i//2-1))

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

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
    
  if plu>N//2:
    print(d)

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

Submission status: Wrong Answer

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

if N%2 == 1:
    for i in range(1,M+1):
        print(i,N-i+1)
else:
    used = [0]*N
    count = 0
    num = 0
    while count < M:
        if used[num] == 1:
            num += 1
            num %= N
        else:
            print(num+1,(num+1+pow(2,count,N))%N)
            num += 1
            num %= N
            count += 1

Submission status: Wrong Answer

Solution code:
from bisect import *
from collections import *

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

Submission status: Wrong Answer

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


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve(n, m):
    p, q = 1, n
    res = []

    st1 = set()
    st2 = set()
    if n % 2 == 1:
        q -= 1
    for i in xrange(m):
        while True:
            if st1 & set([p, q]):
                q -= 1
                continue

            cur = set([q - p, (p - q + n) % n])
            if st2 & cur:
                q -= 1
                continue

            # print p, q, sorted(cur)
            break
        cur = set([q - p, (p - q + n) % n])

        assert not (st2 & cur)
        assert p not in st1 and q not in st1
        st1 |= set([p, q])
        st2 |= cur
        res.append([p, q])

        p += 1
        q -= 1
    return res

solve(7, 3)
solve(12, 5)

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

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

assert m * 2 + 1 <= n

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

Submission status: Wrong Answer

Solution code:
from sys import stdin


def main():
    input = stdin.readline

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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

a = n // 2
ans = []
if n % 2 == 0:
  for i in range(m):
    ans.append(str(a-i+1) + ' ' + str(a+2+i))
  for i in range(m):
    print(ans[m-1-i])
else:
  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:
a,b=map(int,input().split())
for i in range(b):
    print(str(i+1),str(a-i-1))