n, k = map(int, input().split())
m = (n - 1) * (n - 2) // 2
if k > m:
    print(-1)
    exit(0)
print(n + m - k - 1)
for i in range(1, n):
    print(i, n)
for i in range(1, n):
    for j in range(i + 1, n):
        if m == k:
            exit(0)
        print(i, j)
        k += 1 n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k m = (n - 1) * (n - 2) // 2 m (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 if k > m:
    print(-1)
    exit(0) k > m k m print(-1) print -1 exit(0) exit 0 print(n + m - k - 1) print n + m - k - 1 n + m - k n + m n m k 1 for i in range(1, n):
    print(i, n) i range(1, n) range 1 n print(i, n) print i n for i in range(1, n):
    for j in range(i + 1, n):
        if m == k:
            exit(0)
        print(i, j)
        k += 1 i range(1, n) range 1 n for j in range(i + 1, n):
        if m == k:
            exit(0)
        print(i, j)
        k += 1 j range(i + 1, n) range i + 1 i 1 n if m == k:
            exit(0)
         m == k m k exit(0) exit 0 print(i, j) print i j k += 1 k 1 n, k = map(int, input().split()) map(int, input().split()) n m = (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) // 2 m k = map(int, input().split()) map(int, input().split()) k k += 1 1 k
n, k = map(int, input().split())
m = (n - 1) * (n - 2) // 2
if k > m:
    print(-1)
    exit(0)
print(n + m - k - 1)
for i in range(1, n):
    print(i, n)
for i in range(1, n):
    for j in range(i + 1, n):
        if m == k:
            exit(0)
        print(i, j)
        k += 1