Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = [0 for _ in range(N)]
if N % 2 == 0:
    l, r = 0, 1
    for i in range(M):
        X[l] = 1
        X[r] = 1
        print(l+1, r+1)
        if i < M - 1:
            while X[l] != 0 or X[(l+i+2)%N] != 0:
                l += 1
            r = (l + i + 2) % N
else:
    for i in range(M):
        print(N-i-1, i+1)

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

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = [0 for _ in range(N)]
if N % 2 == 0:
    l, r = 0, 1
    for i in range(M):
        X[l] = 1
        X[r] = 1
        print(l+1, r+1)
        if i < M - 1:
            while X[l] != 0 or X[(l+i+2)%N]:
                l += 1
            r = (l + i + 2) % N
else:
    for i in range(M):
        print(N-i-1, i+1)

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

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = [0 for _ in range(N)]
if N % 2 == 0:
    l, r = 0, 1
    for i in range(M):
        X[l] = 1
        X[r] = 1
        print(l+1, r+1)
        while X[l] != 0 or X[(l+i+2)%N]:
            l += 1
        r = (l + i + 2) % N
else:
    for i in range(M):
        print(N-i-1, i+1)


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

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = [0 for _ in range(N)]
if N % 2 == 0:
    l, r = 1, 2
    for i in range(M):
        X[l-1] = 1
        X[r-1] = 1
        print(l, r)
        while X[l-1] != 0:
            l += 1
        r = l + i + 2
else:
    for i in range(M):
        print(N-i-1, i+1)

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