#ABC295H. [ABC295Ex] E or m

[ABC295Ex] E or m

Score : 600600 points

Problem Statement

We have a grid AA with NN rows and MM columns. Initially, 00 is written on every square. Let us perform the following operation.

  • For each integer ii such that 1iN1 \le i \le N, in the ii-th row, turn the digits in zero or more leftmost squares into 11.
  • For each integer jj such that 1jM1 \le j \le M, in the jj-th column, turn the digits in zero or more topmost squares into 11.

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

You are given a grid XX with NN rows and MM columns consisting of 0, 1, and ?. There are 2q2^q grids that can be obtained by replacing each ? with 0 or 1, where qq is the number of ? in XX. How many of them are in SS? This count can be enormous, so find it modulo 998244353998244353.

Constraints

  • NN and MM are integers.
  • 1N,M181 \le N,M \le 18
  • XX is a grid with NN rows and MM columns consisting of 0, 1, and ?.

Input

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

NN MM

X1,1X1,2X1,MX_{1,1} X_{1,2} \dots X_{1,M}

X2,1X2,2X2,MX_{2,1} X_{2,2} \dots X_{2,M}

\vdots

XN,1XN,2XN,MX_{N,1} X_{N,2} \dots X_{N,M}

Output

Print an integer representing the answer.

2 3
0?1
?1?
6

The following six grids are in SS.

011  011  001
010  011  110

001  011  011
111  110  111
5 3
101
010
101
010
101
0

XX may have no ?, and the answer may be 00.

18 18
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
462237431

Be sure to find the count modulo 998244353998244353.