#include<stdio.h>
#include<string.h>
int main(){
char s[40];
int n,m;
scanf("%d", &m);
getchar();
while (m--){
gets(s);
n = strlen(s);
for (int i = n - 1; i >= 0; i--){
if (s[i] == ' ' || (s[i] >= '0' && s[i] <= '9')) continue;
else printf("%c", s[i]);
}
printf("\n");
}
return 0;
}
#include<string.h>
int main(){
char s[40];
int n,m;
scanf("%d", &m);
getchar();
while (m--){
gets(s);
n = strlen(s);
for (int i = n - 1; i >= 0; i--){
if (s[i] == ' ' || (s[i] >= '0' && s[i] <= '9')) continue;
else printf("%c", s[i]);
}
printf("\n");
}
return 0;
}