#include <bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
if(y==0) return x;
if(x==0) return y;
return gc(y%x,x);
}
int main()
{
int t,m;
cin >> t >> m;
for(int i=1;i<=t;i++){
int a,b,c;
cin >> a >> b >> c;
if((b*b-4*a*c)<0){
cout<< "NO";
}
else{
if((b*b-4*a*c)==0){
if((0-b)%(2*a)==0){
cout << ((0-b)/(2*a));
}
else{
cout << (0-b)/gcd((0-b),(2*a)) << '/' <<(2*a)/gcd((0-b),(2*a));
}
}
else{
if((((0-b)+(int)(sqrt(b*b-4*a*c)))%(a*2)==0)&&(sqrt(b*b-4*a*c)*sqrt(b*b-4*a*c))==(b*b-4*a*c)){
cout <<((0-b)+(sqrt(b*b-4*a*c))/(2*a)) << endl;
continue;
}
if((0-b)%(2*a)==0){
if(((0-b)/(2*a))!=0) cout << ((0-b)/(2*a)) << '+';
}
else{
cout << (0-b)/gcd((0-b),(2*a)) << '/' <<(2*a)/gcd((0-b),(2*a)) << '+';
}
if((sqrt(b*b-4*a*c)*sqrt(b*b-4*a*c))==(b*b-4*a*c)){
int w=sqrt(b*b-4*a*c);
if(w%2==0){
cout << w/2;
}
else{
cout << w << '/' << 2;
}
}
else{
if((b*b-4*a*c)%4==0){
cout << "sqrt(" << (b*b-4*a*c)/4 << ")";
}
else cout << "sqrt(" << (b*b-4*a*c) << ")/2";
}
}
}
cout << '\n';
}
return 0;
}