1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS10/11
* Problem: 10109 Solving Systems of Linear Equations
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=13&page=show_problem&problem=1050
*
* @author Fabian Liebl
* @version 1.0, 10/06/2010
*
* Method : Gaussian elimination
* Status : Accepted
* Runtime: 1.060
*/

import java.io.*;
import java.util.Arrays;

public class Main {

private static class RationalNumber {
private long num;
private long denom;

public RationalNumber(long num, long denom) {
this.num = num;
this.denom = denom;
}

public RationalNumber(RationalNumber other) {
this.num = other.num;
this.denom = other.denom;
}

public RationalNumber(String s) {
s = s.trim();
if (s.contains("/")) {
String[] spl = s.split("/");
num = Integer.parseInt(spl[0]);
denom = Integer.parseInt(spl[1]);
} else {
num = Integer.parseInt(s);
denom = 1;
}
}

public void scale(long i) {
num *= i;
denom *= i;
}

public void cancel() {
long i = gcd(num, denom);
num /= i;
denom /= i;
if (denom < 0) {
num *= -1;
denom *= -1;
}
}

public void add(RationalNumber x) {
long d = denom;
this.scale(x.denom);
x.scale(d);
this.num += x.num;
this.cancel();
}

public void mul(RationalNumber x) {
this.num *= x.num;
this.denom *= x.denom;
this.cancel();
}

public void div(RationalNumber x) {
this.num *= x.denom;
this.denom *= x.num;
this.cancel();
}

private long gcd(long a, long b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}

public String toString() {
if (denom == 1) {
return num + "";
} else {
return num + "/" + denom;
}
}
}

public static void main(String[] args) throws IOException {
BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in));

int tc = Integer.parseInt(inputReader.readLine());
int unknowns, equations;
RationalNumber[][] A;
RationalNumber[] line;
RationalNumber[] solution;
RationalNumber factor;
RationalNumber temp;

int rank;
boolean zeroline;
boolean incons;
boolean start = true;

String[] s;

while (tc > 0) {
s = inputReader.readLine().split(" ");
unknowns = Integer.parseInt(s[0]);
equations = Integer.parseInt(s[1]);
A = new RationalNumber[equations][unknowns + 1];
line = new RationalNumber[unknowns + 1];
solution = new RationalNumber[unknowns];

for (int i = 0; i < equations; i++) {
s = inputReader.readLine().split(" ");
int sIndex = 0;
for (int j = 0; j < unknowns + 1; j++) {
while (s[sIndex].equals(""))
sIndex++;
A[i][j] = new RationalNumber(s[sIndex]);
sIndex++;
}
}

for (int i = 0; i < equations; i++) {
if (i >= unknowns)
break;
if (A[i][i].num == 0) {
// Find line with element i not 0
for (int j = i; j < equations; j++) {
if (A[j][i].num != 0) {
// Switch lines
line = Arrays.copyOf(A[i], unknowns + 1);
A[i] = Arrays.copyOf(A[j], unknowns + 1);
A[j] = Arrays.copyOf(line, unknowns + 1);
break;
}
}
}
if (A[i][i].num == 0) {
continue; // Only zeros on this column, nothing to do
}

// Set first element in line to 1
factor = new RationalNumber(A[i][i].denom, A[i][i].num);
for (int j = i; j < unknowns + 1; j++) {
A[i][j].mul(factor);
}

// Eliminate column
for (int j = i + 1; j < equations; j++) {
factor = new RationalNumber(A[j][i].num * -1, A[j][i].denom);
factor.div(A[i][i]);
for (int k = i; k < unknowns + 1; k++) {
temp = new RationalNumber(A[i][k]);
temp.mul(factor);
A[j][k].add(temp);
}
}
}

// Confirm consistency
rank = equations;
incons = false;
for (int i = equations - 1; i >= 0; i--) {
zeroline = true;
for (int j = 0; j < unknowns + 1; j++) {
if (A[i][j].num != 0) {
if (j == unknowns) {
incons = true;
break;
}
zeroline = false;
break;
}
}
if (incons) {
break;
}
if (zeroline) {
rank--;
} else {
break;
}
}

if (!start) {
System.out.println();
} else {
start = false;
}
System.out.printf("Solution for Matrix System # %d\n", tc);

if (incons) {
System.out.println("No Solution.");
} else {
if (unknowns > rank) {
System.out.printf("Infinitely many solutions containing %d arbitrary constants.\n", unknowns - rank);
} else {
for (int i = unknowns - 1; i >= 0; i--) {
for (int j = i + 1; j < unknowns; j++) {
temp = new RationalNumber(A[i][j].num * -1, A[i][j].denom);
temp.mul(solution[j]);
A[i][unknowns].add(temp);
}
solution[i] = new RationalNumber(A[i][unknowns]);
}
for (int i = 0; i < unknowns; i++) {
System.out.printf("x[%d] = %s\n", i + 1, solution[i].toString());
}
}
}

inputReader.readLine();
tc = Integer.parseInt(inputReader.readLine());
}
}

}