N, K = map(int, input().split())

amax = (N-1)*(N-2)//2
if amax-K>=0:
    print(amax-K+N-1)
    for i in range(N-1):
        print(1, i+2)
    cnt = 0

    def out(x):
        cnt = 0
        for i in range(2, N+1):
            for j in range(i+1, N+1):
                if cnt == amax-K:
                    return
                print(i, j)
                cnt += 1
    out(amax-K)
else:
    print(-1) N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K amax = (N-1)*(N-2)//2 amax (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 if amax-K>=0:
    print(amax-K+N-1)
    for i in range(N-1):
        print(1, i+2)
    cnt = 0

    def out(x):
        cnt = 0
        for i in range(2, N+1):
            for j in range(i+1, N+1):
                if cnt == amax-K:
                    return
                print(i, j)
                cnt += 1
    out(amax-K)
else:
    print(-1) amax-K>=0 amax-K amax K 0 print(amax-K+N-1) print amax-K+N-1 amax-K+N amax-K amax K N 1 for i in range(N-1):
        print(1, i+2)
     i range(N-1) range N-1 N 1 print(1, i+2) print 1 i+2 i 2 cnt = 0 cnt 0 def out(x):
        cnt = 0
        for i in range(2, N+1):
            for j in range(i+1, N+1):
                if cnt == amax-K:
                    return
                print(i, j)
                cnt += 1
     out cnt = 0 cnt 0 for i in range(2, N+1):
            for j in range(i+1, N+1):
                if cnt == amax-K:
                    return
                print(i, j)
                cnt += 1
     i range(2, N+1) range 2 N+1 N 1 for j in range(i+1, N+1):
                if cnt == amax-K:
                    return
                print(i, j)
                cnt += 1
     j range(i+1, N+1) range i+1 i 1 N+1 N 1 if cnt == amax-K:
                    return
                 cnt == amax-K cnt amax-K amax K return print(i, j) print i j cnt += 1 cnt 1 x x out(amax-K) out amax-K amax K print(-1) print -1 cnt = 0 0 cnt def out(x):
        cnt = 0
        for i in range(2, N+1):
            for j in range(i+1, N+1):
                if cnt == amax-K:
                    return
                print(i, j)
                cnt += 1
     def out(x):
        cnt = 0
        for i in range(2, N+1):
            for j in range(i+1, N+1):
                if cnt == amax-K:
                    return
                print(i, j)
                cnt += 1
     out K = map(int, input().split()) map(int, input().split()) K N, K = map(int, input().split()) map(int, input().split()) N amax = (N-1)*(N-2)//2 (N-1)*(N-2)//2 amax
N, K = map(int, input().split())

amax = (N-1)*(N-2)//2
if amax-K>=0:
    print(amax-K+N-1)
    for i in range(N-1):
        print(1, i+2)
    cnt = 0

    def out(x):
        cnt = 0
        for i in range(2, N+1):
            for j in range(i+1, N+1):
                if cnt == amax-K:
                    return
                print(i, j)
                cnt += 1
    out(amax-K)
else:
    print(-1)