#include <iostream>
struct A {
void Foo() { std::cout << "foo" << std::endl; }
};
struct B {
A* operator->() { return &a; }
A a;
};
struct C {
B& operator->() { return b; }
B b;
};
struct D {
C& operator->() { return c; }
C c;
};
int main()
{
D d;
d->Foo();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IEEgewogICAgdm9pZCBGb28oKSB7IHN0ZDo6Y291dCA8PCAiZm9vIiA8PCBzdGQ6OmVuZGw7IH0KfTsKCnN0cnVjdCBCIHsKICAgIEEqIG9wZXJhdG9yLT4oKSB7IHJldHVybiAmYTsgfQogICAgQSBhOwp9OwoKc3RydWN0IEMgewogICAgQiYgb3BlcmF0b3ItPigpIHsgcmV0dXJuIGI7IH0KICAgIEIgYjsKfTsKCnN0cnVjdCBEIHsKICAgIEMmIG9wZXJhdG9yLT4oKSB7IHJldHVybiBjOyB9CiAgICBDIGM7Cn07CgppbnQgbWFpbigpCnsKICAgIEQgZDsKICAgIGQtPkZvbygpOwp9Cg==