n,k = map(int,input().split())
mx  = (n-1)*(n-2)//2
li  = []

if k>mx:
  print('-1')
else:
  e = mx-k
  M = (n-1)+e
  print(M)

  for i in range(n-1,0,-1):
    for j in range(1,i):
      li.append([i,j])

  for i in range(1,n):
    print(n,i)
  
  for i in range(e):
    print(*li[i]) 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 li  = [] li [] if k>mx:
  print('-1')
else:
  e = mx-k
  M = (n-1)+e
  print(M)

  for i in range(n-1,0,-1):
    for j in range(1,i):
      li.append([i,j])

  for i in range(1,n):
    print(n,i)
  
  for i in range(e):
    print(*li[i]) k>mx k mx print('-1') print '-1' e = mx-k e mx-k mx k M = (n-1)+e M (n-1)+e n-1 n 1 e print(M) print M for i in range(n-1,0,-1):
    for j in range(1,i):
      li.append([i,j])

   i range(n-1,0,-1) range n-1 n 1 0 -1 for j in range(1,i):
      li.append([i,j])

   j range(1,i) range 1 i li.append([i,j]) li.append li append [i,j] i j for i in range(1,n):
    print(n,i)
  
   i range(1,n) range 1 n print(n,i) print n i for i in range(e):
    print(*li[i]) i range(e) range e print(*li[i]) print *li[i] li[i] li i e = mx-k mx-k e M = (n-1)+e (n-1)+e M li  = [] [] li n,k = map(int,input().split()) map(int,input().split()) n k = map(int,input().split()) map(int,input().split()) k mx  = (n-1)*(n-2)//2 (n-1)*(n-2)//2 mx
n,k = map(int,input().split())
mx  = (n-1)*(n-2)//2
li  = []

if k>mx:
  print('-1')
else:
  e = mx-k
  M = (n-1)+e
  print(M)

  for i in range(n-1,0,-1):
    for j in range(1,i):
      li.append([i,j])

  for i in range(1,n):
    print(n,i)
  
  for i in range(e):
    print(*li[i])
