n, k = map(int, input().split()) 

if 2 * k > (n-1) * (n-2):
  print(-1)
else:
  ans = [(1, i) for i in range(2, n+1)]
  p =  (n-1) * (n-2) // 2
  i = 2
  j = 3
  while p > k:
    ans.append((i, j))
    p -= 1
    j += 1
    if j == n + 1:
      i += 1
      j = i + 1
  print(len(ans))
  for a in ans:
    print(" ".join(map(str, a))) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k if 2 * k > (n-1) * (n-2):
  print(-1)
else:
  ans = [(1, i) for i in range(2, n+1)]
  p =  (n-1) * (n-2) // 2
  i = 2
  j = 3
  while p > k:
    ans.append((i, j))
    p -= 1
    j += 1
    if j == n + 1:
      i += 1
      j = i + 1
  print(len(ans))
  for a in ans:
    print(" ".join(map(str, a))) 2 * k > (n-1) * (n-2) 2 * k 2 k (n-1) * (n-2) n-1 n 1 n-2 n 2 print(-1) print -1 (1, i) for i in range(2, n+1) for i in range(2, n+1) i range(2, n+1) range 2 n+1 n 1 for i in range(2, n+1) (1, i) 1 i ans = [(1, i) for i in range(2, n+1)] ans [(1, i) for i in range(2, n+1)] p =  (n-1) * (n-2) // 2 p (n-1) * (n-2) // 2 (n-1) * (n-2) n-1 n 1 n-2 n 2 2 i = 2 i 2 j = 3 j 3 while p > k:
    ans.append((i, j))
    p -= 1
    j += 1
    if j == n + 1:
      i += 1
      j = i + 1
   p > k p k ans.append((i, j)) ans.append ans append (i, j) i j p -= 1 p 1 j += 1 j 1 if j == n + 1:
      i += 1
      j = i + 1
   j == n + 1 j n + 1 n 1 i += 1 i 1 j = i + 1 j i + 1 i 1 print(len(ans)) print len(ans) len ans for a in ans:
    print(" ".join(map(str, a))) a ans print(" ".join(map(str, a))) print " ".join(map(str, a)) " ".join " " join map(str, a) map str a j = 3 3 j k = map(int, input().split()) map(int, input().split()) k ans = [(1, i) for i in range(2, n+1)] [(1, i) for i in range(2, n+1)] ans n, k = map(int, input().split()) map(int, input().split()) n i += 1 1 i p -= 1 1 p j += 1 1 j i = 2 2 i p =  (n-1) * (n-2) // 2 (n-1) * (n-2) // 2 p j = i + 1 i + 1 j
n, k = map(int, input().split()) 

if 2 * k > (n-1) * (n-2):
  print(-1)
else:
  ans = [(1, i) for i in range(2, n+1)]
  p =  (n-1) * (n-2) // 2
  i = 2
  j = 3
  while p > k:
    ans.append((i, j))
    p -= 1
    j += 1
    if j == n + 1:
      i += 1
      j = i + 1
  print(len(ans))
  for a in ans:
    print(" ".join(map(str, a)))