#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<climits>
#include<cstdio>
#include<cmath>
#define INF INT_MAX
using namespace std;
struct fract{
int bunbo;
int bunsi;
fract(int a,int b){
bunbo = a;
bunsi = b;
}
fract(){
bunbo = 1;
bunsi = 1;
}
};
void show_simplex(vector<vector<fract> >fra){
for(int i=0;i<fra.size();i++){
for(int j=0;j<fra[0].size();j++){
printf("%4d/%-4d ",fra[i][j].bunsi,fra[i][j].bunbo);
}
cout << endl;
}
cout << endl;
}
int judge(vector<vector<fract> > simplex){
for(int i=1;i<simplex[0].size();i++){
if(simplex[0][i].bunbo*simplex[0][i].bunsi > 0){
return i;
}
}
return -1;
}
int gcd(int a, int b) {
int c;
while (a != 0) {
c = a;
a = b % a;
b = c;
}
return b;
}
vector<vector<fract> > yakubun(vector<vector<fract> > fra){
for(int i=0;i<fra.size();i++){
for(int j=0;j<fra[0].size();j++){
fract tmp = fra[i][j];
int a = gcd(abs(tmp.bunsi),abs(tmp.bunbo));
fra[i][j].bunsi = (fra[i][j].bunsi / a) * (fra[i][j].bunbo/abs(fra[i][j].bunbo));
fra[i][j].bunbo = abs(fra[i][j].bunbo) / a;
}
}
return fra;
}
double act(fract a){
if(a.bunbo == 0)return INF;
return (double)a.bunsi/a.bunbo;
}
int stoi(string s){
int ret =0;
bool fu = false;
for(int i=0;i<s.size();i++){
if(s[i]=='-'){
fu = true;
continue;
}
ret *= 10;
ret += (s[i] - '0');
}
return ret * (fu ? -1 : 1);
}
int main(void){
int N,M;
cin >> N >> M;// >> surplus;
vector<vector<fract> >simplex(N);
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
string s;
cin >> s;
fract fra;
int n;
if((n=s.find('/'))==-1){
fra.bunsi = stoi(s);
simplex[i].push_back(fra);
}else{
fra.bunsi = stoi(s.substr(0,n));
fra.bunbo = stoi(s.substr(n+1));
simplex[i].push_back(fra);
}
}
}
show_simplex(simplex);
//列を決定
int c = 1;
while((c = judge(simplex)) != -1 ){
//行を決定
fract tmp2;
int r = -1;
double sa = INF;
for(int i=1;i<N;i++){ //todo 2段階なら、1->2
fract tmp = simplex[i][c];
fract hidari = simplex[i][0];
if(tmp.bunsi <= 0 || hidari.bunsi <= 0)continue;
if(r==-1){
sa = act(hidari)/act(tmp);
r=i;
}
else if(act(hidari)/act(tmp) < sa){
sa = act(hidari)/act(tmp);
r = i;
}
}
cout << r << "," << c << endl;
if(r<0)return 0;
//注目箇所を1に合わせるように逆数をかける
fract rec(abs(simplex[r][c].bunsi),simplex[r][c].bunbo*abs(simplex[r][c].bunsi)/simplex[r][c].bunsi);
for(int i=0;i<M;i++){
simplex[r][i].bunbo *= rec.bunbo;
simplex[r][i].bunsi *= rec.bunsi;
}
simplex = yakubun(simplex);
fract power;
for(int i=0;i<N;i++){
if(r == i)continue;
power = simplex[i][c];
for(int j=0;j<M;j++){
simplex[i][j].bunsi = simplex[r][j].bunbo*simplex[i][j].bunsi*power.bunbo -
simplex[r][j].bunsi*simplex[i][j].bunbo*power.bunsi;
simplex[i][j].bunbo *= simplex[r][j].bunbo * power.bunbo;
}
}
simplex = yakubun(simplex);
show_simplex(simplex);
cout << endl;
}
cout << "Answer =" << simplex[0][0].bunsi << "/" << simplex[0][0].bunbo << endl;
show_simplex(simplex);
return 0;
}