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

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

n_add  = (n-1) * (n-2) // 2 - k
print(n_add + n - 1)

for i in range(2, n+1):
    print(1, i)

for i, (v1, v2) in enumerate(combinations(range(2, n+1), 2)):
    if i == n_add:
        break
    print(v1, v2) from itertools import combinations import sys sys n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k if (n-1) * (n-2) // 2 < k:
    print(-1)
    sys.exit() (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(-1) print -1 sys.exit() sys.exit sys exit n_add  = (n-1) * (n-2) // 2 - k n_add (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(n_add + n - 1) print n_add + n - 1 n_add + n n_add n 1 for i in range(2, n+1):
    print(1, i) i range(2, n+1) range 2 n+1 n 1 print(1, i) print 1 i for i, (v1, v2) in enumerate(combinations(range(2, n+1), 2)):
    if i == n_add:
        break
    print(v1, v2) i (v1, v2) v1 v2 enumerate(combinations(range(2, n+1), 2)) enumerate combinations(range(2, n+1), 2) combinations range(2, n+1) range 2 n+1 n 1 2 if i == n_add:
        break
     i == n_add i n_add break print(v1, v2) print v1 v2 n, k = map(int, input().split()) map(int, input().split()) n n_add  = (n-1) * (n-2) // 2 - k (n-1) * (n-2) // 2 - k n_add k = map(int, input().split()) map(int, input().split()) k
from itertools import combinations
import sys
n, k = map(int, input().split())

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

n_add  = (n-1) * (n-2) // 2 - k
print(n_add + n - 1)

for i in range(2, n+1):
    print(1, i)

for i, (v1, v2) in enumerate(combinations(range(2, n+1), 2)):
    if i == n_add:
        break
    print(v1, v2)
