n, k = [int(i) for i in input().split()]
if k > (n - 1)*(n - 2) // 2:
    print(-1)
else:
    ed = []
    for i in range(1, n):
        ed.append(" ".join(map(str, [1, i + 1])))
    kk = (n - 1)*(n - 2)//2 - k
    if not kk:
        print(len(ed))
        print("\n".join(ed))
        exit()
    for i in range(1, n):
        for j in range(i+1, n):
            ed.append(" ".join(map(str, [i + 1, j + 1])))
            kk -= 1
            if not kk:
                print(len(ed))
                print("\n".join(ed))
                exit() int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i n, k = [int(i) for i in input().split()] n [int(i) for i in input().split()] k if k > (n - 1)*(n - 2) // 2:
    print(-1)
else:
    ed = []
    for i in range(1, n):
        ed.append(" ".join(map(str, [1, i + 1])))
    kk = (n - 1)*(n - 2)//2 - k
    if not kk:
        print(len(ed))
        print("\n".join(ed))
        exit()
    for i in range(1, n):
        for j in range(i+1, n):
            ed.append(" ".join(map(str, [i + 1, j + 1])))
            kk -= 1
            if not kk:
                print(len(ed))
                print("\n".join(ed))
                exit() 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 ed = [] ed [] for i in range(1, n):
        ed.append(" ".join(map(str, [1, i + 1])))
     i range(1, n) range 1 n ed.append(" ".join(map(str, [1, i + 1]))) ed.append ed append " ".join(map(str, [1, i + 1])) " ".join " " join map(str, [1, i + 1]) map str [1, i + 1] 1 i + 1 i 1 kk = (n - 1)*(n - 2)//2 - k kk (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 if not kk:
        print(len(ed))
        print("\n".join(ed))
        exit()
     not kk kk print(len(ed)) print len(ed) len ed print("\n".join(ed)) print "\n".join(ed) "\n".join "\n" join ed exit() exit for i in range(1, n):
        for j in range(i+1, n):
            ed.append(" ".join(map(str, [i + 1, j + 1])))
            kk -= 1
            if not kk:
                print(len(ed))
                print("\n".join(ed))
                exit() i range(1, n) range 1 n for j in range(i+1, n):
            ed.append(" ".join(map(str, [i + 1, j + 1])))
            kk -= 1
            if not kk:
                print(len(ed))
                print("\n".join(ed))
                exit() j range(i+1, n) range i+1 i 1 n ed.append(" ".join(map(str, [i + 1, j + 1]))) ed.append ed append " ".join(map(str, [i + 1, j + 1])) " ".join " " join map(str, [i + 1, j + 1]) map str [i + 1, j + 1] i + 1 i 1 j + 1 j 1 kk -= 1 kk 1 if not kk:
                print(len(ed))
                print("\n".join(ed))
                exit() not kk kk print(len(ed)) print len(ed) len ed print("\n".join(ed)) print "\n".join(ed) "\n".join "\n" join ed exit() exit kk = (n - 1)*(n - 2)//2 - k (n - 1)*(n - 2)//2 - k kk ed = [] [] ed kk -= 1 1 kk k = [int(i) for i in input().split()] [int(i) for i in input().split()] k n, k = [int(i) for i in input().split()] [int(i) for i in input().split()] n
n, k = [int(i) for i in input().split()]
if k > (n - 1)*(n - 2) // 2:
    print(-1)
else:
    ed = []
    for i in range(1, n):
        ed.append(" ".join(map(str, [1, i + 1])))
    kk = (n - 1)*(n - 2)//2 - k
    if not kk:
        print(len(ed))
        print("\n".join(ed))
        exit()
    for i in range(1, n):
        for j in range(i+1, n):
            ed.append(" ".join(map(str, [i + 1, j + 1])))
            kk -= 1
            if not kk:
                print(len(ed))
                print("\n".join(ed))
                exit()
