CF1237F Balanced Domino Placements

Description

Consider a square grid with $ h $ rows and $ w $ columns with some dominoes on it. Each domino covers exactly two cells of the grid that share a common side. Every cell is covered by at most one domino. Let's call a placement of dominoes on the grid perfectly balanced if no row and no column contains a pair of cells covered by two different dominoes. In other words, every row and column may contain no covered cells, one covered cell, or two covered cells that belong to the same domino. You are given a perfectly balanced placement of dominoes on a grid. Find the number of ways to place zero or more extra dominoes on this grid to keep the placement perfectly balanced. Output this number modulo $ 998\,244\,353 $ .

Input Format

N/A

Output Format

N/A

Explanation/Hint

In the first example, the initial grid looks like this: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1237F/23d2c7832fa87b26433f4443e57f8a2c61335a78.png) Here are $ 8 $ ways to place zero or more extra dominoes to keep the placement perfectly balanced: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1237F/f39e74c5e6c5abc41daa487ad47333c83b2084c2.png) In the second example, the initial grid looks like this: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1237F/7739b264ee73fb643402600eb5d0f9454c11a61d.png) No extra dominoes can be placed here.