# K <= N(N-1)//2 - (N-1)
#    = (N-1)(N-2)//2

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

if K > (N - 1) * (N - 2) // 2:
    print(-1)
else:
    M1 = N - 1
    M2 = (N - 1) * (N - 2) // 2 - K
    M = M1 + M2

    print(M)
    for i in range(1, N):
        print(N, i)
    m = 0
    for i in range(1, N):
        for j in range(i + 1, N):
            if m < M2:
                print(i, j)
                m += 1
            else:
                break
        if m == M2:
            break N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K if K > (N - 1) * (N - 2) // 2:
    print(-1)
else:
    M1 = N - 1
    M2 = (N - 1) * (N - 2) // 2 - K
    M = M1 + M2

    print(M)
    for i in range(1, N):
        print(N, i)
    m = 0
    for i in range(1, N):
        for j in range(i + 1, N):
            if m < M2:
                print(i, j)
                m += 1
            else:
                break
        if m == M2:
            break 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 M1 = N - 1 M1 N - 1 N 1 M2 = (N - 1) * (N - 2) // 2 - K M2 (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 M = M1 + M2 M M1 + M2 M1 M2 print(M) print M for i in range(1, N):
        print(N, i)
     i range(1, N) range 1 N print(N, i) print N i m = 0 m 0 for i in range(1, N):
        for j in range(i + 1, N):
            if m < M2:
                print(i, j)
                m += 1
            else:
                break
        if m == M2:
            break i range(1, N) range 1 N for j in range(i + 1, N):
            if m < M2:
                print(i, j)
                m += 1
            else:
                break
         j range(i + 1, N) range i + 1 i 1 N if m < M2:
                print(i, j)
                m += 1
            else:
                break
         m < M2 m M2 print(i, j) print i j m += 1 m 1 break if m == M2:
            break m == M2 m M2 break m += 1 1 m N, K = map(int, input().split()) map(int, input().split()) N M = M1 + M2 M1 + M2 M M2 = (N - 1) * (N - 2) // 2 - K (N - 1) * (N - 2) // 2 - K M2 K = map(int, input().split()) map(int, input().split()) K m = 0 0 m M1 = N - 1 N - 1 M1
# K <= N(N-1)//2 - (N-1)
#    = (N-1)(N-2)//2

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

if K > (N - 1) * (N - 2) // 2:
    print(-1)
else:
    M1 = N - 1
    M2 = (N - 1) * (N - 2) // 2 - K
    M = M1 + M2

    print(M)
    for i in range(1, N):
        print(N, i)
    m = 0
    for i in range(1, N):
        for j in range(i + 1, N):
            if m < M2:
                print(i, j)
                m += 1
            else:
                break
        if m == M2:
            break
