#include <stdio.h>
int foo(int x, int y, int q)
{ if ((x<=0) || (y<=0)) return q;
if (x<=1) return foo(x, y+q, q);
if (y<=2) return foo(x+q, y, q);
return foo(x, y-q, q) + foo(x-q, y, q); }
int main( )
{ int r = foo(12, 9, 7);
return 0;}
I2luY2x1ZGUgPHN0ZGlvLmg+CiAgICAgIAkgICBpbnQgZm9vKGludCB4LCBpbnQgeSwgaW50IHEpIAogICAgeyAgIGlmICgoeDw9MCkgfHwgKHk8PTApKQkgICAgICAgIHJldHVybiBxOwogICAgICAgIGlmICh4PD0xKQkJICAgICAgICByZXR1cm4gZm9vKHgsIHkrcSwgcSk7CiAgICAgICAgaWYgKHk8PTIpCQkgICAgICAgIHJldHVybiBmb28oeCtxLCB5LCBxKTsJCQogICAgICAgIHJldHVybiBmb28oeCwgeS1xLCBxKSArIGZvbyh4LXEsIHksIHEpOyAgICAgfQppbnQgbWFpbiggKQp7ICAgICBpbnQgciA9IGZvbygxMiwgOSwgNyk7CiAgICBwcmludGYoIiVkIiwgcik7CiAgICByZXR1cm4gMDt9IAo=