n,k=map(int,input().split())
if k>(n-2)*(n-1)//2:
	print(-1)
	exit()
elif k==(n-2)*(n-1)//2:
	print(n-1)
	for i in range(n-1):
		print(1,i+2)
	exit()
ans=[]
for i in range(n-1):
	ans.append((1,i+2))
cnt=(n-2)*(n-1)//2
a=2
b=3
while cnt>k:
	cnt-=1
	ans.append((a,b))
	b+=1
	if b==n+1:
		b=a+2
		a+=1
print(len(ans))
for x in ans:
	print(*x) n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k if k>(n-2)*(n-1)//2:
	print(-1)
	exit()
elif k==(n-2)*(n-1)//2:
	print(n-1)
	for i in range(n-1):
		print(1,i+2)
	exit() k>(n-2)*(n-1)//2 k (n-2)*(n-1)//2 (n-2)*(n-1) n-2 n 2 n-1 n 1 2 print(-1) print -1 exit() exit elif k==(n-2)*(n-1)//2:
	print(n-1)
	for i in range(n-1):
		print(1,i+2)
	exit() k==(n-2)*(n-1)//2 k (n-2)*(n-1)//2 (n-2)*(n-1) n-2 n 2 n-1 n 1 2 print(n-1) print n-1 n 1 for i in range(n-1):
		print(1,i+2)
	 i range(n-1) range n-1 n 1 print(1,i+2) print 1 i+2 i 2 exit() exit ans=[] ans [] for i in range(n-1):
	ans.append((1,i+2)) i range(n-1) range n-1 n 1 ans.append((1,i+2)) ans.append ans append (1,i+2) 1 i+2 i 2 cnt=(n-2)*(n-1)//2 cnt (n-2)*(n-1)//2 (n-2)*(n-1) n-2 n 2 n-1 n 1 2 a=2 a 2 b=3 b 3 while cnt>k:
	cnt-=1
	ans.append((a,b))
	b+=1
	if b==n+1:
		b=a+2
		a+=1 cnt>k cnt k cnt-=1 cnt 1 ans.append((a,b)) ans.append ans append (a,b) a b b+=1 b 1 if b==n+1:
		b=a+2
		a+=1 b==n+1 b n+1 n 1 b=a+2 b a+2 a 2 a+=1 a 1 print(len(ans)) print len(ans) len ans for x in ans:
	print(*x) x ans print(*x) print *x x a=2 2 a n,k=map(int,input().split()) map(int,input().split()) n b=3 3 b k=map(int,input().split()) map(int,input().split()) k cnt-=1 1 cnt b+=1 1 b a+=1 1 a ans=[] [] ans b=a+2 a+2 b cnt=(n-2)*(n-1)//2 (n-2)*(n-1)//2 cnt
n,k=map(int,input().split())
if k>(n-2)*(n-1)//2:
	print(-1)
	exit()
elif k==(n-2)*(n-1)//2:
	print(n-1)
	for i in range(n-1):
		print(1,i+2)
	exit()
ans=[]
for i in range(n-1):
	ans.append((1,i+2))
cnt=(n-2)*(n-1)//2
a=2
b=3
while cnt>k:
	cnt-=1
	ans.append((a,b))
	b+=1
	if b==n+1:
		b=a+2
		a+=1
print(len(ans))
for x in ans:
	print(*x)