gets.to_i.times{
  s = gets
  (1..100).map{|a|
    f = nil
    (1..100).map{|b|
      t = s.gsub(/[a-z]/){|c|(?a.ord + (a * (c.ord - ?a.ord) + b) % 26).chr}
      if t["this"] || t["that"]
        puts t
        f = 1
        break
      end
    }
    break if f
  } 
}