f(a,b){return b?(b&1)*a^f(a*2,b/2):0;}
void test_case(int a, int b, int ab) {
int t = f(a,b);
if (t != ab) {
printf("Error! Test case %d @ %d = %d, but f(%d, %d) = %d\n", a
, b
, ab
, a
, b
, t
); }
else {
printf("%d @ %d = %d\n", a
, b
, t
); }
}
int main() {
test_case(0, 1, 0);
test_case(1, 2, 2);
test_case(9, 0, 0);
test_case(6, 1, 6);
test_case(3, 3, 5);
test_case(2, 5, 10);
test_case(7, 9, 63);
test_case(13, 11, 127);
test_case(5, 17, 85);
test_case(14, 13, 70);
test_case(19, 1, 19);
test_case(63, 63, 1365);
return 0;
}
ZihhLGIpe3JldHVybiBiPyhiJjEpKmFeZihhKjIsYi8yKTowO30KCgoKdm9pZCB0ZXN0X2Nhc2UoaW50IGEsIGludCBiLCBpbnQgYWIpIHsKICAgIGludCB0ID0gZihhLGIpOwogICAgCiAgICBpZiAodCAhPSBhYikgewogICAgICAgIHByaW50ZigiRXJyb3IhIFRlc3QgY2FzZSAlZCBAICVkID0gJWQsIGJ1dCBmKCVkLCAlZCkgPSAlZFxuIiwgYSwgYiwgYWIsIGEsIGIsIHQpOwogICAgfQogICAgZWxzZSB7CiAgICAgICAgcHJpbnRmKCIlZCBAICVkID0gJWRcbiIsIGEsIGIsIHQpOwogICAgfQp9CgppbnQgbWFpbigpIHsKICAgIHRlc3RfY2FzZSgwLCAxLCAwKTsKICAgIHRlc3RfY2FzZSgxLCAyLCAyKTsKICAgIHRlc3RfY2FzZSg5LCAwLCAwKTsKICAgIHRlc3RfY2FzZSg2LCAxLCA2KTsKICAgIHRlc3RfY2FzZSgzLCAzLCA1KTsKICAgIHRlc3RfY2FzZSgyLCA1LCAxMCk7CiAgICB0ZXN0X2Nhc2UoNywgOSwgNjMpOwogICAgdGVzdF9jYXNlKDEzLCAxMSwgMTI3KTsKICAgIHRlc3RfY2FzZSg1LCAxNywgODUpOwogICAgdGVzdF9jYXNlKDE0LCAxMywgNzApOwogICAgdGVzdF9jYXNlKDE5LCAxLCAxOSk7CiAgICB0ZXN0X2Nhc2UoNjMsIDYzLCAxMzY1KTsKICAgIHJldHVybiAwOwp9