from itertools import combinations

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

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

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

if k > (n - 1) * (n - 2) // 2:
  print(-1)
else:
  print(n - 1 + (n - 1) * (n - 2) // 2 - 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[:(n - 1) * (n - 2) // 2 - k]:
    print(i, j)