Description

The sum of the MTH powers of the First n Integers

S (n, m) = sum (j = 1 to n) (JM)

Can be written as a polynomial of degree m + 1 in N:

S (n, m) = sum (k = 1 to m + 1) (F (M, k) * NK)

Fo example:

The coefficients f (M, k) of these formulas form faulhaber's tr angle:

Where rows m start with 0 (at the top) and columns K go from 1 to m + 1

Each row of faulhaber's tr angle can be computed from the previous row:

A) The element in row I and column J (j> 1) is (I/J) * (the element above left); that is:

F (I, j) = (I/J) * F (I-1, J-1)

B) The first element in each row F (I, 1) is chosen so the sum of the elements in the row is 1

Write a program to find entries in faulhaber's tr angle as decimal F actions in lowest terms

Input

The first line of input contains a single integer p, (1 <= P <= 1000), which is the number of data sets that follow. Each Data Set shocould be processed identically and independently

Each data set consists of a single line of input consisting of three space separated decimal integers the first integer is the data set number. the second integer is row number m, and the third integer is the index K within the row of the entry for which

You are to find F (M, k), The faulhaber's triangle entry (0 <= m <= 400, 1 <= k <= n + 1 ).

Output

For each data set there is a single line of output. it contains the data set number, followed by a single space which is then followed by either the value if it is an integer or by the numerator of the entry, a forward slash and

The denominator of the entry.

Sample Input

41 4 12 4 33 86 794 400 401

Sample output

1 -1/302 1/33 -223883374 1/401

The recursive equation of this question has been given: f (I, j) = (I/J) * F (I-1, J-1), that is, it is more difficult to process the score, there was a problem with the calculation of the common appointment in the middle. The Code is as follows:

# Include <iostream> # include <cstdio> # include <algorithm> # include <cstring> # define n 100000 using namespace STD; __int64 f [405] [405] [2], Min, sum1, sum2; // F [I] [J] [1] indicates molecules, f [I] [J] [2] indicates the denominator _ int64 getsmin (_ int64 x ,__ int64 y) // calculates the maximum common approx, otherwise _ int64 will pop up {x = (x <0 )? -X: X; y = (Y <0 )? -Y: Y; _ int64 T = x % Y; while (T! = 0) {x = y; y = T; t = x % Y;} return y;} int main () {f [0] [1] [1] = 1; F [0] [1] [2] = 1; F [1] [2] [1] = 1; f [1] [2] [2] = 2; F [1] [1] [1] = 1; F [1] [1] [2] = 2; int I, j, P, T, M, K, ans; for (I = 2; I <= 400; I ++) {for (j = I + 1, sum1 = 0, sum2 = 1; j> 1; j --) {f [I] [J] [1] = I * f [I-1] [J-1] [1]; f [I] [J] [2] = J * f [I-1] [J-1] [2]; min = getsmin (F [I] [J] [1], f [I] [J] [2]); F [I] [J] [1]/= min; F [I] [J] [2]/= min; // approx. // cout <"f [" <I <"] [" <j <"] [1]: f ["<I <"] ["<j <"] [2] "<Endl; // cout <F [I] [J] [1] <"/" <F [I] [J] [2] <Endl; if (sum2% F [I] [J] [2]) {sum1 = sum1 * f [I] [J] [2] + F [I] [J] [1] * sum2; sum2 * = f [I] [J] [2];} else sum1 = sum1 + F [I] [J] [1] * (sum2/f [I] [J] [2]); min = getsmin (sum1, sum2 ); sum1/= min; sum2/= min;} f [I] [1] [2] = sum2; F [I] [1] [1] = sum2-sum1; // The Last One can only use 1 minus the remaining score and min = getsmin (F [I] [1] [1], F [I] [1] [2]); // cout <"min" <min <Endl; F [I] [1] [1]/= min; f [I] [1] [2]/= min; // Cout <"f [" <I <"] [" <j <"] [1]: f ["<I <"] ["<j <"] [2] "<Endl; // cout <F [I] [1] [1] <"/" <F [I] [1] [2] <Endl ;} // cout <F [3] [1] <Endl; scanf ("% d", & P); While (p --) {scanf ("% d", & T, & M, & K); If (! F [m] [k] [1]) printf ("% d 0 \ n", t ); else {If (F [m] [k] [2] = 1) printf ("% d % i64d \ n", T, f [m] [k] [1]); else printf ("% d % i64d/% i64d \ n", T, F [m] [k] [1], f [m] [k] [2]) ;}} return 0 ;}