import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    if (N - 1) * (N - 2) // 2 < K:
        print(-1)
        return
    else:
        edges = set()
        for i in range(2, N + 1):
            edges.add((1, i))

        cnt = (N - 1) * (N - 2) // 2
        for i in range(1, N):
            for j in range(i, N + 1):
                if i == j:
                    continue

                if cnt == K:
                    print(len(edges))
                    for a, b in edges:
                        print(a, b)
                    return

                if (i, j) not in edges:
                    cnt -= 1
                    edges.add((i, j))

        print(len(edges))
        for a, b in edges:
            print(a, b)
        return


if __name__ == "__main__":
    main() import sys sys sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 INF = float("inf") INF float("inf") float "inf" MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def input():
    return sys.stdin.readline().strip() input return sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip def main():
    N, K = map(int, input().split())
    if (N - 1) * (N - 2) // 2 < K:
        print(-1)
        return
    else:
        edges = set()
        for i in range(2, N + 1):
            edges.add((1, i))

        cnt = (N - 1) * (N - 2) // 2
        for i in range(1, N):
            for j in range(i, N + 1):
                if i == j:
                    continue

                if cnt == K:
                    print(len(edges))
                    for a, b in edges:
                        print(a, b)
                    return

                if (i, j) not in edges:
                    cnt -= 1
                    edges.add((i, j))

        print(len(edges))
        for a, b in edges:
            print(a, b)
        return main N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K if (N - 1) * (N - 2) // 2 < K:
        print(-1)
        return
    else:
        edges = set()
        for i in range(2, N + 1):
            edges.add((1, i))

        cnt = (N - 1) * (N - 2) // 2
        for i in range(1, N):
            for j in range(i, N + 1):
                if i == j:
                    continue

                if cnt == K:
                    print(len(edges))
                    for a, b in edges:
                        print(a, b)
                    return

                if (i, j) not in edges:
                    cnt -= 1
                    edges.add((i, j))

        print(len(edges))
        for a, b in edges:
            print(a, b)
        return (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 print(-1) print -1 return edges = set() edges set() set for i in range(2, N + 1):
            edges.add((1, i))

         i range(2, N + 1) range 2 N + 1 N 1 edges.add((1, i)) edges.add edges add (1, i) 1 i cnt = (N - 1) * (N - 2) // 2 cnt (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 for i in range(1, N):
            for j in range(i, N + 1):
                if i == j:
                    continue

                if cnt == K:
                    print(len(edges))
                    for a, b in edges:
                        print(a, b)
                    return

                if (i, j) not in edges:
                    cnt -= 1
                    edges.add((i, j))

         i range(1, N) range 1 N for j in range(i, N + 1):
                if i == j:
                    continue

                if cnt == K:
                    print(len(edges))
                    for a, b in edges:
                        print(a, b)
                    return

                if (i, j) not in edges:
                    cnt -= 1
                    edges.add((i, j))

         j range(i, N + 1) range i N + 1 N 1 if i == j:
                    continue

                 i == j i j continue if cnt == K:
                    print(len(edges))
                    for a, b in edges:
                        print(a, b)
                    return

                 cnt == K cnt K print(len(edges)) print len(edges) len edges for a, b in edges:
                        print(a, b)
                     a b edges print(a, b) print a b return if (i, j) not in edges:
                    cnt -= 1
                    edges.add((i, j))

         (i, j) not in edges (i, j) i j edges cnt -= 1 cnt 1 edges.add((i, j)) edges.add edges add (i, j) i j print(len(edges)) print len(edges) len edges for a, b in edges:
            print(a, b)
         a b edges print(a, b) print a b return if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def main():
    N, K = map(int, input().split())
    if (N - 1) * (N - 2) // 2 < K:
        print(-1)
        return
    else:
        edges = set()
        for i in range(2, N + 1):
            edges.add((1, i))

        cnt = (N - 1) * (N - 2) // 2
        for i in range(1, N):
            for j in range(i, N + 1):
                if i == j:
                    continue

                if cnt == K:
                    print(len(edges))
                    for a, b in edges:
                        print(a, b)
                    return

                if (i, j) not in edges:
                    cnt -= 1
                    edges.add((i, j))

        print(len(edges))
        for a, b in edges:
            print(a, b)
        return def main():
    N, K = map(int, input().split())
    if (N - 1) * (N - 2) // 2 < K:
        print(-1)
        return
    else:
        edges = set()
        for i in range(2, N + 1):
            edges.add((1, i))

        cnt = (N - 1) * (N - 2) // 2
        for i in range(1, N):
            for j in range(i, N + 1):
                if i == j:
                    continue

                if cnt == K:
                    print(len(edges))
                    for a, b in edges:
                        print(a, b)
                    return

                if (i, j) not in edges:
                    cnt -= 1
                    edges.add((i, j))

        print(len(edges))
        for a, b in edges:
            print(a, b)
        return main INF = float("inf") float("inf") INF def input():
    return sys.stdin.readline().strip() def input():
    return sys.stdin.readline().strip() input
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    if (N - 1) * (N - 2) // 2 < K:
        print(-1)
        return
    else:
        edges = set()
        for i in range(2, N + 1):
            edges.add((1, i))

        cnt = (N - 1) * (N - 2) // 2
        for i in range(1, N):
            for j in range(i, N + 1):
                if i == j:
                    continue

                if cnt == K:
                    print(len(edges))
                    for a, b in edges:
                        print(a, b)
                    return

                if (i, j) not in edges:
                    cnt -= 1
                    edges.add((i, j))

        print(len(edges))
        for a, b in edges:
            print(a, b)
        return


if __name__ == "__main__":
    main()
