Nemmo Nemmo (Hard)
Time limit2sMemory limit512 MB
Count subsets of occupied cells in an N by M grid (N times M at most 300) that contain no full 2 by 2 square, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Bit manipulation, Combinatorics, Matrix
- Solved
- No attempts yet
Problem
Nemo liked falling block puzzle games so much that he built one of his own, Nemmo Nemmo, played on a rectangular grid with a mysterious creature called a nemmo. The rules are short. Pick any empty cell of the grid and put one nemmo on it, or find four occupied cells that form a square and remove every nemmo on them. Repeat one of the two moves until you get bored.

The game turned out to be no fun at all, and Nemo got bored very quickly. Disappointed, he played for a while and decided to quit the moment he wants to remove nemmos but the grid holds no removable nemmo. Count the arrangements of nemmos that can be on the grid when Nemo quits.
Input
The first line contains the number of rows and the number of columns of the grid, separated by a space. (, )
Output
Print on the first line the number of arrangements on the given grid in which the occupied cells form no square anywhere, modulo .
Hint
On a grid, only one of the arrangements is excluded, the one that fills all four cells, so the answer is 15.
On a grid, 11,185,495,872 arrangements satisfy the condition.