代码:
#include <bits/stdc++.h>
#define int long long
#define f(i,a,b,c) for(int i=a;i<=b;i+=c)
#define ff(i,a,b,c) for(int i=a;i>b;i-=c)
using namespace std;
const int N=1e5+1;
int n,cnt;
char c[N];
string s;
vector<char> st;
int read(){int X=0,F=1;char C=getchar();while(C<'0'||C>'9'){if(C=='-') F=-1;C=getchar();}while(C>='0'&&C<='9'){X=X*10+C-'0';C=getchar();}return X*F;}
signed main(){
n = read();
while (n--) {
getline(cin,s);
f(i,0,s.size()-1,1) {
char x = s[i];
if (x == '#') {
if (!st.empty()) st.pop_back();
}
else if (x == '@') {
while (!st.empty()) st.pop_back();
}
else st.push_back(x);
}
f(i,0,st.size(),1) cout << st[i];
cout << endl;
}
return 0;
}