let inv a =
    let rec loop = function
        0 -> raise Not_found
        | i -> if (a*i) mod 26 = 1 then i else loop (i-1)
    in loop 26 ;;

let decode ainv b r = (ainv*(r-b+26)) mod 26;;
let rec gcd a b = if b = 0 then a else gcd b (a mod b);;

let dup a b =
    let rec loop l i =
        if i = -1 then false
        else
            let decoded = decode a b i in
            if List.mem decoded l then true
            else loop (decoded::l) (i-1)
in loop [] 25;;

let invs =
    let rec loop l = function
        0 -> l
        | i ->
            if gcd i 26 = 1 then loop ((inv i)::l) (i-1)
            else loop l (i-1)
    in loop [] 26
;;

let decrypt s =
    let f a b = String.map (fun c ->
        let cc = (Char.code c) in
        if cc >= 97 && cc <= 122 then decode a b (cc-97) |> (+) 97 |> Char.chr
        else c) in
    let rec loop = function
    [] -> ()
    | h::tl ->
            for i = 0 to 25 do
                let decrypted = (f h i s) in
                if Str.string_match (Str.regexp ".*\\(this\\|that\\).*")  decrypted 0 then
                    if not (dup h i) then
                        print_endline decrypted;
            done;
            loop tl
    in loop invs
;;

let () =
    let n = read_int () in
    let rec read = function
        0 -> ()
        | i ->
            let line = read_line () in
            decrypt line;read (i-1)
    in read n
;;