Tigger's bounces

No attempts yetTime limit1sMemory limit256 MB

Problem

Tigger loves to bounce. Today he spent the whole day in a rectangular field that is RR cells wide and CC cells long.

With one bounce Tigger lands on one of the four cells that share a side with the cell he is on, above, below, left or right, or he lands again on the same cell. He never lands outside the field.

Write down the cells Tigger lands on in order and you get a sequence of length KK. The first landing may be on any cell of the field, and every landing after that follows the rule above. Once Tigger lands for the KKth time, the day's bouncing is over.

Write a program that counts the different ways Tigger can bounce and prints the count modulo PP.

Input

The first line has a positive integer QQ, the number of questions. QQ is at most 1010.

Each of the next QQ lines holds one question: the positive integers RR, CC, KK, PP in that order, separated by single spaces.

1R,C201 \le R, C \le 20, 1K10001 \le K \le 1000, 1P10000001 \le P \le 1000000

Output

Print QQ lines, one answer per question, in the order the questions are given. Each line holds the number of different ways Tigger can bounce, modulo PP.

Hint

Take R=2R = 2, C=2C = 2, K=3K = 3. On a 2×22 \times 2 field every cell has three possible next landings, counting the cell itself. There are four choices for the first cell and three choices for each of the two later bounces, so the count is 4×3×3=364 \times 3 \times 3 = 36.