def getval():
    n,k = map(int,input().split())
    return n,k 

def main(n,k):
    f = [1]
    for i in range(n):
        f.append(f[i]*(i+1))
    maxpair = f[n-1]//(f[2]*f[n-3])
    if k>maxpair:
        print(-1)
    else:
        pair = maxpair
        ans = []
        for i in range(n-1):
            ans.append([1,i+2])
        for i in range(2,n+1):
            for j in range(i,n+1):
                if pair==k:
                    break
                if i==j:
                    continue
                ans.append([i,j])
                pair -= 1
        print(len(ans))
        for i in ans:
            print(str(i[0]) + " " + str(i[1]))

if __name__=="__main__":
    n,k = getval()
    main(n,k) def getval():
    n,k = map(int,input().split())
    return n,k  getval n,k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k return n,k return n,k n k def main(n,k):
    f = [1]
    for i in range(n):
        f.append(f[i]*(i+1))
    maxpair = f[n-1]//(f[2]*f[n-3])
    if k>maxpair:
        print(-1)
    else:
        pair = maxpair
        ans = []
        for i in range(n-1):
            ans.append([1,i+2])
        for i in range(2,n+1):
            for j in range(i,n+1):
                if pair==k:
                    break
                if i==j:
                    continue
                ans.append([i,j])
                pair -= 1
        print(len(ans))
        for i in ans:
            print(str(i[0]) + " " + str(i[1])) main f = [1] f [1] 1 for i in range(n):
        f.append(f[i]*(i+1))
     i range(n) range n f.append(f[i]*(i+1)) f.append f append f[i]*(i+1) f[i] f i i+1 i 1 maxpair = f[n-1]//(f[2]*f[n-3]) maxpair f[n-1]//(f[2]*f[n-3]) f[n-1] f n-1 n 1 f[2]*f[n-3] f[2] f 2 f[n-3] f n-3 n 3 if k>maxpair:
        print(-1)
    else:
        pair = maxpair
        ans = []
        for i in range(n-1):
            ans.append([1,i+2])
        for i in range(2,n+1):
            for j in range(i,n+1):
                if pair==k:
                    break
                if i==j:
                    continue
                ans.append([i,j])
                pair -= 1
        print(len(ans))
        for i in ans:
            print(str(i[0]) + " " + str(i[1])) k>maxpair k maxpair print(-1) print -1 pair = maxpair pair maxpair ans = [] ans [] for i in range(n-1):
            ans.append([1,i+2])
         i range(n-1) range n-1 n 1 ans.append([1,i+2]) ans.append ans append [1,i+2] 1 i+2 i 2 for i in range(2,n+1):
            for j in range(i,n+1):
                if pair==k:
                    break
                if i==j:
                    continue
                ans.append([i,j])
                pair -= 1
         i range(2,n+1) range 2 n+1 n 1 for j in range(i,n+1):
                if pair==k:
                    break
                if i==j:
                    continue
                ans.append([i,j])
                pair -= 1
         j range(i,n+1) range i n+1 n 1 if pair==k:
                    break
                 pair==k pair k break if i==j:
                    continue
                 i==j i j continue ans.append([i,j]) ans.append ans append [i,j] i j pair -= 1 pair 1 print(len(ans)) print len(ans) len ans for i in ans:
            print(str(i[0]) + " " + str(i[1])) i ans print(str(i[0]) + " " + str(i[1])) print str(i[0]) + " " + str(i[1]) str(i[0]) + " " str(i[0]) str i[0] i 0 " " str(i[1]) str i[1] i 1 n n k k if __name__=="__main__":
    n,k = getval()
    main(n,k) __name__=="__main__" __name__ "__main__" n,k = getval() n getval() getval k main(n,k) main n k def getval():
    n,k = map(int,input().split())
    return n,k  def getval():
    n,k = map(int,input().split())
    return n,k  getval k = getval() getval() k n,k = getval() getval() n def main(n,k):
    f = [1]
    for i in range(n):
        f.append(f[i]*(i+1))
    maxpair = f[n-1]//(f[2]*f[n-3])
    if k>maxpair:
        print(-1)
    else:
        pair = maxpair
        ans = []
        for i in range(n-1):
            ans.append([1,i+2])
        for i in range(2,n+1):
            for j in range(i,n+1):
                if pair==k:
                    break
                if i==j:
                    continue
                ans.append([i,j])
                pair -= 1
        print(len(ans))
        for i in ans:
            print(str(i[0]) + " " + str(i[1])) def main(n,k):
    f = [1]
    for i in range(n):
        f.append(f[i]*(i+1))
    maxpair = f[n-1]//(f[2]*f[n-3])
    if k>maxpair:
        print(-1)
    else:
        pair = maxpair
        ans = []
        for i in range(n-1):
            ans.append([1,i+2])
        for i in range(2,n+1):
            for j in range(i,n+1):
                if pair==k:
                    break
                if i==j:
                    continue
                ans.append([i,j])
                pair -= 1
        print(len(ans))
        for i in ans:
            print(str(i[0]) + " " + str(i[1])) main
def getval():
    n,k = map(int,input().split())
    return n,k 

def main(n,k):
    f = [1]
    for i in range(n):
        f.append(f[i]*(i+1))
    maxpair = f[n-1]//(f[2]*f[n-3])
    if k>maxpair:
        print(-1)
    else:
        pair = maxpair
        ans = []
        for i in range(n-1):
            ans.append([1,i+2])
        for i in range(2,n+1):
            for j in range(i,n+1):
                if pair==k:
                    break
                if i==j:
                    continue
                ans.append([i,j])
                pair -= 1
        print(len(ans))
        for i in ans:
            print(str(i[0]) + " " + str(i[1]))

if __name__=="__main__":
    n,k = getval()
    main(n,k)