gcds = (1..26).select{|i| 26.gcd(i)==1}
al = ('a'..'z').to_a
gets.to_i.times.each do
  str = gets
  hits = str.split.select{ |chr| chr.length == 4 }
  @alph = gcds.find do |a|
    @beta = (0..25).find do |b|
      %w(this that).any? { |h|
        can = h.split('').map{ |ch| al[(a*al.index(ch)+b)%26] }.join
        hits.include?(can)
      }
    end
  end
  map = (0..25).map{|i| (@alph*i+@beta)%26 }
  puts str.chars.map{|st| al.include?(st) ? al[map.index(al.index(st))] : st }.join
end