def solve(string):
    n, k = map(int, string.split())
    if k > (n - 1) * (n - 2) // 2:
        return "-1"
    ans = []
    c = (n - 1) * (n - 2) // 2
    for i in range(1, n):
        ans.append("{} {}".format(i, n))
    for i in range(1, n):
        for j in range(i + 1, n):
            if c - k == 0:
                break
            c -= 1
            ans.append("{} {}".format(i, j))
    return "{}\n".format(len(ans)) + "\n".join(ans)


if __name__ == '__main__':
    print(solve(input())) def solve(string):
    n, k = map(int, string.split())
    if k > (n - 1) * (n - 2) // 2:
        return "-1"
    ans = []
    c = (n - 1) * (n - 2) // 2
    for i in range(1, n):
        ans.append("{} {}".format(i, n))
    for i in range(1, n):
        for j in range(i + 1, n):
            if c - k == 0:
                break
            c -= 1
            ans.append("{} {}".format(i, j))
    return "{}\n".format(len(ans)) + "\n".join(ans) solve n, k = map(int, string.split()) n map(int, string.split()) map int string.split() string.split string split k if k > (n - 1) * (n - 2) // 2:
        return "-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 return "-1" "-1" ans = [] ans [] c = (n - 1) * (n - 2) // 2 c (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 for i in range(1, n):
        ans.append("{} {}".format(i, n))
     i range(1, n) range 1 n ans.append("{} {}".format(i, n)) ans.append ans append "{} {}".format(i, n) "{} {}".format "{} {}" format i n for i in range(1, n):
        for j in range(i + 1, n):
            if c - k == 0:
                break
            c -= 1
            ans.append("{} {}".format(i, j))
     i range(1, n) range 1 n for j in range(i + 1, n):
            if c - k == 0:
                break
            c -= 1
            ans.append("{} {}".format(i, j))
     j range(i + 1, n) range i + 1 i 1 n if c - k == 0:
                break
             c - k == 0 c - k c k 0 break c -= 1 c 1 ans.append("{} {}".format(i, j)) ans.append ans append "{} {}".format(i, j) "{} {}".format "{} {}" format i j return "{}\n".format(len(ans)) + "\n".join(ans) "{}\n".format(len(ans)) + "\n".join(ans) "{}\n".format(len(ans)) "{}\n".format "{}\n" format len(ans) len ans "\n".join(ans) "\n".join "\n" join ans string string if __name__ == '__main__':
    print(solve(input())) __name__ == '__main__' __name__ '__main__' print(solve(input())) print solve(input()) solve input() input def solve(string):
    n, k = map(int, string.split())
    if k > (n - 1) * (n - 2) // 2:
        return "-1"
    ans = []
    c = (n - 1) * (n - 2) // 2
    for i in range(1, n):
        ans.append("{} {}".format(i, n))
    for i in range(1, n):
        for j in range(i + 1, n):
            if c - k == 0:
                break
            c -= 1
            ans.append("{} {}".format(i, j))
    return "{}\n".format(len(ans)) + "\n".join(ans) def solve(string):
    n, k = map(int, string.split())
    if k > (n - 1) * (n - 2) // 2:
        return "-1"
    ans = []
    c = (n - 1) * (n - 2) // 2
    for i in range(1, n):
        ans.append("{} {}".format(i, n))
    for i in range(1, n):
        for j in range(i + 1, n):
            if c - k == 0:
                break
            c -= 1
            ans.append("{} {}".format(i, j))
    return "{}\n".format(len(ans)) + "\n".join(ans) solve
def solve(string):
    n, k = map(int, string.split())
    if k > (n - 1) * (n - 2) // 2:
        return "-1"
    ans = []
    c = (n - 1) * (n - 2) // 2
    for i in range(1, n):
        ans.append("{} {}".format(i, n))
    for i in range(1, n):
        for j in range(i + 1, n):
            if c - k == 0:
                break
            c -= 1
            ans.append("{} {}".format(i, j))
    return "{}\n".format(len(ans)) + "\n".join(ans)


if __name__ == '__main__':
    print(solve(input()))
