N,K = map(int,input().split())

mx = (N-1)*(N-2)//2
if K > mx:
  print(-1)
  exit()

ans = []
for i in range(N-1):
  ans.append((i+1, N))

add = mx-K
edge = []
for i in range(N-1):
  for j in range(i):
    edge.append((i+1, j+1))

for i in range(add):
  ans.append(edge[i])

print(len(ans))
for u,v in ans:
  print(u,v) 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 if K > mx:
  print(-1)
  exit() K > mx K mx print(-1) print -1 exit() exit ans = [] ans [] for i in range(N-1):
  ans.append((i+1, N)) i range(N-1) range N-1 N 1 ans.append((i+1, N)) ans.append ans append (i+1, N) i+1 i 1 N add = mx-K add mx-K mx K edge = [] edge [] for i in range(N-1):
  for j in range(i):
    edge.append((i+1, j+1)) i range(N-1) range N-1 N 1 for j in range(i):
    edge.append((i+1, j+1)) j range(i) range i edge.append((i+1, j+1)) edge.append edge append (i+1, j+1) i+1 i 1 j+1 j 1 for i in range(add):
  ans.append(edge[i]) i range(add) range add ans.append(edge[i]) ans.append ans append edge[i] edge i print(len(ans)) print len(ans) len ans for u,v in ans:
  print(u,v) u v ans print(u,v) print u v 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 add = mx-K mx-K add ans = [] [] ans edge = [] [] edge
N,K = map(int,input().split())

mx = (N-1)*(N-2)//2
if K > mx:
  print(-1)
  exit()

ans = []
for i in range(N-1):
  ans.append((i+1, N))

add = mx-K
edge = []
for i in range(N-1):
  for j in range(i):
    edge.append((i+1, j+1))

for i in range(add):
  ans.append(edge[i])

print(len(ans))
for u,v in ans:
  print(u,v)