#include <iostream>
#include <utility>
class Bar;
class Foo
{
    Bar& refBar;
public:
    int n;
    Foo(Bar& refBar) : refBar(refBar), n(1) {}
    void show() const;
};

class Bar
{
    Foo& refFoo;
public:
    int n;
    Bar(Foo& refFoo) : refFoo(refFoo), n(2) {}
    void show() const;
};

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

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

int main()
{
    std::pair<Foo, Bar> p(p.second, p.first);
    p.first.show();
    p.second.show();
}
