eolymp
bolt
Try our new interface for solving problems

ZZ

ZZ-function, a shorter name of ZeedZaad-function is defines as followed.

prb6573

Given 4 integers a, b, c and d your task is to find ZZ(c, d).

Input

First line is a number of test cases t (t200).

Each test case is a line containing 4 integers a, b, c and d (0a, b109, 1c100, 1c * d108).

Output

For each test case print ZZ(c, d) mod 1000000009.

Time limit 10 seconds
Memory limit 128 MiB
Input example #1
5
1 1 1 1
1 1 1 4
1 1 2 3
1 1 5 5
24995 8633 1 25158567
Output example #1
1
7
7
155
512203519
Source ACM ICPC Asia Thailand National programming Contest 2013