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

if K > (N-1)*(N-2) // 2:
    print(-1)
else:
    max_dif = (N-1)*(N-2) // 2 - K
    M = N - 1 + max_dif
    print(M)
    for i in range(N-1):
        print("{} {}".format(1, i+2))
    node1 = 2
    node2 = 3
    for i in range(max_dif):
        print("{} {}".format(node1, node2))
        if node2 == N:
            node1 += 1
            node2 = node1 + 1
        else:
            node2 += 1 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:
    max_dif = (N-1)*(N-2) // 2 - K
    M = N - 1 + max_dif
    print(M)
    for i in range(N-1):
        print("{} {}".format(1, i+2))
    node1 = 2
    node2 = 3
    for i in range(max_dif):
        print("{} {}".format(node1, node2))
        if node2 == N:
            node1 += 1
            node2 = node1 + 1
        else:
            node2 += 1 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 max_dif = (N-1)*(N-2) // 2 - K max_dif (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 M = N - 1 + max_dif M N - 1 + max_dif N - 1 N 1 max_dif print(M) print M for i in range(N-1):
        print("{} {}".format(1, i+2))
     i range(N-1) range N-1 N 1 print("{} {}".format(1, i+2)) print "{} {}".format(1, i+2) "{} {}".format "{} {}" format 1 i+2 i 2 node1 = 2 node1 2 node2 = 3 node2 3 for i in range(max_dif):
        print("{} {}".format(node1, node2))
        if node2 == N:
            node1 += 1
            node2 = node1 + 1
        else:
            node2 += 1 i range(max_dif) range max_dif print("{} {}".format(node1, node2)) print "{} {}".format(node1, node2) "{} {}".format "{} {}" format node1 node2 if node2 == N:
            node1 += 1
            node2 = node1 + 1
        else:
            node2 += 1 node2 == N node2 N node1 += 1 node1 1 node2 = node1 + 1 node2 node1 + 1 node1 1 node2 += 1 node2 1 node1 = 2 2 node1 node1 += 1 1 node1 K = map(int, input().split()) map(int, input().split()) K node2 += 1 1 node2 max_dif = (N-1)*(N-2) // 2 - K (N-1)*(N-2) // 2 - K max_dif N, K = map(int, input().split()) map(int, input().split()) N node2 = 3 3 node2 M = N - 1 + max_dif N - 1 + max_dif M node2 = node1 + 1 node1 + 1 node2
N, K = map(int, input().split())

if K > (N-1)*(N-2) // 2:
    print(-1)
else:
    max_dif = (N-1)*(N-2) // 2 - K
    M = N - 1 + max_dif
    print(M)
    for i in range(N-1):
        print("{} {}".format(1, i+2))
    node1 = 2
    node2 = 3
    for i in range(max_dif):
        print("{} {}".format(node1, node2))
        if node2 == N:
            node1 += 1
            node2 = node1 + 1
        else:
            node2 += 1
