#include <iostream>
using namespace std;
int main()
{
int n=0;
cin>>n;
getchar();
while(n--){
string a;
getline(cin,a);
while(a.find('#')!=string::npos) a.erase(a.find('#')-1,2);
while(a.find('@')!=string::npos) a.erase(0,a.find('@')+1);
cout<<a<<endl;
}
return 0;
}