#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
string s;
while (n--) {
cin >> s;
int i = 0;
for (char& c : s) {
if (i == 5) {
i = 0;
continue;
}
if (c == '1') {
++i;
} else {
i = 0;
}
cout << c;
}
cout << endl;
}
return 0;
}