from sys import stdin, setrecursionlimit
from collections import deque


def main():
    INF = float('inf')
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
    else:
        ab = [[i, j] for i in range(1, n) for j in range(i + 1, n + 1)]
        m = n - 1 + (n - 1) * (n - 2) // 2 - k
        print(m)
        for i, j in ab[:m]:
            print(i, j)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main() from sys import stdin, setrecursionlimit from collections import deque def main():
    INF = float('inf')
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
    else:
        ab = [[i, j] for i in range(1, n) for j in range(i + 1, n + 1)]
        m = n - 1 + (n - 1) * (n - 2) // 2 - k
        print(m)
        for i, j in ab[:m]:
            print(i, j) main INF = float('inf') INF float('inf') float 'inf' input = stdin.buffer.readline input stdin.buffer.readline stdin.buffer stdin buffer readline 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)
    else:
        ab = [[i, j] for i in range(1, n) for j in range(i + 1, n + 1)]
        m = n - 1 + (n - 1) * (n - 2) // 2 - k
        print(m)
        for i, j in ab[:m]:
            print(i, j) 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 [i, j] for i in range(1, n) for j in range(i + 1, n + 1) for i in range(1, n) for j in range(i + 1, n + 1) i range(1, n) range 1 n for j in range(i + 1, n + 1) j range(i + 1, n + 1) range i + 1 i 1 n + 1 n 1 for j in range(i + 1, n + 1) [i, j] i j ab = [[i, j] for i in range(1, n) for j in range(i + 1, n + 1)] ab [[i, j] for i in range(1, n) for j in range(i + 1, n + 1)] m = n - 1 + (n - 1) * (n - 2) // 2 - k m n - 1 + (n - 1) * (n - 2) // 2 - k n - 1 + (n - 1) * (n - 2) // 2 n - 1 n 1 (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 k print(m) print m for i, j in ab[:m]:
            print(i, j) i j ab[:m] ab :m m print(i, j) print i j if __name__ == "__main__":
    setrecursionlimit(10000)
    main() __name__ == "__main__" __name__ "__main__" setrecursionlimit(10000) setrecursionlimit 10000 main() main def main():
    INF = float('inf')
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
    else:
        ab = [[i, j] for i in range(1, n) for j in range(i + 1, n + 1)]
        m = n - 1 + (n - 1) * (n - 2) // 2 - k
        print(m)
        for i, j in ab[:m]:
            print(i, j) def main():
    INF = float('inf')
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
    else:
        ab = [[i, j] for i in range(1, n) for j in range(i + 1, n + 1)]
        m = n - 1 + (n - 1) * (n - 2) // 2 - k
        print(m)
        for i, j in ab[:m]:
            print(i, j) main
from sys import stdin, setrecursionlimit
from collections import deque


def main():
    INF = float('inf')
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
    else:
        ab = [[i, j] for i in range(1, n) for j in range(i + 1, n + 1)]
        m = n - 1 + (n - 1) * (n - 2) // 2 - k
        print(m)
        for i, j in ab[:m]:
            print(i, j)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
