AtCoder Beginner Contest 295
Ex
E or m
AtCoder
⌀ 2728
原题
←G →
翻译中…

Problem Statement

翻译中…

We have a grid $A$ with $N$ rows and $M$ columns. Initially, $0$ is written on every square. Let us perform the following operation.

翻译中…
  • For each integer $i$ such that $1 \le i \le N$, in the $i$-th row, turn the digits in zero or more leftmost squares into $1$.
  • For each integer $j$ such that $1 \le j \le M$, in the $j$-th column, turn the digits in zero or more topmost squares into $1$.
翻译中…

Let $S$ be the set of grids that can be obtained in this way.

翻译中…

You are given a grid $X$ with $N$ rows and $M$ columns consisting of 0, 1, and ?. There are $2^q$ grids that can be obtained by replacing each ? with 0 or 1, where $q$ is the number of ? in $X$. How many of them are in $S$? This count can be enormous, so find it modulo $998244353$.

翻译中…

Constraints

翻译中…
  • $N$ and $M$ are integers.
  • $1 \le N,M \le 18$
  • $X$ is a grid with $N$ rows and $M$ columns consisting of 0, 1, and ?.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N M
X_{1,1} X_{1,2} \dots X_{1,M}
X_{2,1} X_{2,2} \dots X_{2,M}
\vdots
X_{N,1} X_{N,2} \dots X_{N,M}

翻译中…

Output

翻译中…

Print an integer representing the answer.

翻译中…

样例

Input #1
2 3
0?1
?1?
Output #1
6
The following six grids are in $S$.
Input #2
5 3
101
010
101
010
101
Output #2
0
$X$ may have no `?`, and the answer may be $0$.
Input #3
18 18
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
Output #3
462237431
Be sure to find the count modulo $998244353$.
题目信息
题号
abc295_h
时间限制
4 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。