N, K = map(int, input().split(' '))
count = (N - 1) * (N - 2) // 2
is_connect = [[False for _ in range(N)] for _ in range(N)]
if K > count:
  print(-1)
else:
  for i in range(1, N):
    is_connect[0][i] = True
  i = 2
  j = 1
  for _ in range(count - K):
    is_connect[j][i] = True
    if i == N - 1:
      j += 1
      i = j + 1
    else:
      i += 1
  print(N - 1 + count - K)
  for i in range(N):
    for j in range(N):
      if i != j and is_connect[i][j]:
        print('{0} {1}'.format(i + 1, j + 1)) N, K = map(int, input().split(' ')) N map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' K count = (N - 1) * (N - 2) // 2 count (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 [False for _ in range(N)] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [False for _ in range(N)] is_connect = [[False for _ in range(N)] for _ in range(N)] is_connect [[False for _ in range(N)] for _ in range(N)] if K > count:
  print(-1)
else:
  for i in range(1, N):
    is_connect[0][i] = True
  i = 2
  j = 1
  for _ in range(count - K):
    is_connect[j][i] = True
    if i == N - 1:
      j += 1
      i = j + 1
    else:
      i += 1
  print(N - 1 + count - K)
  for i in range(N):
    for j in range(N):
      if i != j and is_connect[i][j]:
        print('{0} {1}'.format(i + 1, j + 1)) K > count K count print(-1) print -1 for i in range(1, N):
    is_connect[0][i] = True
   i range(1, N) range 1 N is_connect[0][i] = True is_connect[0][i] [0] is_connect 0 i True i = 2 i 2 j = 1 j 1 for _ in range(count - K):
    is_connect[j][i] = True
    if i == N - 1:
      j += 1
      i = j + 1
    else:
      i += 1
   _ range(count - K) range count - K count K is_connect[j][i] = True is_connect[j][i] [j] is_connect j i True if i == N - 1:
      j += 1
      i = j + 1
    else:
      i += 1
   i == N - 1 i N - 1 N 1 j += 1 j 1 i = j + 1 i j + 1 j 1 i += 1 i 1 print(N - 1 + count - K) print N - 1 + count - K N - 1 + count N - 1 N 1 count K for i in range(N):
    for j in range(N):
      if i != j and is_connect[i][j]:
        print('{0} {1}'.format(i + 1, j + 1)) i range(N) range N for j in range(N):
      if i != j and is_connect[i][j]:
        print('{0} {1}'.format(i + 1, j + 1)) j range(N) range N if i != j and is_connect[i][j]:
        print('{0} {1}'.format(i + 1, j + 1)) i != j and is_connect[i][j] i != j i j is_connect[i][j] [i] is_connect i j print('{0} {1}'.format(i + 1, j + 1)) print '{0} {1}'.format(i + 1, j + 1) '{0} {1}'.format '{0} {1}' format i + 1 i 1 j + 1 j 1 N, K = map(int, input().split(' ')) map(int, input().split(' ')) N j += 1 1 j i = j + 1 j + 1 i is_connect = [[False for _ in range(N)] for _ in range(N)] [[False for _ in range(N)] for _ in range(N)] is_connect i += 1 1 i count = (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) // 2 count i = 2 2 i K = map(int, input().split(' ')) map(int, input().split(' ')) K j = 1 1 j
N, K = map(int, input().split(' '))
count = (N - 1) * (N - 2) // 2
is_connect = [[False for _ in range(N)] for _ in range(N)]
if K > count:
  print(-1)
else:
  for i in range(1, N):
    is_connect[0][i] = True
  i = 2
  j = 1
  for _ in range(count - K):
    is_connect[j][i] = True
    if i == N - 1:
      j += 1
      i = j + 1
    else:
      i += 1
  print(N - 1 + count - K)
  for i in range(N):
    for j in range(N):
      if i != j and is_connect[i][j]:
        print('{0} {1}'.format(i + 1, j + 1))