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

if K > (N - 1) * (N - 2) // 2:
    print(-1)
else:
    M = N * (N - 1) // 2 - K
    cnt = 0
    ans = []
    for i in range(N - 1):
        for j in range(i + 1, N):
            ans.append((i + 1, j + 1))
            cnt += 1
            if M == cnt:
                break
        else:
            continue
        break
    print(M)
    for edge in ans:
        print(*edge) 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:
    M = N * (N - 1) // 2 - K
    cnt = 0
    ans = []
    for i in range(N - 1):
        for j in range(i + 1, N):
            ans.append((i + 1, j + 1))
            cnt += 1
            if M == cnt:
                break
        else:
            continue
        break
    print(M)
    for edge in ans:
        print(*edge) 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 M = N * (N - 1) // 2 - K M N * (N - 1) // 2 - K N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 K cnt = 0 cnt 0 ans = [] ans [] for i in range(N - 1):
        for j in range(i + 1, N):
            ans.append((i + 1, j + 1))
            cnt += 1
            if M == cnt:
                break
        else:
            continue
        break
     i range(N - 1) range N - 1 N 1 for j in range(i + 1, N):
            ans.append((i + 1, j + 1))
            cnt += 1
            if M == cnt:
                break
        else:
            continue
         j range(i + 1, N) range i + 1 i 1 N ans.append((i + 1, j + 1)) ans.append ans append (i + 1, j + 1) i + 1 i 1 j + 1 j 1 cnt += 1 cnt 1 if M == cnt:
                break
         M == cnt M cnt break continue break print(M) print M for edge in ans:
        print(*edge) edge ans print(*edge) print *edge edge cnt += 1 1 cnt K = map(int, input().split()) map(int, input().split()) K cnt = 0 0 cnt N, K = map(int, input().split()) map(int, input().split()) N M = N * (N - 1) // 2 - K N * (N - 1) // 2 - K M ans = [] [] ans
N, K = map(int, input().split())

if K > (N - 1) * (N - 2) // 2:
    print(-1)
else:
    M = N * (N - 1) // 2 - K
    cnt = 0
    ans = []
    for i in range(N - 1):
        for j in range(i + 1, N):
            ans.append((i + 1, j + 1))
            cnt += 1
            if M == cnt:
                break
        else:
            continue
        break
    print(M)
    for edge in ans:
        print(*edge)
