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