import itertools
from sys import exit

N, K = map(int, input().split())
max_edge = (N - 1) * (N - 2) // 2
if K > max_edge:
    print(-1)
    exit()

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

cnt = max_edge
it = itertools.combinations(range(1, N), 2)
while cnt > K:
    print(*next(it))
    cnt -= 1 import itertools itertools from sys import exit N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K max_edge = (N - 1) * (N - 2) // 2 max_edge (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 if K > max_edge:
    print(-1)
    exit() K > max_edge K max_edge print(-1) print -1 exit() exit print(N - 1 + max_edge - K) print N - 1 + max_edge - K N - 1 + max_edge N - 1 N 1 max_edge K for i in range(1, N):
    print(i, N) i range(1, N) range 1 N print(i, N) print i N cnt = max_edge cnt max_edge it = itertools.combinations(range(1, N), 2) it itertools.combinations(range(1, N), 2) itertools.combinations itertools combinations range(1, N) range 1 N 2 while cnt > K:
    print(*next(it))
    cnt -= 1 cnt > K cnt K print(*next(it)) print *next(it) next(it) next it cnt -= 1 cnt 1 max_edge = (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) // 2 max_edge cnt -= 1 1 cnt N, K = map(int, input().split()) map(int, input().split()) N K = map(int, input().split()) map(int, input().split()) K cnt = max_edge max_edge cnt it = itertools.combinations(range(1, N), 2) itertools.combinations(range(1, N), 2) it
import itertools
from sys import exit

N, K = map(int, input().split())
max_edge = (N - 1) * (N - 2) // 2
if K > max_edge:
    print(-1)
    exit()

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

cnt = max_edge
it = itertools.combinations(range(1, N), 2)
while cnt > K:
    print(*next(it))
    cnt -= 1
