#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef __int128 int128;
#define IOS ios::sync_with_stdio(0);
#define rep(i,x,y,z) for(int i = x;i <= y;i+=z)
#define per(i,y,x,z) for(int i = y;i >= x;i-=z)
#define frin(x) freopen(x,"r",stdin);
#define frout(x) freopen(x,"w",stdout);
const int N = 1e6 + 5;
const int M = 2e3 + 5;
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int dx[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int dy[] = {0, 0, -1, 1, 1, -1, -1, 1};
inline ll read();
inline void solve();
inline void print(ll x);
inline ll gcd(ll x, ll y);
inline ll lcm(ll x, ll y);
inline ll pow(ll x, ll y, ll z);
struct Big {
int len, s[810];
Big() {
memset(s, 0, sizeof(s));
len = 1;
}
Big(int val) {
*this = val;
}
Big(const char *val) {
*this = val;
}
Big operator = (const int &val) {
char s[810];
sprintf(s, "%d", val);
*this = s;
return *this;
}
Big operator = (const char *val) {
len = strlen(val);
while (len > 1 && val[0] == '0') ++val, len--;
for ( int i = 0; i < len; ++i) s[i] = val[len - i - 1] - '0';
return *this;
}
inline void deal() {
while (len > 1 && !s[len - 1]) len--;
}
Big operator + (const Big &a) const {
Big res;
res.len = 0;
int top = max(len, a.len), add = 0;
for ( int i = 0; add || i < top; ++i) {
int now = add;
if (i < len) now += s[i];
if (i < a.len) now += a.s[i];
res.s[res.len++] = now % 10;
add = now / 10;
}
return res;
}
Big operator - (const Big &a) const {
Big res;
res.len = 0;
int del = 0;
for ( int i = 0; i < len; ++i) {
int now = s[i] - del;
if (i < a.len) now -= a.s[i];
if (now >= 0) del = 0;
else del = 1, now += 10;
res.s[res.len++] = now;
}
res.deal();
return res;
}
Big operator * (const Big &a) const {
Big res;
res.len = len + a.len;
for ( int i = 0; i < len; ++i)
for ( int j = 0; j < a.len; ++j)
res.s[i + j] += s[i] * a.s[j];
for ( int i = 0; i < res.len; ++i)
res.s[i + 1] += res.s[i] / 10, res.s[i] %= 10;
res.deal();
return res;
}
Big operator / (const Big &a) const {
Big res, cur = 0;
res.len = len;
for ( int i = len - 1; ~i; --i) {
cur = cur * 10, cur.s[0] = s[i];
while (cur >= a)
cur -= a, res.s[i]++;
}
res.deal();
return res;
}
Big operator % (const Big &a) const {
Big res = *this / a;
return *this - res * a;
}
Big operator += (const Big &a) {
*this = *this + a;
return *this;
}
Big operator -= (const Big &a) {
*this = *this - a;
return *this;
}
Big operator *= (const Big &a) {
*this = *this * a;
return *this;
}
Big operator /= (const Big &a) {
*this = *this / a;
return *this;
}
Big operator %= (const Big &a) {
*this = *this % a;
return *this;
}
bool operator < (const Big &a) const {
if (len != a.len) return len < a.len;
for ( int i = len - 1; ~i; i--)
if (s[i] != a.s[i]) return s[i] < a.s[i];
return false;
}
bool operator > (const Big &a) const {
return a < *this;
}
bool operator <= (const Big &a) const {
return !(*this > a);
}
bool operator >= (const Big &a) const {
return !(*this < a);
}
bool operator == (const Big &a) const {
return !(*this > a || *this < a);
}
bool operator != (const Big &a) const {
return *this > a || *this < a;
}
Big Sqrt(const Big &x) {
int a[510], top = 0;
for ( int i = 0; i < x.len; i += 2) {
if (i == x.len - 1) a[top++] = x.s[i];
else a[top++] = x.s[i] + x.s[i + 1] * 10;
}
Big res = (int)sqrt((double)a[top - 1]);
int dat = (int)sqrt((double)a[top - 1]);
Big pre = a[top - 1] - dat * dat, val;
for ( int i = top - 2; ~i; --i) {
pre = pre * 100 + a[i], val = res * 20;
for ( int j = 9; ~j; --j) {
Big now = (dat + j) * j;
if (now > pre) continue;
res = res * 10 + j;
pre -= now;
break;
}
}
return res;
}
void print(const Big &a) {
for ( int i = a.len - 1; ~i; --i)
printf("%d", a.s[i]);
puts("");
}
int read() {
int a = 0, b = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
b = (ch == '-') ? -1 : 1, ch = getchar();
while (ch >= '0' && ch <= '9')
a = (a << 3) + (a << 1) + (ch ^ 48), ch = getchar();
return a * b;
}
};
int main() {
IOS;
int T = 1, Max;
cin >> T >> Max;
while (T--) {
solve();
}
return 0;
}
inline ll read() {
ll s = 0, w = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') w = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
s = s * 10 + c - '0';
c = getchar();
}
return s * w;
}
inline void print(ll x) {
if (x < 0) {
putchar('-');
x = -x;
}
if (x >= 10) {
print(x / 10);
}
putchar(x % 10 + '0');
return;
}
inline ll pow(ll x, ll y, ll z) {
if (z == 0) z = INF;
ll ans = 1;
while (y) {
if (y % 2) {
ans *= x;
}
x *= x;
y >>= 1;
}
return ans;
}
inline ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a % b);
}
inline ll lcm(ll a, ll b) {
return a * b / gcd(a, b);
}
int a, b, c;
inline void solve() {
cin >> a >> b >> c;
if(a < 0) a = -a,b = -b,c = -c;
if (b * b - 4 * a * c < 0) {
cout << "NO\n";
return ;
}
int delta = b * b - 4 * a * c, del_xs = 1;
if (delta == 0) {
int Gcd = gcd(-b, 2 * a);
if (Gcd != 2 * a) {
cout << -b / Gcd << "/" << 2 * a / Gcd << endl;
return ;
}
cout << -b / Gcd << endl;
return ;
}
for (int i = 2; i <= sqrt(delta); i++) {
if (delta % (i * i) == 0) {
while (delta % (i * i) == 0) {
del_xs *= i;
delta /= (i * i);
}
}
}
if (delta == 1) {
int Gcd = gcd(del_xs - b, 2 * a);
if (Gcd == 2 * a) {
cout << (del_xs - b) / Gcd << endl;
return ;
}
cout << (del_xs - b) / Gcd << "/" << 2 * a / Gcd << endl;
return ;
} else if (b != 0) {
int Gcd = gcd(-b, 2 * a);
if (Gcd == 2 * a) {
cout << -b / Gcd << "+";
} else {
cout << -b / Gcd << "/" << 2 * a / Gcd << "+";
}
}
int Gcd = gcd(del_xs, 2 * a);
if (del_xs / Gcd == 1) {
if (Gcd == 2 * a) {
cout << "sqrt(" << delta << ")" << endl;
} else cout << "sqrt(" << delta << ")" << "/" << 2 * a / Gcd << endl;
} else {
if (Gcd == 2 * a) {
cout << del_xs / Gcd << "*" << "sqrt(" << delta << ")" << endl;
return ;
}
cout << del_xs / Gcd << "*" << "sqrt(" << delta << ")" << "/" << 2 * a / Gcd << endl;
}
}