#include<bits/stdc++.h>
using namespace std;
bool wq(int n){
if(pow(sqrt(n),2)==n){return 1;}
else{return 0;}
}
int main(){
int t,m;
cin>>t>>m;
for(int nymyj8=0;nymyj8<t;nymyj8++){
int a,b,c,s;
cin>>a>>b>>c;
s=b*b-4*a*c;
if(s<0){
cout<<"NO"<<endl;
continue;
}
else if(s==0){
int g=gcd(-b,2*a);
double fz=-b/g,fm=2*a/g;
if(fm==1){cout<<fz<<endl;}
else{cout<<fz<<"/"<<fm<<endl;}
}
else{
if(wq(s)){
int g=gcd(max(-b-int(sqrt(s)),-b+int(sqrt(s))),2*a);
double fz=max(-b-int(sqrt(s)),-b+int(sqrt(s)))/g,fm=2*a/g;
if(fm==1){cout<<fz<<endl;}
else{cout<<fz<<"/"<<fm<<endl;}
}
else{cout<<endl;}
}
}
return 0;
}