Grammy has a big picture with n+1 rows and m+1 columns. Rows are numbered from 1 to n+1 and columns are numbered from 1 to m+1.
Grammy decides to color this picture in a special way. For the i-th row, Grammy will color the leftmost j (1≤j≤m) cells black with probability p_i,j. For the j-th column, Grammy will color the topmost i (1≤i≤n) cells black with probability q_i,j. Operations are independent, and a cell could be colored more than once.
Let us define the beauty value as the number of maximal orthogonally connected regions of the same color. Before Grammy finishes her coloring, she wants to know the expected number of regions on the picture. Please calculate the expected beauty value of the picture for her.
Two cells x and y are in the same orthogonally connected region if and only if they satisfy the following constraints:
The first line contains two integers n and m (1≤n,m≤1000), denoting the size of the picture.
Each of the next n lines contains m integers p_i,j, denoting the probability of painting the leftmost j cells of the i-th row black, modulo 998,244,353. It is guaranteed that the sum of the probabilities in each row is 1.
Each of the next n lines contains m integers q_i,j, denoting the probability of painting the topmost i cells of the j-th column black, modulo 998,244,353. It is guaranteed that the sum of the probabilities in each column is 1.
Output a single integer, denoting the expected beauty value of the picture, modulo 998,244,353.
It can be shown that the answer can be expressed as an irreducible fraction yx, where x and y are integers and y≡0(mod998,244,353). Output the integer equal to x⋅y−1(mod998,244,353). In other words, output such an integer a that 0≤a<998,244,353 and a⋅y≡x(mod998,244,353).
There is only one possible picture in the first example, which is shown as follows. There are 3 maximal orthogonally connected regions in the picture, so the beauty value of the picture is 3.
