def main(N, K):
    e_max = (N - 1) * (N - 2) // 2
    if K > e_max:
        print(-1)
        return

    edge = []
    add = []
    for i in range(2, N + 1):
        edge.append((1, i))
    for i in range(2, N):
        for j in range(i + 1, N + 1):
            add.append((i, j))

    while e_max != K:
        edge.append(add.pop())
        K += 1

    print(len(edge))
    for x, y in edge:
        print(x, y)
    return


N, K = map(int, input().split())
main(N, K) def main(N, K):
    e_max = (N - 1) * (N - 2) // 2
    if K > e_max:
        print(-1)
        return

    edge = []
    add = []
    for i in range(2, N + 1):
        edge.append((1, i))
    for i in range(2, N):
        for j in range(i + 1, N + 1):
            add.append((i, j))

    while e_max != K:
        edge.append(add.pop())
        K += 1

    print(len(edge))
    for x, y in edge:
        print(x, y)
    return main e_max = (N - 1) * (N - 2) // 2 e_max (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 if K > e_max:
        print(-1)
        return

     K > e_max K e_max print(-1) print -1 return edge = [] edge [] add = [] add [] for i in range(2, N + 1):
        edge.append((1, i))
     i range(2, N + 1) range 2 N + 1 N 1 edge.append((1, i)) edge.append edge append (1, i) 1 i for i in range(2, N):
        for j in range(i + 1, N + 1):
            add.append((i, j))

     i range(2, N) range 2 N for j in range(i + 1, N + 1):
            add.append((i, j))

     j range(i + 1, N + 1) range i + 1 i 1 N + 1 N 1 add.append((i, j)) add.append add append (i, j) i j while e_max != K:
        edge.append(add.pop())
        K += 1

     e_max != K e_max K edge.append(add.pop()) edge.append edge append add.pop() add.pop add pop K += 1 K 1 print(len(edge)) print len(edge) len edge for x, y in edge:
        print(x, y)
     x y edge print(x, y) print x y return N N K K N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K main(N, K) main N K def main(N, K):
    e_max = (N - 1) * (N - 2) // 2
    if K > e_max:
        print(-1)
        return

    edge = []
    add = []
    for i in range(2, N + 1):
        edge.append((1, i))
    for i in range(2, N):
        for j in range(i + 1, N + 1):
            add.append((i, j))

    while e_max != K:
        edge.append(add.pop())
        K += 1

    print(len(edge))
    for x, y in edge:
        print(x, y)
    return def main(N, K):
    e_max = (N - 1) * (N - 2) // 2
    if K > e_max:
        print(-1)
        return

    edge = []
    add = []
    for i in range(2, N + 1):
        edge.append((1, i))
    for i in range(2, N):
        for j in range(i + 1, N + 1):
            add.append((i, j))

    while e_max != K:
        edge.append(add.pop())
        K += 1

    print(len(edge))
    for x, y in edge:
        print(x, y)
    return main N, K = map(int, input().split()) map(int, input().split()) N K = map(int, input().split()) map(int, input().split()) K
def main(N, K):
    e_max = (N - 1) * (N - 2) // 2
    if K > e_max:
        print(-1)
        return

    edge = []
    add = []
    for i in range(2, N + 1):
        edge.append((1, i))
    for i in range(2, N):
        for j in range(i + 1, N + 1):
            add.append((i, j))

    while e_max != K:
        edge.append(add.pop())
        K += 1

    print(len(edge))
    for x, y in edge:
        print(x, y)
    return


N, K = map(int, input().split())
main(N, K)