N,K=[int(x) for x in input().split()]
if K>(N-2)*(1+N-2)//2:
	print(-1)
else:
	print(((N-2)*(1+N-2)//2)+((N-1)-K))
	counter=0
	for i in range(2,N+1):
		print(1,i)
		counter+=1
	for i in range(2,N+1):
		for j in range(i+1,N+1):
			if counter==((N-2)*(1+N-2)//2)+((N-1)-K):
				exit()
			else:
				print(i,j)
				counter+=1 int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x N,K=[int(x) for x in input().split()] N [int(x) for x in input().split()] K if K>(N-2)*(1+N-2)//2:
	print(-1)
else:
	print(((N-2)*(1+N-2)//2)+((N-1)-K))
	counter=0
	for i in range(2,N+1):
		print(1,i)
		counter+=1
	for i in range(2,N+1):
		for j in range(i+1,N+1):
			if counter==((N-2)*(1+N-2)//2)+((N-1)-K):
				exit()
			else:
				print(i,j)
				counter+=1 K>(N-2)*(1+N-2)//2 K (N-2)*(1+N-2)//2 (N-2)*(1+N-2) N-2 N 2 1+N-2 1+N 1 N 2 2 print(-1) print -1 print(((N-2)*(1+N-2)//2)+((N-1)-K)) print ((N-2)*(1+N-2)//2)+((N-1)-K) (N-2)*(1+N-2)//2 (N-2)*(1+N-2) N-2 N 2 1+N-2 1+N 1 N 2 2 (N-1)-K N-1 N 1 K counter=0 counter 0 for i in range(2,N+1):
		print(1,i)
		counter+=1
	 i range(2,N+1) range 2 N+1 N 1 print(1,i) print 1 i counter+=1 counter 1 for i in range(2,N+1):
		for j in range(i+1,N+1):
			if counter==((N-2)*(1+N-2)//2)+((N-1)-K):
				exit()
			else:
				print(i,j)
				counter+=1 i range(2,N+1) range 2 N+1 N 1 for j in range(i+1,N+1):
			if counter==((N-2)*(1+N-2)//2)+((N-1)-K):
				exit()
			else:
				print(i,j)
				counter+=1 j range(i+1,N+1) range i+1 i 1 N+1 N 1 if counter==((N-2)*(1+N-2)//2)+((N-1)-K):
				exit()
			else:
				print(i,j)
				counter+=1 counter==((N-2)*(1+N-2)//2)+((N-1)-K) counter ((N-2)*(1+N-2)//2)+((N-1)-K) (N-2)*(1+N-2)//2 (N-2)*(1+N-2) N-2 N 2 1+N-2 1+N 1 N 2 2 (N-1)-K N-1 N 1 K exit() exit print(i,j) print i j counter+=1 counter 1 counter+=1 1 counter N,K=[int(x) for x in input().split()] [int(x) for x in input().split()] N counter+=1 1 counter K=[int(x) for x in input().split()] [int(x) for x in input().split()] K counter=0 0 counter
N,K=[int(x) for x in input().split()]
if K>(N-2)*(1+N-2)//2:
	print(-1)
else:
	print(((N-2)*(1+N-2)//2)+((N-1)-K))
	counter=0
	for i in range(2,N+1):
		print(1,i)
		counter+=1
	for i in range(2,N+1):
		for j in range(i+1,N+1):
			if counter==((N-2)*(1+N-2)//2)+((N-1)-K):
				exit()
			else:
				print(i,j)
				counter+=1