pii comb(pii a, pii b) {
/* {the number that remains, count of the number} */
if (a.f == b.f) { return mp(a.f, a.s+b.s); }
if (a.s > b.s) {
return mp(a.f, a.s-b.s);
}
return mp(b.f, b.s-a.s);
}
cGlpIGNvbWIocGlpIGEsIHBpaSBiKSB7CgkvKiB7dGhlIG51bWJlciB0aGF0IHJlbWFpbnMsIGNvdW50IG9mIHRoZSBudW1iZXJ9ICovCiAgICBpZiAoYS5mID09IGIuZikgeyByZXR1cm4gbXAoYS5mLCBhLnMrYi5zKTsgfQogICAgaWYgKGEucyA+IGIucykgewogICAgICAgIHJldHVybiBtcChhLmYsIGEucy1iLnMpOwogICAgfQogICAgcmV0dXJuIG1wKGIuZiwgYi5zLWEucyk7Cn0KCg==