#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<ll,ll>> solve(ll n) {
vector<pair<ll,ll>> res;
ll x = 0, y = sqrt(n);
while(x <= y) {
ll sum = x*x + y*y;
if(sum == n) {
res.emplace_back(x, y);
x++;
y--;
} else if(sum < n) {
x++;
} else {
y--;
}
}
return res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while(T--) {
ll n;
cin >> n;
auto ans = solve(n);
for(auto [x,y] : ans) {
cout << "(" << x << "," << y << ") ";
}
cout << "\n";
}
return 0;
}