from itertools import combinations
n, k = map(int, input().split())
nc2 = (n - 1) * (n - 2) // 2
if nc2 < k:
  print('-1')
  exit()
print(n - 1 + (nc2 - k))  # M
for i in range(2, n+1):
  print(f'1 {i}')
for i in range(nc2 - k):
  combs = list(combinations(range(2, n+1), 2))
  print(f'{combs[i][0]} {combs[i][1]}') from itertools import combinations n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k nc2 = (n - 1) * (n - 2) // 2 nc2 (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 if nc2 < k:
  print('-1')
  exit() nc2 < k nc2 k print('-1') print '-1' exit() exit print(n - 1 + (nc2 - k)) print n - 1 + (nc2 - k) n - 1 n 1 nc2 - k nc2 k for i in range(2, n+1):
  print(f'1 {i}') i range(2, n+1) range 2 n+1 n 1 print(f'1 {i}') print f'1 {i}' for i in range(nc2 - k):
  combs = list(combinations(range(2, n+1), 2))
  print(f'{combs[i][0]} {combs[i][1]}') i range(nc2 - k) range nc2 - k nc2 k combs = list(combinations(range(2, n+1), 2)) combs list(combinations(range(2, n+1), 2)) list combinations(range(2, n+1), 2) combinations range(2, n+1) range 2 n+1 n 1 2 print(f'{combs[i][0]} {combs[i][1]}') print f'{combs[i][0]} {combs[i][1]}' k = map(int, input().split()) map(int, input().split()) k combs = list(combinations(range(2, n+1), 2)) list(combinations(range(2, n+1), 2)) combs nc2 = (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) // 2 nc2 n, k = map(int, input().split()) map(int, input().split()) n
from itertools import combinations
n, k = map(int, input().split())
nc2 = (n - 1) * (n - 2) // 2
if nc2 < k:
  print('-1')
  exit()
print(n - 1 + (nc2 - k))  # M
for i in range(2, n+1):
  print(f'1 {i}')
for i in range(nc2 - k):
  combs = list(combinations(range(2, n+1), 2))
  print(f'{combs[i][0]} {combs[i][1]}')
