n,k=map(int,input().split())

if k>(n-1)*(n-2)//2:
    print(-1)
    exit()

ansl=[(1,i) for i in range(2,n+1)]
now=[]
for i in range(2,n+1):
    for j in range(i+1,n+1):
        now.append((i,j))

ansl+=now[:(n-1)*(n-2)//2-k]
print(len(ansl))
for i,j in ansl:
    print(i,j) n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k if k>(n-1)*(n-2)//2:
    print(-1)
    exit() k>(n-1)*(n-2)//2 k (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 print(-1) print -1 exit() exit (1,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,i) 1 i ansl=[(1,i) for i in range(2,n+1)] ansl [(1,i) for i in range(2,n+1)] now=[] now [] for i in range(2,n+1):
    for j in range(i+1,n+1):
        now.append((i,j)) i range(2,n+1) range 2 n+1 n 1 for j in range(i+1,n+1):
        now.append((i,j)) j range(i+1,n+1) range i+1 i 1 n+1 n 1 now.append((i,j)) now.append now append (i,j) i j ansl+=now[:(n-1)*(n-2)//2-k] ansl now[:(n-1)*(n-2)//2-k] now :(n-1)*(n-2)//2-k (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 print(len(ansl)) print len(ansl) len ansl for i,j in ansl:
    print(i,j) i j ansl print(i,j) print i j ansl=[(1,i) for i in range(2,n+1)] [(1,i) for i in range(2,n+1)] ansl k=map(int,input().split()) map(int,input().split()) k n,k=map(int,input().split()) map(int,input().split()) n now=[] [] now ansl+=now[:(n-1)*(n-2)//2-k] now[:(n-1)*(n-2)//2-k] ansl
n,k=map(int,input().split())

if k>(n-1)*(n-2)//2:
    print(-1)
    exit()

ansl=[(1,i) for i in range(2,n+1)]
now=[]
for i in range(2,n+1):
    for j in range(i+1,n+1):
        now.append((i,j))

ansl+=now[:(n-1)*(n-2)//2-k]
print(len(ansl))
for i,j in ansl:
    print(i,j)
