#include <bits/stdc++.h>
#define int long long
using namespace std;
void ZorF(int a,int b){
if(a==0){
cout<<0;
return;
}
if(a%b==0){
cout<<a/b;
return;
}
if(a*b<0){
cout<<"-";
if(a<0){
a=-a;
}
if(b<0){
b=-b;
}
}
int g=__gcd(a,b);
cout<<a/g<<"/"<<b/g;
}
void solve(int a,int b){
bool flag=false;
if(b<0){
b=-b;
flag=true;
}
int t=1;
for(int i=sqrt(a);i>=2;i--){
if(a%(i*i)==0){
t=i;
a/=(i*i);
break;
}
}
int g=__gcd(t,b);
t/=g,b/=g;
if(t!=1){
cout<<t<<"*";
}
cout<<"sqrt("<<a<<")";
if(b!=1){
cout<<"/";
if(flag){
cout<<-b;
}
else{
cout<<b;
}
}
}
signed main(){
int t,m;
cin>>t>>m;
for(int i=1;i<=t;i++){
int a,b,c;
cin>>a>>b>>c;
int num=b*b-4*a*c;
if(num<0){
cout<<"NO";
}
else{
int d=sqrt(num);
if(d*d==num){
double a1=1.0*(-b+d)/(2*a);
double a2=1.0*(-b-d)/(2*a);
if(a1>a2){
ZorF((-b+d),(2*a));
}
else{
ZorF((-b-d),(2*a));
}
}
else{
if(b!=0){
ZorF(-b,2*a);
cout<<"+";
}
solve(d,2*a);
}
}
cout<<endl;
}
return 0;
}