#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N;
	cin >> N;
	string S;
	bool c;
	for(int i = 0; i < N; i++)
	{
		cin >> S;
		c = false;
		if(S == "00000") cout << 0 << endl;
		else
		{
			for(int i = 0; i < 5; i++)
			{
				if(c) cout << S[i];
				else
				{
					if(S[i] != '0')
					{
						c = true;
						cout << S[i];
					}
				}
			}
			cout << endl;
		}
	}
	return 0;
}