#include <bits/stdc++.h>
using namespace std;
int n,k,cy;
string s1,s2;
string cyc;
int main(){
cin>>n;
getline(cin,s1);
while(n--){
k=0;
getline(cin,s1);
int t=s1.size();
for(int j=0;j<t;j++){
cy=0;
s2[k++]=s1[j];
while(s1[j]!=' '){
cyc[cy++]=s1[j];
j++;
}
if(cy<3) k--;
if(cy==3){
if((cyc[1]=='A' or cyc[1]=='a') and (cyc[2]=='N' or cyc[2]=='n') and (cyc[3]=='D' or cyc[3]=='d')) k--;
if((cyc[1]=='F' or cyc[1]=='f') and (cyc[2]=='O' or cyc[2]=='o') and (cyc[3]=='R' or cyc[3]=='r')) k--;
if((cyc[1]=='T' or cyc[1]=='t') and (cyc[2]=='H' or cyc[2]=='h') and (cyc[3]=='E' or cyc[3]=='e')) k--;
}
}
for(int j=1;j<=s2.size();j++) cout<<s2[j];
cout<<endl;
}
return 0;
}