N-beat

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

문제

N-beat is a popular rhythm arcade game, in which you push buttons arranged in a x×yx \times y grid. The buttons light up when you have to push them; you have to push them with precise timing to get scores.

One game of N-beat consists of one or more screens. A screen is a configuration of lit buttons which you have to push.

For example, the picture above shows 44 successive screens for a N-beat machine with 4×44 \times 4 grid. Here, boxes with the target mark are the lit buttons you have to press.

A sequence of screens in a game is called a transcription.

Now, Jaeha Koo, a genius composer, just made a new song for N-beat. You’re going to make transcription for this song.

There are BB beats in this song, so this transcription will consist of BB screens. Therefore, without any restriction, there are a total of (2xy)B(2^{xy})^B possible transcriptions.

But transcriptions differ in difficulty. Generally, you can push one button with one finger, so it’s harder when a single screen has more lit buttons. Especially, if a screen has more than 1010 lit buttons, it’s very difficult to push them successfully. Also, adjacent screens having a lot of lit buttons can also can make the game difficult. For example, two successive screens with 77 and 66 lit buttons each might be more difficult than two screens with 22 and 88 lit buttons each.

As a generous transcriptor, you decided to limit the number of lit buttons. The limit is given as three nonnegative integers: p_1p\_1, p_2p\_2, and p_3p\_3. p_1p\_1 is the maximum number of lit buttons you can have in any one screen. p_2p\_2 is the maximum number of lit buttons you can have in any two consecutive screens. Also, as you guessed, p_3p\_3 is the maximum number of lit buttons you can have in any three consecutive screens. In the picture above, 44 screens each have 44, 88, 66, 88 of turned-on buttons, so this transcription will only be valid if p_18p\_1 ≥ 8, p_214p\_2 ≥ 14, and p_322p\_3 ≥ 22.

Your task is to calculate the number of possible transcriptions given xx, yy, BB, p_1p\_1, p_2p\_2 and p_3p\_3. As the result can be quite huge, just calculate the answer mod 109+710^9 + 7.

입력

The input consists of TT test cases. The first line of the input contains TT.

Each test case starts with 66 integers xx, yy (1x,y10001 ≤ x, y ≤ 1000), BB (1B1091 ≤ B ≤ 10^9), p_1p\_1 (0p_1100 ≤ p\_1 ≤ 10), p_2p\_2 (0p_2200 ≤ p\_2 ≤ 20), p_3p\_3 (0p_3300 ≤ p\_3 ≤ 30) separated by a whitespace.

출력

For each test case, print the number of possible transcriptions mod 109+710^9 + 7, in a single line.