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