A Boring Lesson with Four Squares
Time limit1sMemory limit1024 MB
Count the ways to place four non-overlapping squares, one in each corner of an M by N sheet, modulo 1e9+7.
- Level
Medium7 of 10
- Topics
- Math, Combinatorics
- Solved
- No attempts yet
Problem
Juku is bored in class, so he draws squares on graph paper. To be exact, he draws exactly four squares on every sheet, one in each corner of the sheet. The squares may not overlap each other (but they may touch). Juku tries to draw the squares so that each result differs from all the previous ones. How many sheets of paper can he use up this way?
Input
The only line of the input file contains two integers and (, ), the dimensions of Juku's graph paper.
Output
The only line of the output file contains one integer: the number of ways to draw four non-overlapping squares. The number of ways may be large, and Juku's notebook is very thick, so print the answer modulo .