N,K=map(int,input().split())
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
if N==2 and K>=1:
    print(-1)
    exit()
if K>cmb(N-1,2):
    print(-1)
else:
    count=cmb(N-1,2)-K
    print(cmb(N,2)-K)
    for i in range(2,N+1):
        print(1,i)

    for i in range(2,N):
        for j in range(i+1,N+1):
            if count==0:
                exit()
            print(i,j)
            count-=1 N,K=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split K def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result cmb if n - r < r: r = n - r
     n - r < r n - r n r r if r == 0: return 1
     r == 0 r 0 if r == 1: return n

     r == 1 r 1 n - r + k + 1 for k in range(r) for k in range(r) k range(r) range r for k in range(r) n - r + k + 1 n - r + k n - r n r k 1 numerator = [n - r + k + 1 for k in range(r)] numerator [n - r + k + 1 for k in range(r)] k + 1 for k in range(r) for k in range(r) k range(r) range r for k in range(r) k + 1 k 1 denominator = [k + 1 for k in range(r)] denominator [k + 1 for k in range(r)] for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

     p range(2,r+1) range 2 r+1 r 1 pivot = denominator[p - 1] pivot denominator[p - 1] denominator p - 1 p 1 if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

     pivot > 1 pivot 1 offset = (n - r) % p offset (n - r) % p n - r n r p for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

     k range(p-1,r,p) range p-1 p 1 r p numerator[k - offset] /= pivot numerator[k - offset] numerator k - offset k offset pivot denominator[k] /= pivot denominator[k] denominator k pivot result = 1 result 1 for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

     k range(r) range r if numerator[k] > 1:
            result *= int(numerator[k])

     numerator[k] > 1 numerator[k] numerator k 1 result *= int(numerator[k]) result int(numerator[k]) int numerator[k] numerator k return result result n n r r if N==2 and K>=1:
    print(-1)
    exit() N==2 and K>=1 N==2 N 2 K>=1 K 1 print(-1) print -1 exit() exit if K>cmb(N-1,2):
    print(-1)
else:
    count=cmb(N-1,2)-K
    print(cmb(N,2)-K)
    for i in range(2,N+1):
        print(1,i)

    for i in range(2,N):
        for j in range(i+1,N+1):
            if count==0:
                exit()
            print(i,j)
            count-=1 K>cmb(N-1,2) K cmb(N-1,2) cmb N-1 N 1 2 print(-1) print -1 count=cmb(N-1,2)-K count cmb(N-1,2)-K cmb(N-1,2) cmb N-1 N 1 2 K print(cmb(N,2)-K) print cmb(N,2)-K cmb(N,2) cmb N 2 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 i in range(2,N):
        for j in range(i+1,N+1):
            if count==0:
                exit()
            print(i,j)
            count-=1 i range(2,N) range 2 N for j in range(i+1,N+1):
            if count==0:
                exit()
            print(i,j)
            count-=1 j range(i+1,N+1) range i+1 i 1 N+1 N 1 if count==0:
                exit()
             count==0 count 0 exit() exit print(i,j) print i j count-=1 count 1 K=map(int,input().split()) map(int,input().split()) K N,K=map(int,input().split()) map(int,input().split()) N count=cmb(N-1,2)-K cmb(N-1,2)-K count def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result cmb count-=1 1 count
N,K=map(int,input().split())
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
if N==2 and K>=1:
    print(-1)
    exit()
if K>cmb(N-1,2):
    print(-1)
else:
    count=cmb(N-1,2)-K
    print(cmb(N,2)-K)
    for i in range(2,N+1):
        print(1,i)

    for i in range(2,N):
        for j in range(i+1,N+1):
            if count==0:
                exit()
            print(i,j)
            count-=1
