def main():
    N, K = (int(i) for i in input().split())
    if (N-1)*(N-2)//2 < K:
        return print(-1)
    need_reduce = (N-1)*(N-2)//2 - K
    M = (N-1) + need_reduce
    ans = [[1, j] for j in range(2, N+1)]
    i = 2
    while need_reduce > 0:
        j = i+1
        while j <= N and need_reduce > 0:
            ans.append([i, j])
            j += 1
            need_reduce -= 1
        i += 1
    print(M)
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main() def main():
    N, K = (int(i) for i in input().split())
    if (N-1)*(N-2)//2 < K:
        return print(-1)
    need_reduce = (N-1)*(N-2)//2 - K
    M = (N-1) + need_reduce
    ans = [[1, j] for j in range(2, N+1)]
    i = 2
    while need_reduce > 0:
        j = i+1
        while j <= N and need_reduce > 0:
            ans.append([i, j])
            j += 1
            need_reduce -= 1
        i += 1
    print(M)
    for a in ans:
        print(*a) main int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i N, K = (int(i) for i in input().split()) N (int(i) for i in input().split()) K if (N-1)*(N-2)//2 < K:
        return print(-1)
     (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 return print(-1) print(-1) print -1 need_reduce = (N-1)*(N-2)//2 - K need_reduce (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 = (N-1) + need_reduce M (N-1) + need_reduce N-1 N 1 need_reduce [1, j] for j in range(2, N+1) for j in range(2, N+1) j range(2, N+1) range 2 N+1 N 1 for j in range(2, N+1) [1, j] 1 j ans = [[1, j] for j in range(2, N+1)] ans [[1, j] for j in range(2, N+1)] i = 2 i 2 while need_reduce > 0:
        j = i+1
        while j <= N and need_reduce > 0:
            ans.append([i, j])
            j += 1
            need_reduce -= 1
        i += 1
     need_reduce > 0 need_reduce 0 j = i+1 j i+1 i 1 while j <= N and need_reduce > 0:
            ans.append([i, j])
            j += 1
            need_reduce -= 1
         j <= N and need_reduce > 0 j <= N j N need_reduce > 0 need_reduce 0 ans.append([i, j]) ans.append ans append [i, j] i j j += 1 j 1 need_reduce -= 1 need_reduce 1 i += 1 i 1 print(M) print M for a in ans:
        print(*a) a ans print(*a) print *a a if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N, K = (int(i) for i in input().split())
    if (N-1)*(N-2)//2 < K:
        return print(-1)
    need_reduce = (N-1)*(N-2)//2 - K
    M = (N-1) + need_reduce
    ans = [[1, j] for j in range(2, N+1)]
    i = 2
    while need_reduce > 0:
        j = i+1
        while j <= N and need_reduce > 0:
            ans.append([i, j])
            j += 1
            need_reduce -= 1
        i += 1
    print(M)
    for a in ans:
        print(*a) def main():
    N, K = (int(i) for i in input().split())
    if (N-1)*(N-2)//2 < K:
        return print(-1)
    need_reduce = (N-1)*(N-2)//2 - K
    M = (N-1) + need_reduce
    ans = [[1, j] for j in range(2, N+1)]
    i = 2
    while need_reduce > 0:
        j = i+1
        while j <= N and need_reduce > 0:
            ans.append([i, j])
            j += 1
            need_reduce -= 1
        i += 1
    print(M)
    for a in ans:
        print(*a) main
def main():
    N, K = (int(i) for i in input().split())
    if (N-1)*(N-2)//2 < K:
        return print(-1)
    need_reduce = (N-1)*(N-2)//2 - K
    M = (N-1) + need_reduce
    ans = [[1, j] for j in range(2, N+1)]
    i = 2
    while need_reduce > 0:
        j = i+1
        while j <= N and need_reduce > 0:
            ans.append([i, j])
            j += 1
            need_reduce -= 1
        i += 1
    print(M)
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main()
