// https://sim.csp.thusaac.com/contest/33/problem/2
/*
* CSP认证第三题,经典大模拟
* 第一步首先得读取矩阵,这里由于事先不知道一行中元素的个数,
* 所以用一个哈希表来记录元素在第几行(自增索引idx)
*
* 第二步就是大模拟将矩阵进行高斯消元
*/
#include<bits/stdc++.h>
using namespace std;
const int N=100, M=100;
unordered_map<string, int> mp;
double mat[N][M];
int idx;
int q;
void work(){
cin>>q;
while(q--){
mp=unordered_map<string, int>();
memset(mat, 0, sizeof mat);
idx=0;
int m, cnt=0;
cin>>m;
for(int i=0;i<m;i++){
string str;
cin>>str;
stringstream ssin(str);
char c;
bool flag=false;
string tmp;//元素
int num=0;//个数
while(ssin>>c){
if(c>='0'&&c<='9'){
int x=c-'0';
num=num*10+x;
flag=true;
}
else{
if(flag){
if(!mp.count(tmp)) mp[tmp]=idx++;
mat[mp[tmp]][i]=num;
tmp="";
num=0;
flag=false;
}
tmp+=c;
}
}
if(!mp.count(tmp)) mp[tmp]=idx++;
mat[mp[tmp]][i]=num;
}
//test
// for(int i=0;i<idx;i++){
// for(int j=0;j<m;j++) cout<<mat[i][j]<<" ";
// cout<<endl;
// }
for(int j=0;j<m;j++){
int i=j;
while(i<idx&&mat[i][j]==0) i++;
if(i==idx) continue;
for(int k=j;k<m;k++) swap(mat[i][k], mat[j][k]);
for(int u=j+1;u<idx;u++){
double y=mat[u][j]/mat[j][j];
for(int v=j;v<m;v++)
mat[u][v]-=mat[j][v]*y;
}
}
// test
// for(int i=0;i<idx;i++){
// for(int j=0;j<m;j++) cout<<mat[i][j]<<" ";
// cout<<endl;
// }
int rank=0;
for(int i=0;i<idx;i++){
bool f=true;
for(int j=0;j<m;j++){
if(mat[i][j]!=0){
f=false;
break;
}
}
if(f) rank++;
}
rank=idx-rank;
//test
// cout<<"rank: "<<rank<<endl;
if(rank<m) cout<<"Y"<<endl;
else cout<<"N"<<endl;
}
}
int main(){
work();
return 0;
}