from math import factorial
from itertools import combinations, islice

def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)

def main():
    N, K = map(int, input().split())
    A = nCr(N - 1, 2) if N > 2 else 0
    if K > A:
        print(-1)
        return
    print(N - 1 + A - K)
    for i in range(2, N + 1):
        print(1, i)
    for u, v in islice(combinations(range(2, N + 1), 2), A - K):
        print(u, v)

main() from math import factorial from itertools import combinations, islice def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r) nCr return factorial(n) // factorial(r) // factorial(n - r) factorial(n) // factorial(r) // factorial(n - r) factorial(n) // factorial(r) factorial(n) factorial n factorial(r) factorial r factorial(n - r) factorial n - r n r n n r r def main():
    N, K = map(int, input().split())
    A = nCr(N - 1, 2) if N > 2 else 0
    if K > A:
        print(-1)
        return
    print(N - 1 + A - K)
    for i in range(2, N + 1):
        print(1, i)
    for u, v in islice(combinations(range(2, N + 1), 2), A - K):
        print(u, v) main N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K A = nCr(N - 1, 2) if N > 2 else 0 A nCr(N - 1, 2) if N > 2 else 0 N > 2 N 2 nCr(N - 1, 2) nCr N - 1 N 1 2 0 if K > A:
        print(-1)
        return
     K > A K A print(-1) print -1 return print(N - 1 + A - K) print N - 1 + A - K N - 1 + A N - 1 N 1 A K for i in range(2, N + 1):
        print(1, i)
     i range(2, N + 1) range 2 N + 1 N 1 print(1, i) print 1 i for u, v in islice(combinations(range(2, N + 1), 2), A - K):
        print(u, v) u v islice(combinations(range(2, N + 1), 2), A - K) islice combinations(range(2, N + 1), 2) combinations range(2, N + 1) range 2 N + 1 N 1 2 A - K A K print(u, v) print u v main() main def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r) def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r) nCr def main():
    N, K = map(int, input().split())
    A = nCr(N - 1, 2) if N > 2 else 0
    if K > A:
        print(-1)
        return
    print(N - 1 + A - K)
    for i in range(2, N + 1):
        print(1, i)
    for u, v in islice(combinations(range(2, N + 1), 2), A - K):
        print(u, v) def main():
    N, K = map(int, input().split())
    A = nCr(N - 1, 2) if N > 2 else 0
    if K > A:
        print(-1)
        return
    print(N - 1 + A - K)
    for i in range(2, N + 1):
        print(1, i)
    for u, v in islice(combinations(range(2, N + 1), 2), A - K):
        print(u, v) main
from math import factorial
from itertools import combinations, islice

def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)

def main():
    N, K = map(int, input().split())
    A = nCr(N - 1, 2) if N > 2 else 0
    if K > A:
        print(-1)
        return
    print(N - 1 + A - K)
    for i in range(2, N + 1):
        print(1, i)
    for u, v in islice(combinations(range(2, N + 1), 2), A - K):
        print(u, v)

main()
