#include <cmath>
#include <iostream>
int T, M;
int power (int x, int y) {
int ret = 1;
for (int i = 1; i <= y; i++) ret *= x;
return ret;
}
int gcd (int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
int tot, d, t, k = 1;
void uqe () {
int a, b, c;
std::cin >> a>> b>> c;
if (a < 0) a *= -1, b *= -1, c *= -1;
int d = pow (b, 2) - 4 * a * c;
if (d < 0) std::cout << "NO"<< std::endl;
if (d == 0 || d == 1) {
t = abs(gcd(2 * a,-b + k * d));
std::cout << (-b + k * d) / t;
if((2 * a) / t != 1) std::cout << "/"<< (2 * a) / t;
std::cout << "\n";
return ;
}
t = std::abs(gcd(-b,2*a));
if (b / t != 0) {
std::cout << -b / t;
if((2 * a) / t != 1) std::cout << "/"<< (2 * a) / t;
std::cout << "+";
}
t = std::abs (gcd (k, 2 * a));
if (k / t != 1) std::cout << k / t << "*";
printf ("sqrt(%d)", d);
if ((2 * a) / t != 1) std::cout << "/" << (2 * a) / t;
std::cout << std::endl;
return ;
}
int main() {
std::cin >> T>> M;
for (int i = 1; i <= T; i++) uqe();
return 0;
}