n,k=map(int,input().split())
ans=["1 "+str(i) for i in range(2,n+1)]
c=(n-1)*(n-2)//2
if k>c:
	print(-1)
	exit()
for i in range(2,n):
	for j in range(i+1,n+1):
		if c==k:
			break
		ans+=["{} {}".format(i,j)]
		c-=1
	else:
		continue
	break
print(len(ans))
print(*ans,sep="\n") n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k "1 "+str(i) for i in range(2,n+1) for i in range(2,n+1) i range(2,n+1) range 2 n+1 n 1 for i in range(2,n+1) "1 "+str(i) "1 " str(i) str i ans=["1 "+str(i) for i in range(2,n+1)] ans ["1 "+str(i) for i in range(2,n+1)] c=(n-1)*(n-2)//2 c (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 if k>c:
	print(-1)
	exit() k>c k c print(-1) print -1 exit() exit for i in range(2,n):
	for j in range(i+1,n+1):
		if c==k:
			break
		ans+=["{} {}".format(i,j)]
		c-=1
	else:
		continue
	break i range(2,n) range 2 n for j in range(i+1,n+1):
		if c==k:
			break
		ans+=["{} {}".format(i,j)]
		c-=1
	else:
		continue
	 j range(i+1,n+1) range i+1 i 1 n+1 n 1 if c==k:
			break
		 c==k c k break ans+=["{} {}".format(i,j)] ans ["{} {}".format(i,j)] "{} {}".format(i,j) "{} {}".format "{} {}" format i j c-=1 c 1 continue break print(len(ans)) print len(ans) len ans print(*ans,sep="\n") print *ans ans sep="\n" sep "\n" n,k=map(int,input().split()) map(int,input().split()) n ans+=["{} {}".format(i,j)] ["{} {}".format(i,j)] ans c-=1 1 c ans=["1 "+str(i) for i in range(2,n+1)] ["1 "+str(i) for i in range(2,n+1)] ans k=map(int,input().split()) map(int,input().split()) k c=(n-1)*(n-2)//2 (n-1)*(n-2)//2 c
n,k=map(int,input().split())
ans=["1 "+str(i) for i in range(2,n+1)]
c=(n-1)*(n-2)//2
if k>c:
	print(-1)
	exit()
for i in range(2,n):
	for j in range(i+1,n+1):
		if c==k:
			break
		ans+=["{} {}".format(i,j)]
		c-=1
	else:
		continue
	break
print(len(ans))
print(*ans,sep="\n")