
N, K = map(int, input().split())
res = (N - 1) * (N - 2) // 2 - K

if res < 0:
    print(-1)
else:
    ans = []
    for i in range(2, N + 1):
        ans.append([1, i])

    cnt = 0
    for i in range(2, N):
        if cnt == res:
            break

        for j in range(i + 1, N + 1):
            if cnt == res:
                break
            ans.append([i, j])
            cnt += 1

    print(len(ans))
    for v in ans:
        print(*v) N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K res = (N - 1) * (N - 2) // 2 - K res (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 res < 0:
    print(-1)
else:
    ans = []
    for i in range(2, N + 1):
        ans.append([1, i])

    cnt = 0
    for i in range(2, N):
        if cnt == res:
            break

        for j in range(i + 1, N + 1):
            if cnt == res:
                break
            ans.append([i, j])
            cnt += 1

    print(len(ans))
    for v in ans:
        print(*v) res < 0 res 0 print(-1) print -1 ans = [] ans [] for i in range(2, N + 1):
        ans.append([1, i])

     i range(2, N + 1) range 2 N + 1 N 1 ans.append([1, i]) ans.append ans append [1, i] 1 i cnt = 0 cnt 0 for i in range(2, N):
        if cnt == res:
            break

        for j in range(i + 1, N + 1):
            if cnt == res:
                break
            ans.append([i, j])
            cnt += 1

     i range(2, N) range 2 N if cnt == res:
            break

         cnt == res cnt res break for j in range(i + 1, N + 1):
            if cnt == res:
                break
            ans.append([i, j])
            cnt += 1

     j range(i + 1, N + 1) range i + 1 i 1 N + 1 N 1 if cnt == res:
                break
             cnt == res cnt res break ans.append([i, j]) ans.append ans append [i, j] i j cnt += 1 cnt 1 print(len(ans)) print len(ans) len ans for v in ans:
        print(*v) v ans print(*v) print *v v K = map(int, input().split()) map(int, input().split()) K res = (N - 1) * (N - 2) // 2 - K (N - 1) * (N - 2) // 2 - K res N, K = map(int, input().split()) map(int, input().split()) N cnt = 0 0 cnt ans = [] [] ans cnt += 1 1 cnt

N, K = map(int, input().split())
res = (N - 1) * (N - 2) // 2 - K

if res < 0:
    print(-1)
else:
    ans = []
    for i in range(2, N + 1):
        ans.append([1, i])

    cnt = 0
    for i in range(2, N):
        if cnt == res:
            break

        for j in range(i + 1, N + 1):
            if cnt == res:
                break
            ans.append([i, j])
            cnt += 1

    print(len(ans))
    for v in ans:
        print(*v)
