let af a b c = if c >= 'a' && c <= 'z' then char_of_int (((a * (int_of_char c - 97) + b) mod 26) + 97) else c

let rec seq s t = if s > t then [] else s :: seq (s + 1) t

let rec make_fs ps = function
  | [] -> []
  | f :: rest -> List.map (fun x -> f x) ps @ make_fs ps rest

let elem s1 s2 =
  let l1 = String.length s1
  and l2 = String.length s2 in
  let rec iter s t =
    if s > t then false 
    else if String.sub s2 s l1 = s1 then true 
    else iter (s+1) t in
  iter 0 (l2 - l1)

let rec decrypt s = function
  | [] -> s
  | f :: fs -> 
     let decs = String.map f s in
     if elem "this" decs || elem "that" decs then decs else decrypt s fs

let _ = 
  let fs = make_fs (seq 0 25) (List.map (fun x -> af x) [1;3;5;7;9;11;15;17;19;21;23;25]) in
  let n = read_int () in
  for i = 1 to n do
    let str = read_line () in
    print_endline (decrypt str fs)
  done