Buggy python submission (verdict: Time Limit Exceeded):
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

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

else:
    #lst=set([i for i in range(1,N//2+1)])
    visited=set()
    c=1
    z=1
    while M:
        if c>N:
            c=1
        if c in visited:
            c+=1
            continue
        else:
            Z=c+z
            if Z>N:
                Z-=N
            if Z in visited:
                c+=1
                continue
            else:
                print(c,Z)
                visited.add(c)
                visited.add(c+z)
                c+=1
                z+=1
                M-=1


Fixed submission:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

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

else:

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

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

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

else:
    #lst=set([i for i in range(1,N//2+1)])
    visited=set()
    c=1
    z=1
    while M:
        if c>N:
            c=1
        if c in visited:
            c+=1
            continue
        else:
            Z=c+z
            if Z>N:
                Z-=N
            if Z in visited:
                c+=1
                continue
            else:
                print(c,Z)
                visited.add(c)
                visited.add(c+z)
                c+=1
                z+=1
                M-=1


Fixed submission:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

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

else:

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

Buggy python submission (verdict: Runtime Error):
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

if not N%2:
    print(unko)


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


Fixed submission:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

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

else:

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

Buggy python submission (verdict: Runtime Error):
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

if N%2:
    print(unko)


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


Fixed submission:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

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

else:

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