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 static if(is(T:B)){
		return func(t.y);
	}else static if(is(T:C)){
		return t.z;
	}
}

void main()
{
	writeln(func(*new A));
	writeln(func(*new B));
	writeln(func(*new C));
}