#include <cstdio>
#include <utility>
using namespace std;
struct Heavy
{
Heavy() { printf("h "); }
Heavy(const Heavy&) { printf("H "); }
};
template<int N, class... Args> struct getter;
template<class A, class... Args> struct getter<0,A,Args...>
{
typedef A type;
static type const& get(A const& a, Args&&...) { printf("0 "); return a; }
};
template<int N, class A, class... Args> struct getter<N,A,Args...>
{
typedef getter<N-1,Args...> base;
typedef typename base::type type;
static type const& get(A const& a, Args&&... args)
{
printf("%d ", N);
return base::get(forward<Args>(args)...);
}
};
template<int N, class... Args>
typename getter<N,Args...>::type const&
get(Args&&... args)
{
printf("go ");
return getter<N,Args...>::get(forward<Args>(args)...);
}
int main()
{
get<4>(0,1,2,3,4, Heavy(), 6,7,8,9);
printf("\n");
get<5>(0,1,2,3,4, Heavy(), 6,7,8,9);
printf("\n");
get<9>(0,1,2,3,4, Heavy(), 6,7,8,9);
printf("\n");
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPHV0aWxpdHk+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IEhlYXZ5CnsKICAgIEhlYXZ5KCkgeyBwcmludGYoImggIik7IH0KICAgIEhlYXZ5KGNvbnN0IEhlYXZ5JikgeyBwcmludGYoIkggIik7IH0KfTsKCnRlbXBsYXRlPGludCBOLCBjbGFzcy4uLiBBcmdzPiBzdHJ1Y3QgZ2V0dGVyOwp0ZW1wbGF0ZTxjbGFzcyBBLCBjbGFzcy4uLiBBcmdzPiBzdHJ1Y3QgZ2V0dGVyPDAsQSxBcmdzLi4uPgp7CiAgICB0eXBlZGVmIEEgdHlwZTsKICAgIHN0YXRpYyB0eXBlIGNvbnN0JiBnZXQoQSBjb25zdCYgYSwgQXJncyYmLi4uKSB7IHByaW50ZigiMCAiKTsgcmV0dXJuIGE7IH0KfTsKdGVtcGxhdGU8aW50IE4sIGNsYXNzIEEsIGNsYXNzLi4uIEFyZ3M+IHN0cnVjdCBnZXR0ZXI8TixBLEFyZ3MuLi4+CnsKICAgIH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