n,k = map(int,input().split())
x = (n-1)*(n-2)//2-k
if x < 0:
    print(-1)
    exit()
print(n*(n-1)//2-k)
for i in range(2,n+1): print(1,i)
cnt = 0
for i in range(2,n+1):
    for j in range(i+1,n+1):
        if cnt == x: exit()
        print(i,j)
        cnt += 1 n,k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k x = (n-1)*(n-2)//2-k x (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 if x < 0:
    print(-1)
    exit() x < 0 x 0 print(-1) print -1 exit() exit print(n*(n-1)//2-k) print n*(n-1)//2-k n*(n-1)//2 n*(n-1) n n-1 n 1 2 k for i in range(2,n+1): print(1,i) i range(2,n+1) range 2 n+1 n 1 cnt = 0 cnt 0 for i in range(2,n+1):
    for j in range(i+1,n+1):
        if cnt == x: exit()
        print(i,j)
        cnt += 1 i range(2,n+1) range 2 n+1 n 1 for j in range(i+1,n+1):
        if cnt == x: exit()
        print(i,j)
        cnt += 1 j range(i+1,n+1) range i+1 i 1 n+1 n 1 if cnt == x: exit()
         cnt == x cnt x print(i,j) print i j cnt += 1 cnt 1 k = map(int,input().split()) map(int,input().split()) k cnt += 1 1 cnt x = (n-1)*(n-2)//2-k (n-1)*(n-2)//2-k x n,k = map(int,input().split()) map(int,input().split()) n cnt = 0 0 cnt
n,k = map(int,input().split())
x = (n-1)*(n-2)//2-k
if x < 0:
    print(-1)
    exit()
print(n*(n-1)//2-k)
for i in range(2,n+1): print(1,i)
cnt = 0
for i in range(2,n+1):
    for j in range(i+1,n+1):
        if cnt == x: exit()
        print(i,j)
        cnt += 1