#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<map>
#define Redge(u) for (int k = h[u],to; k; k = ed[k].nxt)
#define REP(i,n) for (int i = 1; i <= (n); i++)
#define mp(a,b) make_pair<int,int>(a,b)
#define cls(s) memset(s,0,sizeof(s))
#define cp pair<int,int>
#define LL long long int
using namespace std;
const int maxn = 100005,maxm = 100005,INF = 1000000000;
inline int read(){int out = 0,flag = 1; char c = getchar();while (c < 48 || c > 57){if (c == '-') flag = -1; c = getchar();}while (c >= 48 && c <= 57){out = (out << 3) + (out << 1) + c - 48; c = getchar();}return out * flag;
}
LL a,b,x,y,tmp;
LL gcd(LL a,LL b){return b ? gcd(b,a % b) : a;}
int main(){int T = read();while (T--){a = read(); b = read(); x = read(); y = read();if (a < b) swap(a,b);tmp = gcd(gcd(2 * a * b,a * a + b * b),a * a - b * b);if ((b * x - a * y) % tmp || (b * x + a * y) % tmp || (a * x - b * y) % tmp || (a * x + b * y) % tmp)puts("N");else puts("Y");}return 0;
}