you bag contain n card there number write card number ith card a_iYou play follow game during turn choose remove random card bag card leave inside bag choose equiprobably nothing happen turn turn remove card let number x compare card remove previous turn let number y possible outcome x y game end lose x y game end win x y game continue if card leave bag lose Cards return bag remove themyou calculate probability win game it show form fracpq p Q nonnegative integer Q neq 0 p le Q Output value p cdot Q1 mod 998244353