def main():
    n, k = map(int, input().split())
    if (n-1)*(n-2)//2 < k:
        print("-1")
    else:
        ans = []
        buf = (n-1)*(n-2)//2
        for i in range(2, n+1):
            ans.append([1, i])
        for i in range(2, n):
            if buf == k:
                break
            for j in range(i+1, n+1):
                ans.append([i, j])
                buf -= 1
                if buf == k:
                    break
        print(len(ans))
        for v in ans:
            print(v[0], v[1])

if __name__ == "__main__":
    main() def main():
    n, k = map(int, input().split())
    if (n-1)*(n-2)//2 < k:
        print("-1")
    else:
        ans = []
        buf = (n-1)*(n-2)//2
        for i in range(2, n+1):
            ans.append([1, i])
        for i in range(2, n):
            if buf == k:
                break
            for j in range(i+1, n+1):
                ans.append([i, j])
                buf -= 1
                if buf == k:
                    break
        print(len(ans))
        for v in ans:
            print(v[0], v[1]) 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")
    else:
        ans = []
        buf = (n-1)*(n-2)//2
        for i in range(2, n+1):
            ans.append([1, i])
        for i in range(2, n):
            if buf == k:
                break
            for j in range(i+1, n+1):
                ans.append([i, j])
                buf -= 1
                if buf == k:
                    break
        print(len(ans))
        for v in ans:
            print(v[0], v[1]) (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" ans = [] ans [] buf = (n-1)*(n-2)//2 buf (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 for i in range(2, n+1):
            ans.append([1, i])
         i range(2, n+1) range 2 n+1 n 1 ans.append([1, i]) ans.append ans append [1, i] 1 i for i in range(2, n):
            if buf == k:
                break
            for j in range(i+1, n+1):
                ans.append([i, j])
                buf -= 1
                if buf == k:
                    break
         i range(2, n) range 2 n if buf == k:
                break
             buf == k buf k break for j in range(i+1, n+1):
                ans.append([i, j])
                buf -= 1
                if buf == k:
                    break
         j range(i+1, n+1) range i+1 i 1 n+1 n 1 ans.append([i, j]) ans.append ans append [i, j] i j buf -= 1 buf 1 if buf == k:
                    break
         buf == k buf k break print(len(ans)) print len(ans) len ans for v in ans:
            print(v[0], v[1]) v ans print(v[0], v[1]) print v[0] v 0 v[1] v 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n, k = map(int, input().split())
    if (n-1)*(n-2)//2 < k:
        print("-1")
    else:
        ans = []
        buf = (n-1)*(n-2)//2
        for i in range(2, n+1):
            ans.append([1, i])
        for i in range(2, n):
            if buf == k:
                break
            for j in range(i+1, n+1):
                ans.append([i, j])
                buf -= 1
                if buf == k:
                    break
        print(len(ans))
        for v in ans:
            print(v[0], v[1]) def main():
    n, k = map(int, input().split())
    if (n-1)*(n-2)//2 < k:
        print("-1")
    else:
        ans = []
        buf = (n-1)*(n-2)//2
        for i in range(2, n+1):
            ans.append([1, i])
        for i in range(2, n):
            if buf == k:
                break
            for j in range(i+1, n+1):
                ans.append([i, j])
                buf -= 1
                if buf == k:
                    break
        print(len(ans))
        for v in ans:
            print(v[0], v[1]) main
def main():
    n, k = map(int, input().split())
    if (n-1)*(n-2)//2 < k:
        print("-1")
    else:
        ans = []
        buf = (n-1)*(n-2)//2
        for i in range(2, n+1):
            ans.append([1, i])
        for i in range(2, n):
            if buf == k:
                break
            for j in range(i+1, n+1):
                ans.append([i, j])
                buf -= 1
                if buf == k:
                    break
        print(len(ans))
        for v in ans:
            print(v[0], v[1])

if __name__ == "__main__":
    main()