Domino Covering
题号:NC243975
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

There is an chessboard, you need to cover it with dominos, each cell should be covered exactly once.

Each possible position of a domino has been given an integer in , the value of a covering pattern is the product of integers on the dominos' positions. Please calculate the sum of values of all covering patterns, modulo 998244353.



输入描述:

For convenience, we use (i,j) to represent the j-th cell on the i-th row of the board.

The first line contains two integers n,m(2 \le n,m \le 300), separated by a space.

For the next n lines, each line contains m-1 integers separated by spaces:
  • In the i-th row, the j-th integer is for the position covering (i,j) and (i,j+1).


For the next n-1 lines, each line contains m integers separated by spaces:
  • In the i-th row, the j-th integer is for the position covering (i,j) and (i+1,j).

输出描述:

An integer, denoting the answer.
示例1

输入

复制
3 2
1
2
3
4 5
6 7

输出

复制
108
示例2

输入

复制
4 5
14 30 86 91
82 73 17 99
40 61 18 37
52 56 98 65
11 25 48 38 50
86 47 29 45 19
43 36 90 65 36

输出

复制
190919724