import std.stdio;
struct A{int x;}
struct B{C y;}
struct C{int z;}
int func(T)(T t){
static if(is(T:A)){
return t.x;
}else if(is(T:B)){
return func(t.y);
}else if(is(T:C)){
return t.z;
}
}
void main()
{
writeln(func(new A));
writeln(func(new B));
writeln(func(new C));
}
aW1wb3J0IHN0ZC5zdGRpbzsKCnN0cnVjdCBBe2ludCB4O30Kc3RydWN0IEJ7QyB5O30Kc3RydWN0IEN7aW50IHo7fQoKaW50IGZ1bmMoVCkoVCB0KXsKCXN0YXRpYyBpZihpcyhUOkEpKXsKCQlyZXR1cm4gdC54OwoJfWVsc2UgaWYoaXMoVDpCKSl7CgkJcmV0dXJuIGZ1bmModC55KTsKCX1lbHNlIGlmKGlzKFQ6QykpewoJCXJldHVybiB0Lno7Cgl9Cn0KCnZvaWQgbWFpbigpCnsKCXdyaXRlbG4oZnVuYyhuZXcgQSkpOwoJd3JpdGVsbihmdW5jKG5ldyBCKSk7Cgl3cml0ZWxuKGZ1bmMobmV3IEMpKTsKfQ==