import os, sys, re, math, queue

N,K = list(map(int,input().split(' ')))
ans = []

if (N-1)*(N-2) < 2*K:
	print('-1')
	sys.exit()

for i in range(2,N+1):
	ans.append('1 ' + str(i))

for i in range(2, N):
	for j in range(i+1, N+1):
		ans.append(str(i) + ' ' + str(j))

limit = N - 1 + (N-1)*(N-2)//2 - K
print(limit)
for k in range(limit):
	print(ans[k]) import os, sys, re, math, queue os sys re math queue N,K = list(map(int,input().split(' '))) N list(map(int,input().split(' '))) list map(int,input().split(' ')) map int input().split(' ') ().split () input split ' ' K ans = [] ans [] if (N-1)*(N-2) < 2*K:
	print('-1')
	sys.exit() (N-1)*(N-2) < 2*K (N-1)*(N-2) N-1 N 1 N-2 N 2 2*K 2 K print('-1') print '-1' sys.exit() sys.exit sys exit for i in range(2,N+1):
	ans.append('1 ' + str(i)) i range(2,N+1) range 2 N+1 N 1 ans.append('1 ' + str(i)) ans.append ans append '1 ' + str(i) '1 ' str(i) str i for i in range(2, N):
	for j in range(i+1, N+1):
		ans.append(str(i) + ' ' + str(j)) i range(2, N) range 2 N for j in range(i+1, N+1):
		ans.append(str(i) + ' ' + str(j)) j range(i+1, N+1) range i+1 i 1 N+1 N 1 ans.append(str(i) + ' ' + str(j)) ans.append ans append str(i) + ' ' + str(j) str(i) + ' ' str(i) str i ' ' str(j) str j limit = N - 1 + (N-1)*(N-2)//2 - K limit N - 1 + (N-1)*(N-2)//2 - K N - 1 + (N-1)*(N-2)//2 N - 1 N 1 (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 K print(limit) print limit for k in range(limit):
	print(ans[k]) k range(limit) range limit print(ans[k]) print ans[k] ans k K = list(map(int,input().split(' '))) list(map(int,input().split(' '))) K limit = N - 1 + (N-1)*(N-2)//2 - K N - 1 + (N-1)*(N-2)//2 - K limit ans = [] [] ans N,K = list(map(int,input().split(' '))) list(map(int,input().split(' '))) N
import os, sys, re, math, queue

N,K = list(map(int,input().split(' ')))
ans = []

if (N-1)*(N-2) < 2*K:
	print('-1')
	sys.exit()

for i in range(2,N+1):
	ans.append('1 ' + str(i))

for i in range(2, N):
	for j in range(i+1, N+1):
		ans.append(str(i) + ' ' + str(j))

limit = N - 1 + (N-1)*(N-2)//2 - K
print(limit)
for k in range(limit):
	print(ans[k])
