SP21407 GRIDSUM1 - 2x2 Subgrid Sum Problem (medium)

Description

This problem is a higher constraints version of [KWACIK](http://pl.spoj.com/problems/KWACIK/) (Polish). ![Sample case for a=1, b=3 and n=8.](../../../content/min_25:grid_3x3.png "Sample case for a=1, b=3 and n=8.") You are given a 3x3 grid. You can place an integer _m_ (**_a_** m **b**) in each cell. How many ways are there to place integers in the cells such that the sum of each 2x2 subgrid is _**n**_ ?

Input Format

The first line contains an integer **_T_** (1 **T** On each of the next **_T_** lines, you are given three integers _**a**_, **_b_** and _**n**_. (0 _a_ _b_ _n_

Output Format

For each test case, output a single line containing the number of ways to place integers.