import sys

n, k = map(int, sys.stdin.readline().split())

def main():
  m = n - 1
  cnt = (n - 1) * (n - 2) // 2
  if k > cnt: print(-1); return
  edges = [(1, v) for v in range(2, n + 1)]

  for u in range(2, n):
    for v in range(u + 1, n + 1):
      if cnt == k: break
      edges.append((u, v))
      m += 1
      cnt -= 1

  print(m)
  for u, v in edges:
    print(u, v)

if __name__ == '__main__':
  main() import sys sys n, k = map(int, sys.stdin.readline().split()) n map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split k def main():
  m = n - 1
  cnt = (n - 1) * (n - 2) // 2
  if k > cnt: print(-1); return
  edges = [(1, v) for v in range(2, n + 1)]

  for u in range(2, n):
    for v in range(u + 1, n + 1):
      if cnt == k: break
      edges.append((u, v))
      m += 1
      cnt -= 1

  print(m)
  for u, v in edges:
    print(u, v) main m = n - 1 m n - 1 n 1 cnt = (n - 1) * (n - 2) // 2 cnt (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 if k > cnt: print(-1); return
   k > cnt k cnt (1, v) for v in range(2, n + 1) for v in range(2, n + 1) v range(2, n + 1) range 2 n + 1 n 1 for v in range(2, n + 1) (1, v) 1 v edges = [(1, v) for v in range(2, n + 1)] edges [(1, v) for v in range(2, n + 1)] for u in range(2, n):
    for v in range(u + 1, n + 1):
      if cnt == k: break
      edges.append((u, v))
      m += 1
      cnt -= 1

   u range(2, n) range 2 n for v in range(u + 1, n + 1):
      if cnt == k: break
      edges.append((u, v))
      m += 1
      cnt -= 1

   v range(u + 1, n + 1) range u + 1 u 1 n + 1 n 1 if cnt == k: break
       cnt == k cnt k edges.append((u, v)) edges.append edges append (u, v) u v m += 1 m 1 cnt -= 1 cnt 1 print(m) print m for u, v in edges:
    print(u, v) u v edges print(u, v) print u v if __name__ == '__main__':
  main() __name__ == '__main__' __name__ '__main__' main() main k = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) k n, k = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) n def main():
  m = n - 1
  cnt = (n - 1) * (n - 2) // 2
  if k > cnt: print(-1); return
  edges = [(1, v) for v in range(2, n + 1)]

  for u in range(2, n):
    for v in range(u + 1, n + 1):
      if cnt == k: break
      edges.append((u, v))
      m += 1
      cnt -= 1

  print(m)
  for u, v in edges:
    print(u, v) def main():
  m = n - 1
  cnt = (n - 1) * (n - 2) // 2
  if k > cnt: print(-1); return
  edges = [(1, v) for v in range(2, n + 1)]

  for u in range(2, n):
    for v in range(u + 1, n + 1):
      if cnt == k: break
      edges.append((u, v))
      m += 1
      cnt -= 1

  print(m)
  for u, v in edges:
    print(u, v) main
import sys

n, k = map(int, sys.stdin.readline().split())

def main():
  m = n - 1
  cnt = (n - 1) * (n - 2) // 2
  if k > cnt: print(-1); return
  edges = [(1, v) for v in range(2, n + 1)]

  for u in range(2, n):
    for v in range(u + 1, n + 1):
      if cnt == k: break
      edges.append((u, v))
      m += 1
      cnt -= 1

  print(m)
  for u, v in edges:
    print(u, v)

if __name__ == '__main__':
  main()