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