Katappa vs Bahubali

Why did Kattapa killed Bahubali ? Is this question even relevant. The following is what actually happened that fateful day. Kattapa and Bahubali had a fight. At the start of the fight both kattapa and bahubali had same life. Both of them had same set of three attacks with intensities 2, 5, 7. The intensity is equal the damage done to the life of the opponent and life lost by the attacker. Same intensity attack can be done any number of times. Given Kattapa hits first and a given energy or life(they are equal). The one whose life reduces to 1 or 0 loses. So, Find out who wins?

Note: Assume they attack each other optimally and turn wise, in each turn they will attack only once then other player will attack. Last man attacking wins the fight.

precompute winner for all numbers (LIFE) upto 100000

idea is simple that if its katappa’s turn and life is X and if any {X-2,X-5,X-7} lead to loss of Bahubali
Then katappa wins else bahubali