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