typedef int ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
// #define int long long

signed main(){
    ll n;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        std::cin >> s;
        bool ok = false;
        if(s=="00000"){
            std::cout << 0 << std::endl;
            continue;
        }
        for (auto e : s) {
            if(ok){
                std::cout << e;
            }else{
                if(e=='0')continue;
                ok=true;
                std::cout << e;
            }
        }
        std::cout << std::endl;
    }
}