/*input
3
128
255
100
*/
#include <bits/stdc++.h>
#define fastIo ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define sz size
#define pb push_back
#define mp make_pair
using namespace std;

//#define LOCAL
#ifdef LOCAL
	#define DEBUG(x) do { cout << #x << ": " << x << '\n'; } while (0)
#else
	#define DEBUG(x) 
#endif

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

string arr[105];

int main(){
	fastIo;

	int n;
	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	for(int i = n - 1; i >= 0; i--){
		int j;
		for(j = arr[i].sz() - 1; (arr[i][j] == '0' && j >= 1); j--); 
		arr[i] = arr[i].substr(0, j + 1);
		reverse(all(arr[i]));
		cout << arr[i] << '\n';
	}

	return 0;
}