Buggy python submission (verdict: Runtime Error):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
x = combinations_count(N-1, 2)
if x < K:
    print('-1')
    quit()

h = []
for i in range(2,N+1):
    h.append(('1', str(i)))

hen = x-K
x = 2
y = 3
while hen > 0:
    h.append((x,y))
    y += 1
    if y > N:
        x += 1
        y = x+1
    hen -= 1

print(len(h))
for x,y in h:
    print(x,y)

Fixed submission:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
if N > 2:
    x = combinations_count(N-1, 2)
else:
    x = 0
if x < K:
    print('-1')
    quit()

h = []
for i in range(2,N+1):
    h.append(('1', str(i)))

hen = x-K
x = 2
y = 3
while hen > 0:
    h.append((x,y))
    y += 1
    if y > N:
        x += 1
        y = x+1
    hen -= 1

print(len(h))
for x,y in h:
    print(x,y)

Buggy python submission (verdict: Runtime Error):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
x = combinations_count(N-1, 2)
if x < K:
    print('-1')
    quit()

for i in range(2,N+1):
    print('1', str(i))

hen = x-K
x = 2
y = 3
while hen > 0:
    print(x,y)
    y += 1
    if y > N:
        x += 1
        y = x+1
    hen -= 1

Fixed submission:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
if N > 2:
    x = combinations_count(N-1, 2)
else:
    x = 0
if x < K:
    print('-1')
    quit()

h = []
for i in range(2,N+1):
    h.append(('1', str(i)))

hen = x-K
x = 2
y = 3
while hen > 0:
    h.append((x,y))
    y += 1
    if y > N:
        x += 1
        y = x+1
    hen -= 1

print(len(h))
for x,y in h:
    print(x,y)

Buggy python submission (verdict: Runtime Error):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
x = combinations_count(N-1, 2)
if K < N-1 and x < K:
    print('-1')
    quit()

for i in range(2,N+1):
    print('1', str(i))

hen = x-K
x = 2
y = 3
while hen > 0:
    print(x,y)
    y += 1
    if y > N:
        x += 1
        y = x+1
    hen -= 1

Fixed submission:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
if N > 2:
    x = combinations_count(N-1, 2)
else:
    x = 0
if x < K:
    print('-1')
    quit()

h = []
for i in range(2,N+1):
    h.append(('1', str(i)))

hen = x-K
x = 2
y = 3
while hen > 0:
    h.append((x,y))
    y += 1
    if y > N:
        x += 1
        y = x+1
    hen -= 1

print(len(h))
for x,y in h:
    print(x,y)

Buggy python submission (verdict: Runtime Error):
import itertools
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
x = combinations_count(N-1, 2)
if N-1 < K or K < x:
    print('-1')
    quit()

for i in range(2,N+1):
    print('1', str(i))

hen = x-K
x = 2
y = 3
while hen > 0:
    print(x,y)
    y += 1
    if y > N:
        x += 1
        y = x+1
    hen -= 1

Fixed submission:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
if N > 2:
    x = combinations_count(N-1, 2)
else:
    x = 0
if x < K:
    print('-1')
    quit()

h = []
for i in range(2,N+1):
    h.append(('1', str(i)))

hen = x-K
x = 2
y = 3
while hen > 0:
    h.append((x,y))
    y += 1
    if y > N:
        x += 1
        y = x+1
    hen -= 1

print(len(h))
for x,y in h:
    print(x,y)

Buggy python submission (verdict: Runtime Error):
import itertools
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N, K = map(int, input().split())
x = combinations_count(N-1, 2)
if N-1 < K < combinations_count(N-1, 2):
    print('-1')
    quit()

for i in range(2,N+1):
    print('1', str(i))

for i in range(2,x-K,2):
    print(str(i), str(i+1))

Fixed submission:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
if N > 2:
    x = combinations_count(N-1, 2)
else:
    x = 0
if x < K:
    print('-1')
    quit()

h = []
for i in range(2,N+1):
    h.append(('1', str(i)))

hen = x-K
x = 2
y = 3
while hen > 0:
    h.append((x,y))
    y += 1
    if y > N:
        x += 1
        y = x+1
    hen -= 1

print(len(h))
for x,y in h:
    print(x,y)

Buggy python submission (verdict: Runtime Error):
import itertools
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N, K = map(int, input())
x = combinations_count(N-1, 2)
if N-1 < K < combinations_count(N-1, 2):
    print('-1')
    quit()

for i in range(2,N+1):
    print('1', str(i))

for i in range(2,x-K,2):
    print(str(i), str(i+1))

Fixed submission:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
if N > 2:
    x = combinations_count(N-1, 2)
else:
    x = 0
if x < K:
    print('-1')
    quit()

h = []
for i in range(2,N+1):
    h.append(('1', str(i)))

hen = x-K
x = 2
y = 3
while hen > 0:
    h.append((x,y))
    y += 1
    if y > N:
        x += 1
        y = x+1
    hen -= 1

print(len(h))
for x,y in h:
    print(x,y)