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


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

num = (n-1)*(n-2)/2 - k
print(int(n-1+num))
ansl = []
for i in range(1,n):
    print(str(1)+" "+str(i+1))

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


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

num = (n-1)*(n-2)/2 - k
print(int(n-1+num))
ansl = []
for i in range(1,n):
    print(str(1)+" "+str(i+1))

for i in range(1,n):
    for j in range(i+1, n):
        if num > 0:
            print(str(i+1)+" "+str(j+1))
            num -= 1

