QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100

#3738. Building a House

統計

Bobo bought an $n \times m$ plot of land at ICPCCamp, where some cells are obstacles.

He wants to select two rectangular areas to build two houses. Obviously, the areas used for building houses cannot contain any obstacles. Furthermore, the two areas cannot intersect (though they may be adjacent).

Bobo wants to know the number of all possible distinct schemes modulo $(10^9 + 7)$.

Input

The input contains no more than 10 test cases.

The first line of each test case contains two integers $n, m$ ($1 \leq n, m \leq 10^3$).

The next $n$ lines each contain a string $s_i$ of length $m$. The $j$-th character of $s_i$ is 0 if the cell at the $i$-th row and $j$-th column is empty, and 1 if the cell is an obstacle.

Output

For each test case, output an integer representing the required value.

Examples

Input 1

2 2
00
01

Output 1

5

Input 2

3 4
1000
0001
0100

Output 2

160

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.