Two players A and B are playing a game called mukjjippa.
The game consists of several turns.
At the $i$-th turn ($1\le i\le n$):
Note that there is no attacker for the first turn.
If the game does not end until the beginning of the $(n+1)$-th turn, nobody is a winner.
The probability distribution of each choice is given. All choices are independent.
Find the probability that A wins.
The first line contains an integer $n$.
The $i$-th of the next $n$ lines contains three integers $r_i$, $s_i$, and $p_i$. This means that the probabilities that $X_i$ is $\mathrm R$, $\mathrm S$, and $\mathrm P$ are $\frac{r_i}{r_i+s_i+p_i}$, $\frac{s_i}{r_i+s_i+p_i}$, and $\frac{p_i}{r_i+s_i+p_i}$, respectively.
The $i$-th of the next $n$ lines contains three integers $r_i'$, $s_i'$, and $p_i'$. This means that the probabilities that $Y_i$ is $\mathrm R$, $\mathrm S$, and $\mathrm P$ are $\frac{r_i'}{r_i'+s_i'+p_i'}$, $\frac{s_i'}{r_i'+s_i'+p_i'}$, and $\frac{p_i'}{r_i'+s_i'+p_i'}$, respectively.
Let $\frac{x}{y}$ be the probability that A wins, where $x$ and $y$ are coprime integers, and $x\ge 0$ and $y>0$.
Print the integer $z$ such that $yz\equiv x\pmod{998\, 244\, 353}$ and $0\le z<998\, 244\, 353$.
It can be proved that such an integer $z$ always exists and is uniquely determined, under the constraints of this problem.