N, K = map(int, input().split())
if K > (N - 1) * (N - 2) // 2:
  print(-1)
else:
  M = N * (N - 1) // 2 - K
  print(M)
  for i in range(2, N + 1):
    print(1, i)
  M -= N - 1
  for i in range(2, N + 1):
    for j in range(i + 1, N + 1):
      if M == 0:
        break
      print(i, j)
      M -= 1
    if M == 0:
      break 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:
  M = N * (N - 1) // 2 - K
  print(M)
  for i in range(2, N + 1):
    print(1, i)
  M -= N - 1
  for i in range(2, N + 1):
    for j in range(i + 1, N + 1):
      if M == 0:
        break
      print(i, j)
      M -= 1
    if M == 0:
      break 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 M = N * (N - 1) // 2 - K M N * (N - 1) // 2 - K N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 K print(M) print M 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 M -= N - 1 M N - 1 N 1 for i in range(2, N + 1):
    for j in range(i + 1, N + 1):
      if M == 0:
        break
      print(i, j)
      M -= 1
    if M == 0:
      break i range(2, N + 1) range 2 N + 1 N 1 for j in range(i + 1, N + 1):
      if M == 0:
        break
      print(i, j)
      M -= 1
     j range(i + 1, N + 1) range i + 1 i 1 N + 1 N 1 if M == 0:
        break
       M == 0 M 0 break print(i, j) print i j M -= 1 M 1 if M == 0:
      break M == 0 M 0 break N, K = map(int, input().split()) map(int, input().split()) N M -= N - 1 N - 1 M K = map(int, input().split()) map(int, input().split()) K M = N * (N - 1) // 2 - K N * (N - 1) // 2 - K M M -= 1 1 M
N, K = map(int, input().split())
if K > (N - 1) * (N - 2) // 2:
  print(-1)
else:
  M = N * (N - 1) // 2 - K
  print(M)
  for i in range(2, N + 1):
    print(1, i)
  M -= N - 1
  for i in range(2, N + 1):
    for j in range(i + 1, N + 1):
      if M == 0:
        break
      print(i, j)
      M -= 1
    if M == 0:
      break