// Arup Guha
// 2/9/2017
// Solution to 2017 FHSPS Problem: Electric Car Race

import java.util.*;

public class electric {

	public static int numStops;
	public static int numCharge;
	public static int maxDistance;
	public static int[][] adj;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=0; loop<numCases; loop++) {

			// Get basic input.
			numStops = stdin.nextInt();
			numCharge = stdin.nextInt();
			maxDistance = stdin.nextInt();

			// Get adjacency matrix.
			adj = new int[numStops+1][numStops+1];
			for (int i=0; i<numStops+1; i++)
				for (int j=0; j<numStops+1; j++)
					adj[i][j] = stdin.nextInt();

			// Set up and run permutation recursion.
			int[] perm = new int[numStops];
			boolean[] used = new boolean[numStops];
			int numsols = go(perm, used, 0);
			int den = fact(numStops);

			// Get the number we must divide the numerator, denominator by.
			int div = gcd(numsols, den);

			// Output in lowest terms.
			System.out.println((numsols/div)+"/"+(den/div));
		}
	}

	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a%b);
	}

	public static int fact(int n) {
		return n == 0 ? 1 : n*fact(n-1);
	}

	public static int go(int[] perm, boolean[] used, int k) {

		// Done, see if this works.
		if (k == perm.length) return eval(perm);

		int res = 0;

		// Do usual permutation recursion.
		for (int i=0; i<perm.length; i++) {
			if (!used[i]) {
				used[i] = true;
				perm[k] = i+1; // Notice off by 1, so we're permuting 1-n, not 0-(n-1).
				res += go(perm, used, k+1);
				used[i] = false;
			}
		}

		// This is our final result.
		return res;
	}

	// Returns 1 if this route is viable, 0 otherwise.
	public static int eval(int[] perm) {

		// Our current charge.
		int curLeft = maxDistance;

		// Traverse whole path.
		for (int i=0; i<=numStops; i++) {

			// Figure out which path we are currently traversing.
			int start = i == 0 ? i : perm[i-1];
			int end = i == numStops ? 0 : perm[i];

			// Subtract the miles.
			curLeft -= adj[start][end];

			// Oops we didn't make it.
			if (curLeft < 0) return 0;

			// It's a charging station, so charge up!
			if (end >= 1 && end <= numCharge)
				curLeft = maxDistance;
		}

		// We made it!
		return 1;
	}
}