This page is still under construction.

Parts of this page are still being built. What you see may change.

ZZ

Time limit15sMemory limit64 MB

Summary
Starting from Fibonacci-like values a and b, repeat prefix sums c times and output the d-th value modulo 1000000009.
Level

Hard8 of 10

Topics
Combinatorics, Number theory, Dynamic programming
Solved
No attempts yet

Problem

The function ZZZZ is defined as follows.

ZZ(0,1)=aZZ(0, 1) = a

ZZ(0,2)=bZZ(0, 2) = b

ZZ(0,k)=ZZ(0,k−1)+ZZ(0,k−2)(k>2)ZZ(0, k) = ZZ(0, k-1) + ZZ(0, k-2) \quad (k > 2)

ZZ(i,k)=∑j=1kZZ(i−1,j)(i≥1, k≥1)ZZ(i, k) = \sum_{j=1}^{k} ZZ(i-1, j) \quad (i \ge 1,\ k \ge 1)

Given four integers aa, bb, cc, dd, write a program that computes ZZ(c,d)ZZ(c, d).

Input

The first line contains the number of test cases TT. (T≤200T \le 200)

Each of the next TT lines holds one test case as four integers aa, bb, cc, dd. (0≤a,b≤10000000000 \le a, b \le 1000000000, 1≤c≤1001 \le c \le 100, 1≤c×d≤1000000001 \le c \times d \le 100000000)

Output

For each test case, print ZZ(c,d)ZZ(c, d) modulo 10000000091000000009 on its own line.

Examples1

  1. Example 1

    Input
    5
    1 1 1 1
    1 1 1 4
    1 1 2 3
    1 1 5 5
    24995 8633 1 25158567
    
    Expected output
    1
    7
    7
    155
    512203519