n,k=map(int,input().split())
ans=set()
for i in range(2,n+1):
    ans.add((1,i))
c=0
import itertools
for x,y in itertools.combinations(list(range(2,n+1)),2):
    if c>=(n-1)*(n-2)//2-k:
        break
    c+=1
    ans.add((x,y))

if (n-1)*(n-2)//2-k<0:
    print(-1)
    exit()
print(len(ans))
for i,j in ans:
    print(i,j) n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k ans=set() ans set() set for i in range(2,n+1):
    ans.add((1,i)) i range(2,n+1) range 2 n+1 n 1 ans.add((1,i)) ans.add ans add (1,i) 1 i c=0 c 0 import itertools itertools for x,y in itertools.combinations(list(range(2,n+1)),2):
    if c>=(n-1)*(n-2)//2-k:
        break
    c+=1
    ans.add((x,y)) x y itertools.combinations(list(range(2,n+1)),2) itertools.combinations itertools combinations list(range(2,n+1)) list range(2,n+1) range 2 n+1 n 1 2 if c>=(n-1)*(n-2)//2-k:
        break
     c>=(n-1)*(n-2)//2-k c (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 break c+=1 c 1 ans.add((x,y)) ans.add ans add (x,y) x y if (n-1)*(n-2)//2-k<0:
    print(-1)
    exit() (n-1)*(n-2)//2-k<0 (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 0 print(-1) print -1 exit() exit print(len(ans)) print len(ans) len ans for i,j in ans:
    print(i,j) i j ans print(i,j) print i j c+=1 1 c ans=set() set() ans c=0 0 c n,k=map(int,input().split()) map(int,input().split()) n k=map(int,input().split()) map(int,input().split()) k
n,k=map(int,input().split())
ans=set()
for i in range(2,n+1):
    ans.add((1,i))
c=0
import itertools
for x,y in itertools.combinations(list(range(2,n+1)),2):
    if c>=(n-1)*(n-2)//2-k:
        break
    c+=1
    ans.add((x,y))

if (n-1)*(n-2)//2-k<0:
    print(-1)
    exit()
print(len(ans))
for i,j in ans:
    print(i,j)
