#include #include #include #include using namespace std; typedef long long ll; #define rep(i,a,n) for(int i=(a);i<(n);i++) int T; int D, x, y; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> T; while(T--){ cin >> D >> x >> y; int g = gcd(x, y); int nx = y/g, ny = -x/g; long l=0L, r=1e9+1; while(l+1abs(R)) cout << l*(x*x+y*y)/g << endl; else cout << -R*(x*x+y*y)/g << endl; } }