N, K = map(int, raw_input().split())

if K<=(N-1)*(N-2)/2:
  E = []
  for i in range(N-1):
    for j in range(i):
      E += [(j, i)]
  E = E[:(N-1)*(N-2)/2-K]
  for i in range(N-1):
    E += [(i, N-1)]
  print len(E)
  for e in E:
    print e[0]+1, e[1]+1
else:
  print "-1" N, K = map(int, raw_input().split()) N map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split K if K<=(N-1)*(N-2)/2:
  E = []
  for i in range(N-1):
    for j in range(i):
      E += [(j, i)]
  E = E[:(N-1)*(N-2)/2-K]
  for i in range(N-1):
    E += [(i, N-1)]
  print len(E)
  for e in E:
    print e[0]+1, e[1]+1
else:
  print "-1" 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 E = [] E [] for i in range(N-1):
    for j in range(i):
      E += [(j, i)]
   i range(N-1) range N-1 N 1 for j in range(i):
      E += [(j, i)]
   j range(i) range i E += [(j, i)] E [(j, i)] (j, i) j i E = E[:(N-1)*(N-2)/2-K] E E[:(N-1)*(N-2)/2-K] E :(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 for i in range(N-1):
    E += [(i, N-1)]
   i range(N-1) range N-1 N 1 E += [(i, N-1)] E [(i, N-1)] (i, N-1) i N-1 N 1 print len(E) len E for e in E:
    print e[0]+1, e[1]+1 e E print e[0]+1 e[0] e 0 1 e[1]+1 e[1] e 1 1 print E += [(j, i)] [(j, i)] E K = map(int, raw_input().split()) map(int, raw_input().split()) K E = E[:(N-1)*(N-2)/2-K] E[:(N-1)*(N-2)/2-K] E E += [(i, N-1)] [(i, N-1)] E E = [] [] E N, K = map(int, raw_input().split()) map(int, raw_input().split()) N
N, K = map(int, raw_input().split())

if K<=(N-1)*(N-2)/2:
  E = []
  for i in range(N-1):
    for j in range(i):
      E += [(j, i)]
  E = E[:(N-1)*(N-2)/2-K]
  for i in range(N-1):
    E += [(i, N-1)]
  print len(E)
  for e in E:
    print e[0]+1, e[1]+1
else:
  print "-1"
