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

remain = (n-1)*(n-2)//2 - k
if remain < 0:
    print(-1)
    exit()

m = n-1 + remain
print(m)
for i in range(1, n):
    print(1, i+1)

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

remain = (n-1)*(n-2)//2 - k
if remain < 0:
    print(-1)
    exit()

m = n-1 + remain
print(m)
for i in range(1, n):
    print(1, i+1)

for i in range(1, n):
    for j in range(i+1, n):
        if remain > 0:
            print(i+1, j+1)
            remain -= 1
        else:
            exit()