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