#include <iostream>
#include <utility>
struct A;
struct B
{
    A& ref;
    int n;
    void show() const;
};

struct A
{
    B& ref;
    int n;
    void show() const;
};

void A::show() const
{
    std::cout << "A.n is " << n
              << " A.ref.n is " << ref.n
              << " A.ref.ref.n is " << ref.ref.n
              << " A.ref.ref.ref.n is " << ref.ref.ref.n
              << '\n';
}

void B::show() const
{
    std::cout << "B.n is " << n
              << " B.ref.n is " << ref.n
              << " B.ref.ref.n is " << ref.ref.n
              << " B.ref.ref.ref.n is " << ref.ref.ref.n
              << '\n';
}

int main()
{
    struct {A first; B second;} pair = {{pair.second, 2}, {pair.first, 1}};
    pair.first.show();
    pair.second.show();
}
