int _tmain(int argc, _TCHAR* argv[])
{
    int nums;
    cin>>nums;
    for(int i=0;i<nums;++i){
        string str;
        cin>>str;
        int len=str.size();
        string tmp;
        int j=0;
        while(j<len){
            if (str[j]=='@')
            {
                tmp.clear();
            } 
            else if(str[j]=='#')
            {
                tmp=tmp.substr(0,tmp.size()-1);
            }
            else
                tmp+=str[j];
            ++j;
        }
        cout<<tmp<<endl;
    }
    return 0;
}