N,K=map(int,input().split())
fil=int((N-1)*(N-2)/2)
if K>fil:
  print(-1)
else:
  M=N-1+fil-K
  print(M)
  for i in range(N-1):
    print(1,i+2)
    count=0
  list=[]

  for j in range(2,N):
    for k in range(j+1,N+1):
      list.append((j,k))
  for i in range(fil-K):
    print(list[i][0],list[i][1]) N,K=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split K fil=int((N-1)*(N-2)/2) fil int((N-1)*(N-2)/2) int (N-1)*(N-2)/2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 if K>fil:
  print(-1)
else:
  M=N-1+fil-K
  print(M)
  for i in range(N-1):
    print(1,i+2)
    count=0
  list=[]

  for j in range(2,N):
    for k in range(j+1,N+1):
      list.append((j,k))
  for i in range(fil-K):
    print(list[i][0],list[i][1]) K>fil K fil print(-1) print -1 M=N-1+fil-K M N-1+fil-K N-1+fil N-1 N 1 fil K print(M) print M for i in range(N-1):
    print(1,i+2)
    count=0
   i range(N-1) range N-1 N 1 print(1,i+2) print 1 i+2 i 2 count=0 count 0 list=[] list [] for j in range(2,N):
    for k in range(j+1,N+1):
      list.append((j,k))
   j range(2,N) range 2 N for k in range(j+1,N+1):
      list.append((j,k))
   k range(j+1,N+1) range j+1 j 1 N+1 N 1 list.append((j,k)) list.append list append (j,k) j k for i in range(fil-K):
    print(list[i][0],list[i][1]) i range(fil-K) range fil-K fil K print(list[i][0],list[i][1]) print list[i][0] [i] list i 0 list[i][1] [i] list i 1 M=N-1+fil-K N-1+fil-K M K=map(int,input().split()) map(int,input().split()) K N,K=map(int,input().split()) map(int,input().split()) N count=0 0 count fil=int((N-1)*(N-2)/2) int((N-1)*(N-2)/2) fil list=[] [] list
N,K=map(int,input().split())
fil=int((N-1)*(N-2)/2)
if K>fil:
  print(-1)
else:
  M=N-1+fil-K
  print(M)
  for i in range(N-1):
    print(1,i+2)
    count=0
  list=[]

  for j in range(2,N):
    for k in range(j+1,N+1):
      list.append((j,k))
  for i in range(fil-K):
    print(list[i][0],list[i][1])