import sys

n, k = list(map(int, input().split()))

if k > (n - 1) * (n - 2) // 2:
	print(-1)
else:
	rest = (n - 1) * (n - 2) // 2 - k
	print((n - 1) + rest)
	for i in range(2, n + 1):
		print("1 " + str(i))

	for i in range(2, n + 1):
		for j in range(i + 1, n + 1):
			if rest == 0:
				sys.exit()
			print(str(i) + " " + str(j))
			rest -= 1 import sys sys 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 if k > (n - 1) * (n - 2) // 2:
	print(-1)
else:
	rest = (n - 1) * (n - 2) // 2 - k
	print((n - 1) + rest)
	for i in range(2, n + 1):
		print("1 " + str(i))

	for i in range(2, n + 1):
		for j in range(i + 1, n + 1):
			if rest == 0:
				sys.exit()
			print(str(i) + " " + str(j))
			rest -= 1 k > (n - 1) * (n - 2) // 2 k (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 print(-1) print -1 rest = (n - 1) * (n - 2) // 2 - k rest (n - 1) * (n - 2) // 2 - k (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 k print((n - 1) + rest) print (n - 1) + rest n - 1 n 1 rest for i in range(2, n + 1):
		print("1 " + str(i))

	 i range(2, n + 1) range 2 n + 1 n 1 print("1 " + str(i)) print "1 " + str(i) "1 " str(i) str i for i in range(2, n + 1):
		for j in range(i + 1, n + 1):
			if rest == 0:
				sys.exit()
			print(str(i) + " " + str(j))
			rest -= 1 i range(2, n + 1) range 2 n + 1 n 1 for j in range(i + 1, n + 1):
			if rest == 0:
				sys.exit()
			print(str(i) + " " + str(j))
			rest -= 1 j range(i + 1, n + 1) range i + 1 i 1 n + 1 n 1 if rest == 0:
				sys.exit()
			 rest == 0 rest 0 sys.exit() sys.exit sys exit print(str(i) + " " + str(j)) print str(i) + " " + str(j) str(i) + " " str(i) str i " " str(j) str j rest -= 1 rest 1 k = list(map(int, input().split())) list(map(int, input().split())) k rest -= 1 1 rest n, k = list(map(int, input().split())) list(map(int, input().split())) n rest = (n - 1) * (n - 2) // 2 - k (n - 1) * (n - 2) // 2 - k rest
import sys

n, k = list(map(int, input().split()))

if k > (n - 1) * (n - 2) // 2:
	print(-1)
else:
	rest = (n - 1) * (n - 2) // 2 - k
	print((n - 1) + rest)
	for i in range(2, n + 1):
		print("1 " + str(i))

	for i in range(2, n + 1):
		for j in range(i + 1, n + 1):
			if rest == 0:
				sys.exit()
			print(str(i) + " " + str(j))
			rest -= 1
