Drawing lots

Compute the expected number of draws until a blue lot has been drawn K times, where red lots are removed and green and blue lots are returned.

Hard9ProbabilityMathDynamic programmingNo attempts yetTime limit2sMemory limit512 MB

Problem

He draws lots whenever he has time to spare. Drawing them with no rules attached got boring, so he settled on rules that depend on the color of the lot he draws.

He has RR lots with a red tip, GG lots with a green tip, and BB lots with a blue tip. He puts every lot into a box with the colored end hidden, mixes the box well, and draws one lot at a time. He mixes the box thoroughly every time, so every lot still in the box is equally likely to be drawn. He acts on the color of the lot he drew as follows.

  1. If he draws a red lot, he throws that lot away.
  2. If he draws a green lot, he puts it back into the box and mixes the box.
  3. If he draws a blue lot, he puts it back into the box and mixes the box. Once he has drawn a blue lot KK times, he stops drawing and goes to sleep.

Write a program that computes the expected number of lots he draws before he goes to sleep.

Input

The first line contains the number of test cases TT (1T1031 \le T \le 10^3).

Each test case is one line holding the number of red lots RR, the number of green lots GG, the number of blue lots BB, and the number of blue draws KK that sends him to sleep, separated by spaces. All four numbers are integers between 11 and 10910^9.

Output

For each test case, print the expected number of lots he draws before he goes to sleep on its own line.

When the expected value is written as the irreducible fraction a/ba/b, print the remainder of a×b1a \times b^{-1} divided by 1,000,000,007. Here b1b^{-1} is the multiplicative inverse of bb modulo 1,000,000,007. An answer exists for every input.

Hint

For R=1R = 1, G=1G = 1, B=1B = 1, K=1K = 1 the expected value is 5/25/2. The inverse of 22 modulo 1,000,000,007 is 500000004500000004, so print the remainder of 5×5000000045 \times 500000004 divided by 1,000,000,007, which is 500000006500000006.