#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 get(A 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 get(A a, Args&&... args)
{
printf("%d ", N);
return base::get(forward<Args>(args)...);
}
};
template<int N, class... Args>
typename getter<N,Args...>::type
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+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IEhlYXZ5CnsKICAgIEhlYXZ5KCkgeyBwcmludGYoImggIik7IH0KICAgIEhlYXZ5KGNvbnN0IEhlYXZ5JikgeyBwcmludGYoIkggIik7IH0KfTsKCnRlbXBsYXRlPGludCBOLCBjbGFzcy4uLiBBcmdzPiBzdHJ1Y3QgZ2V0dGVyOwp0ZW1wbGF0ZTxjbGFzcyBBLCBjbGFzcy4uLiBBcmdzPiBzdHJ1Y3QgZ2V0dGVyPDAsQSxBcmdzLi4uPgp7CiAgICB0eXBlZGVmIEEgdHlwZTsKICAgIHN0YXRpYyB0eXBlIGdldChBIGEsIEFyZ3MmJi4uLikgeyBwcmludGYoIjAgIik7IHJldHVybiBhOyB9Cn07CnRlbXBsYXRlPGludCBOLCBjbGFzcyBBLCBjbGFzcy4uLiBBcmdzPiBzdHJ1Y3QgZ2V0dGVyPE4sQSxBcmdzLi4uPgp7CiAgICB0eXBlZGVmIGdldHRlcjxOLTEsQXJncy4uL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