while gets do
  $_.to_i.times do
    l = gets
    line = l
    a,b = 1,1
    while line !~ /th(at|is)/
      line = l.unpack("C*").map{|n|
        n = (n >= 97 and n <= 122) ? (a*n+b)%26+97 : n
      }.pack("C*")
      b=(b+1)%26
      if b==0
        begin
          a+=1
        end while a.gcd(26) != 1
      end
    end
    puts line
  end
end