N = int(input()) def solve(S): for i in range(len(S)): if S[i] != 0: break rev = [] for k in range(i,len(S)): rev.append(S[k]) if rev == []: return [0] else:return rev ANS = [] for _ in range(N): S = list(map(int,input().split())) ANS.append(solve(S)) for ans in ANS: print(''.join(list(map(str,ans))))