Problem Statement
Ciel is going to perform the following operation twice. The operation starts with Ciel choosing a subrectangle of the board. The dimensions of the subrectangle have to be sx times sy, and the side with length sx has to be parallel to the side of the board with length X. Once the subrectangle is chosen, Ciel presses some of the panels it contains (possibly none at all or all of them).
The following figures show an example of these operations for X = 5, Y = 4, sx = 3, and sy = 2. The picture on the left shows the initial board, the picture in the middle shows the board after the first operation, and the picture on the right shows the board after the second operation.

Compute and return the number of different patterns Ciel can have after finishing the two operations, modulo 1,000,000,007.
Definition
- Class:
- LitPanels
- Method:
- countPatterns
- Parameters:
- int, int, int, int
- Returns:
- int
- Method signature:
- int countPatterns(int X, int Y, int sx, int sy)
- (be sure your method is public)
Constraints
- X will be between 1 and 40, inclusive.
- Y will be between 1 and 40, inclusive.
- sx will be between 1 and X, inclusive.
- sy will be between 1 and Y, inclusive.
Examples
2
2
1
1
Returns: 11
All patterns with at most two lit panels are possible. The number of such patterns is C(4, 0) + C(4, 1) + C(4, 2) = 11, where C denotes binomial coefficients.
2
3
1
2
Returns: 40
The following picture shows all 40 possible patterns.
4
4
3
2
Returns: 14096
40
39
5
8
Returns: 877713074
39
30
19
6
Returns: 910646629
33
38
18
37
Returns: 194248776
39
38
5
27
Returns: 672204430
11
28
3
14
Returns: 976102091
28
11
11
10
Returns: 845166142
24
31
20
16
Returns: 51434886
23
31
11
9
Returns: 441644622
39
34
16
13
Returns: 637898925
22
39
20
5
Returns: 388324708
23
32
6
22
Returns: 105718060
23
20
4
5
Returns: 120935308
22
13
20
8
Returns: 344015095
22
37
13
3
Returns: 157424773
13
14
1
4
Returns: 734722
32
20
24
11
Returns: 581156206
35
24
22
9
Returns: 354411196
40
35
8
14
Returns: 570868936
19
40
18
32
Returns: 34849280
10
27
7
16
Returns: 363338153
24
33
10
24
Returns: 432650652
40
40
1
1
Returns: 1280801
40
40
1
10
Returns: 17478937
40
40
1
30
Returns: 255128517
40
40
1
40
Returns: 717566518
40
40
10
1
Returns: 17478937
40
40
10
10
Returns: 604269258
40
40
10
30
Returns: 81588147
40
40
10
40
Returns: 51702122
40
40
30
1
Returns: 255128517
40
40
30
10
Returns: 81588147
40
40
30
30
Returns: 930255495
40
40
30
40
Returns: 592352867
40
40
40
1
Returns: 717566518
40
40
40
10
Returns: 51702122
40
40
40
30
Returns: 592352867
40
40
40
40
Returns: 592352867
1
1
1
1
Returns: 2
1
40
1
10
Returns: 66584576
1
40
1
30
Returns: 511620083
40
1
10
1
Returns: 66584576
40
1
30
1
Returns: 511620083
40
40
13
13
Returns: 464067811