LaLa and Magic Stone

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

One day, LaLa\color{blue}{\text{LaLa}} realized that she ran out of magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} stone components for her magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} tools. (Think of them as a battery in our world.) So LaLa\color{blue}{\text{LaLa}} rushed to a nearby store and bought a slab of magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} stone.

LaLa\color{blue}{\text{LaLa}} wants to cut the slab into magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} stone components. The slab consists of N×MN \times M cells. Unfortunately, some cells are incompatible with LaLa\color{blue}{\text{LaLa}}'s magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} tools.

The required magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} stone component is a 7-cell U-shaped piece.

As LaLa\color{blue}{\text{LaLa}} forgot to buy magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} stone glue, LaLa\color{blue}{\text{LaLa}} can't merge smaller pieces to form the required shape.

Furthermore, since LaLa\color{blue}{\text{LaLa}} hates wasting magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} stones, LaLa\color{blue}{\text{LaLa}} will be satisfied if and only if the slab is cut so that every single compatible cell belongs to a required shape.

Write a program that computes the number of ways to cut the slab so that LaLa\color{blue}{\text{LaLa}} is satisfied, modulo 998,244,353998\\,244\\,353. Two ways to cut pieces are different if and only if there exist two compatible cells such that they belong to the same piece in one and to different pieces in the other.

입력

The input is given in the following format:

NN MM

S_0S\_0

S_1S\_1

\vdots

S_N1S\_{N-1}

where NN is the number of rows of the slab, MM is the number of columns, and S_iS\_i is a binary string of length MM where jj-th character is '1' if and only if the cell at the ii-th row from the top and jj-th column from the left is incompatible.

The input satisfies the following constraints:

  • NN and MM are integers.
  • 3N,M1,0003 \le N, M \le 1\\,000

출력

The output should be a integer equal to the number of ways to cut the slab so that LaLa\color{blue}{\text{LaLa}} is satisfied, modulo 998,244,353998\\,244\\,353.

힌트

The following illustrates two possible ways to cut the slab in the first sample.

The following illustrates the only way to cut the slab in the second sample.