#include <bits/stdc++.h>
using namespace std;
int a, b, c, m;
int n;
int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
int f(int n) {
int maxn=0;
for (int i = 1; i * i <= n; i++) {
if (n % (i*i) == 0) {
maxn = i*i;
}
}
return sqrt(maxn);
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a >> b >> c;
int p = b * b - 4 * a * c;
if (p < 0) cout << "NO" << endl;
else if (p >= 0) {
int t1 = abs(-b + sqrt(p));
int t2 = abs(2 * a);
int t3 = gcd(t1, t2);
int t4 = abs(-b - sqrt(p));
int t5 = gcd(t4, t2);
double x1 = (-b + sqrt(p)) * 1.0 / 2 / a;
double x2 = (-b - sqrt(p)) * 1.0 / 2 / a;
if (int(sqrt(p))*int(sqrt(p)) == p) {
if (x1 >= x2) {
if ((-b + sqrt(p)) * 2 * a > 0) {
if (t2 / t3 != 1) cout << t1 / t3 << "/" << t2 / t3 << endl;
else cout << t1 / t3 << endl;
} else if (-b + sqrt(p) == 0) cout << 0 << endl;
else if ((-b + sqrt(p)) * 2 * a < 0) {
if (t2 / t3 != 1) cout << "-" << t1 / t3 << "/" << t2 / t3 << endl;
else cout << "-" << t1 / t3 << endl;
}
} else if (x1 < x2) {
if ((-b - sqrt(p)) * 2 * a > 0) {
if (t2 / t5 != 1) cout << t4 / t5 << "/" << t2 / t5 << endl;
else cout << t4 / t5 << endl;
} else if (-b - sqrt(p) == 0) cout << 0 << endl;
else if ((-b - sqrt(p)) * 2 * a < 0) {
if (t2 / t5 != 1) cout << "-" << t4 / t5 << "/" << t2 / t5 << endl;
else cout << "-" << t4 / t5 << endl;
}
}
} else if (int(sqrt(p))*int(sqrt(p)) != p) {
int tmp = abs(b);
int t6 = gcd(tmp, t2);
int t7 = gcd(f(p), t2);
if (t2 / t6 != 1) {
if(-2*a*b>0) cout << tmp / t6 << "/" << t2 / t6 << "+";
else if(-2*a*b<0) cout <<"-" << tmp / t6 << "/" << t2 / t6 << "+";
if (f(p) / t7 != 1 && t2 / t7 != 1) {
cout << f(p) / t7 << "*" << "sqrt(" << p / f(p) / f(p) << ")" << "/" << t2 / t7 << endl;
} else if (f(p) / t7 != 1 && t2 / t7 == 1) {
cout << f(p) / t7 << "*" << "sqrt(" << p / f(p) / f(p) << ")" << endl;
} else if (f(p) / t7 == 1 && t2 / t7 != 1) {
cout << "sqrt(" << p / f(p) / f(p) << ")" << "/" << t2 / t7 << endl;
} else if (f(p) / t7 == 1 && t2 / t7 == 1) {
cout << "sqrt(" << p / f(p) / f(p) << ")" << endl;
}
} else {
if(-2*a*b>0) cout << tmp / t6 << "+";
if(-2*a*b<0) cout <<"-"<< tmp / t6 << "+";
if (f(p) / t7 != 1 && t2 / t7 != 1) {
cout << f(p) / t7 << "*" << "sqrt(" << p / f(p) / f(p) << ")" << "/" << t2 / t7 << endl;
} else if (f(p) / t7 != 1 && t2 / t7 == 1) {
cout << f(p) / t7 << "*" << "sqrt(" << p / f(p) / f(p) << ")" << endl;
} else if (f(p) / t7 == 1 && t2 / t7 != 1) {
cout << "sqrt(" << p / f(p) / f(p) << ")" << "/" << t2 / t7 << endl;
} else if (f(p) / t7 == 1 && t2 / t7 == 1) {
cout << "sqrt(" << p / f(p) / f(p) << ")";
}
}
}
}
}
return 0;
}