#include <iostream>
#include <memory>
using namespace std;

struct A {
	weak_ptr<A> Next;
	~A(){ cout << "deleted" << endl; }
};

void Foo() 
{
  auto a1 = make_shared<A>();
  auto a2 = make_shared<A>();
  a1->Next = a2;
  a2->Next = a1;
}

int main() {
	Foo();
	// your code goes here
	return 0;
}