Liar Game

Time limit2sMemory limit512 MB

Summary
For N cards (one Joker) and R rounds, compute the probability of scoring K points, times (2*N)^R, modulo 1000003.
Level

Hard8 of 10

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

Problem

During resurrection round 2 of Liar Game, Kanzaki Nao was fooled by Fukunaga Yuuji in a "Light vs. Dark" card game, where Kanzaki Nao chose "Light" and Fukunaga Yuuji chose "Dark". The rules of the game are as follows:

Two playing cards are placed inside a bag:

  1. The "Light" card: a regular Joker card with Joker printed on one side and a back on the other side.
  2. The "Dark" card: a misprint card that has a back on both sides.

The game consists of multiple rounds, and one round proceeds as follows:

  1. Fukunaga shakes the bag, and then Kanzaki pulls out a card from the bag.
  2. If the Joker is face-up when pulled out, it is returned to the bag and the game proceeds to the next round (this round is lost). Otherwise the card is flipped over.
  3. If the card is the Joker, the "Light" player gets 1 point. Otherwise it must be the misprint card, and the "Dark" player gets 1 point.
  4. The card is returned to the bag and the game proceeds to the next round.

Here we deal with a more general "Light vs. Dark" game. Suppose there are N cards in the bag. One of them is the "Light" card, and all of the other cards are "Dark" cards. Akiyama Shinichi, a mastermind swindler, wants to know the exact probability that Kanzaki Nao gets exactly K points in the game after R rounds.

Input

The first line of input contains an integer T (1 <= T <= 2500), the number of test cases.

Each test case is described in one line consisting of 3 integers: N, R, K, where 1 <= N, R <= 100,000 and 0 <= K <= R.

Output

For each test case, output a single line: (P * (2*N)R) mod 1000003, where P is the probability that Kanzaki Nao gets K points (picks the face-down Joker card K times) in a game consisting of R rounds and N cards.

Examples1

  1. Example 1

    Input
    6
    2 2 1
    2 5 2
    2 10 5
    3 5 1
    100 100 14
    46624 22965 14070
    
    Expected output
    6
    270
    61236
    3125
    975443
    408634