T=int(input()) for _ in range(T): s=list(input()) i=0 while i