from itertools import combinations

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

if k > (n - 1) * (n - 2) // 2:
  print(-1)
else:
  print(n * (n - 1) // 2 - k)
  for i in range(1, n):
    print(i, n)
  edge = combinations(range(1, n), 2)
  for _ in range((n - 1) * (n - 2) // 2 - k):
    u, v = next(edge)
    print(u, v) from itertools import combinations 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)
else:
  print(n * (n - 1) // 2 - k)
  for i in range(1, n):
    print(i, n)
  edge = combinations(range(1, n), 2)
  for _ in range((n - 1) * (n - 2) // 2 - k):
    u, v = next(edge)
    print(u, v) 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 print(n * (n - 1) // 2 - k) print n * (n - 1) // 2 - k n * (n - 1) // 2 n * (n - 1) n n - 1 n 1 2 k for i in range(1, n):
    print(i, n)
   i range(1, n) range 1 n print(i, n) print i n edge = combinations(range(1, n), 2) edge combinations(range(1, n), 2) combinations range(1, n) range 1 n 2 for _ in range((n - 1) * (n - 2) // 2 - k):
    u, v = next(edge)
    print(u, v) _ range((n - 1) * (n - 2) // 2 - k) range (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 u, v = next(edge) u next(edge) next edge v print(u, v) print u v u, v = next(edge) next(edge) u edge = combinations(range(1, n), 2) combinations(range(1, n), 2) edge n, k = map(int, input().split()) map(int, input().split()) n k = map(int, input().split()) map(int, input().split()) k v = next(edge) next(edge) v
from itertools import combinations

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

if k > (n - 1) * (n - 2) // 2:
  print(-1)
else:
  print(n * (n - 1) // 2 - k)
  for i in range(1, n):
    print(i, n)
  edge = combinations(range(1, n), 2)
  for _ in range((n - 1) * (n - 2) // 2 - k):
    u, v = next(edge)
    print(u, v)