import itertools

n,k = map(int, input().split())
if k > (n-1) * (n-2) // 2:
  print(-1)
  exit()
m = n * (n-1) // 2 - k
print(m)
for i in range(1,n):
  print(i,n)
add = (n-1) * (n-2) // 2 - k
for i in itertools.combinations(range(1,n),2):
  if not add:
    break
  print(*i)
  add -= 1 import itertools itertools 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)
  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 exit() exit m = n * (n-1) // 2 - k m n * (n-1) // 2 - k n * (n-1) // 2 n * (n-1) n n-1 n 1 2 k print(m) print m for i in range(1,n):
  print(i,n) i range(1,n) range 1 n print(i,n) print i n add = (n-1) * (n-2) // 2 - k add (n-1) * (n-2) // 2 - k (n-1) * (n-2) // 2 (n-1) * (n-2) n-1 n 1 n-2 n 2 2 k for i in itertools.combinations(range(1,n),2):
  if not add:
    break
  print(*i)
  add -= 1 i itertools.combinations(range(1,n),2) itertools.combinations itertools combinations range(1,n) range 1 n 2 if not add:
    break
   not add add break print(*i) print *i i add -= 1 add 1 add -= 1 1 add add = (n-1) * (n-2) // 2 - k (n-1) * (n-2) // 2 - k add n,k = map(int, input().split()) map(int, input().split()) n k = map(int, input().split()) map(int, input().split()) k m = n * (n-1) // 2 - k n * (n-1) // 2 - k m
import itertools

n,k = map(int, input().split())
if k > (n-1) * (n-2) // 2:
  print(-1)
  exit()
m = n * (n-1) // 2 - k
print(m)
for i in range(1,n):
  print(i,n)
add = (n-1) * (n-2) // 2 - k
for i in itertools.combinations(range(1,n),2):
  if not add:
    break
  print(*i)
  add -= 1