// this answer satisfies the question given in the link , but it still shows wrong why?? #include
using namespace std;
int n;
int y=0;
int main() {
int t;
cin>>t;
int c[1000000];
while(t--){
cin>>n;
int x=0;
int i=0;
while(n){
c[i] = n%10;
n/=10;
i++;
x++;
}
int a[10];
int y=0;
for(int i=0;i<x;i++){
if(c[i]!=c[i-1]){
a[y]=c[i];
y++;
}
}
for(int i=0;i<y;i++){
cout<<a[i];
}
cout<<endl;
}
return 0;