from itertools import combinations

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

border = (n - 1) * (n - 2) // 2

if k > border:
  print(-1)
else:
  print(n - 1 + border - k)
  for i in range(2, n + 1):
    print(1, i)
  comb = list(combinations([i for i in range(2, n + 1)], 2))
  for i, j in comb[:border - k]:
    print(i, j) from itertools import combinations n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k border = (n - 1) * (n - 2) // 2 border (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 if k > border:
  print(-1)
else:
  print(n - 1 + border - k)
  for i in range(2, n + 1):
    print(1, i)
  comb = list(combinations([i for i in range(2, n + 1)], 2))
  for i, j in comb[:border - k]:
    print(i, j) k > border k border print(-1) print -1 print(n - 1 + border - k) print n - 1 + border - k n - 1 + border n - 1 n 1 border k 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 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) i comb = list(combinations([i for i in range(2, n + 1)], 2)) comb list(combinations([i for i in range(2, n + 1)], 2)) list combinations([i for i in range(2, n + 1)], 2) combinations [i for i in range(2, n + 1)] 2 for i, j in comb[:border - k]:
    print(i, j) i j comb[:border - k] comb :border - k border - k border k print(i, j) print i j n, k = map(int, input().split()) map(int, input().split()) n k = map(int, input().split()) map(int, input().split()) k comb = list(combinations([i for i in range(2, n + 1)], 2)) list(combinations([i for i in range(2, n + 1)], 2)) comb border = (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) // 2 border
from itertools import combinations

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

border = (n - 1) * (n - 2) // 2

if k > border:
  print(-1)
else:
  print(n - 1 + border - k)
  for i in range(2, n + 1):
    print(1, i)
  comb = list(combinations([i for i in range(2, n + 1)], 2))
  for i, j in comb[:border - k]:
    print(i, j)