N, K = map(int, input().split())
mx = (N-1)*(N-2)/2
if mx < K:
  print(-1)
  exit()
pair = []
for i in range(N-1):
  pair += [[i+1, N]]
add = mx - K
edge = []
for i in range(N-1):
  for j in range(i):
    edge += [[i+1, j+1]]

for i in range(int(add)):
  pair += [edge[i]]

print(len(pair))
for i, j in pair:
  print(i, j) N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K mx = (N-1)*(N-2)/2 mx (N-1)*(N-2)/2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 if mx < K:
  print(-1)
  exit() mx < K mx K print(-1) print -1 exit() exit pair = [] pair [] for i in range(N-1):
  pair += [[i+1, N]] i range(N-1) range N-1 N 1 pair += [[i+1, N]] pair [[i+1, N]] [i+1, N] i+1 i 1 N add = mx - K add mx - K mx K edge = [] edge [] for i in range(N-1):
  for j in range(i):
    edge += [[i+1, j+1]] i range(N-1) range N-1 N 1 for j in range(i):
    edge += [[i+1, j+1]] j range(i) range i edge += [[i+1, j+1]] edge [[i+1, j+1]] [i+1, j+1] i+1 i 1 j+1 j 1 for i in range(int(add)):
  pair += [edge[i]] i range(int(add)) range int(add) int add pair += [edge[i]] pair [edge[i]] edge[i] edge i print(len(pair)) print len(pair) len pair for i, j in pair:
  print(i, j) i j pair print(i, j) print i j N, K = map(int, input().split()) map(int, input().split()) N pair = [] [] pair edge = [] [] edge add = mx - K mx - K add pair += [edge[i]] [edge[i]] pair K = map(int, input().split()) map(int, input().split()) K mx = (N-1)*(N-2)/2 (N-1)*(N-2)/2 mx edge += [[i+1, j+1]] [[i+1, j+1]] edge pair += [[i+1, N]] [[i+1, N]] pair
N, K = map(int, input().split())
mx = (N-1)*(N-2)/2
if mx < K:
  print(-1)
  exit()
pair = []
for i in range(N-1):
  pair += [[i+1, N]]
add = mx - K
edge = []
for i in range(N-1):
  for j in range(i):
    edge += [[i+1, j+1]]

for i in range(int(add)):
  pair += [edge[i]]

print(len(pair))
for i, j in pair:
  print(i, j)