chomp ($n = <>); while($n--){ chomp ($_ = <>); if ($ _ eq "00000"){ print "0"; } else { s/^0*//; print; } print "\n"; }