5. What is the output of the following C++ program?

#include <exception>
#include <iostream>

class A
{
public:
    virtual ~A() { }
};

class B
    : public A
{
};

class C
    : public A
{
};

int main()
{
    try {
        B b;
        C c;
        A *pa1 = &b, *pa2 = &c;

        std::cout << ((dynamic_cast<B*>(pa1) != nullptr) ? 1 : 0);
        std::cout << ((dynamic_cast<B*>(pa2) != nullptr) ? 1 : 0);

        B &b1 = dynamic_cast<B&>(*pa2);
        pa1 = &b1;

        std::cout << ((static_cast<C*>(pa1) != nullptr) ? 1 : 0);
    }
    catch(const std::exception &) {
            std::cout << 2;
    }

    std::cout << std::endl;

    return 0;
}