using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ0040
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;
                int N = int.Parse(input);

                for (int i = 0; i < N; i++)
                {
                    input = Console.ReadLine();
                    string[] word = input.Split(' ');
                    variable X;
                    X.a = 1; X.b = 0;
                    string[] after = new string[word.Length];
                    StringBuilder output = new StringBuilder();

                    IDictionary<char, int> alphabet = new Dictionary<char, int>();
                    alphabet['a'] = 0; alphabet['b'] = 1; alphabet['c'] = 2; alphabet['d'] = 3; alphabet['e'] = 4;
                    alphabet['f'] = 5; alphabet['g'] = 6; alphabet['h'] = 7; alphabet['i'] = 8; alphabet['j'] = 9;
                    alphabet['k'] = 10; alphabet['l'] = 11; alphabet['m'] = 12; alphabet['n'] = 13; alphabet['o'] = 14;
                    alphabet['p'] = 15; alphabet['q'] = 16; alphabet['r'] = 17; alphabet['s'] = 18; alphabet['t'] = 19;
                    alphabet['u'] = 20; alphabet['v'] = 21; alphabet['w'] = 22; alphabet['x'] = 23; alphabet['y'] = 24; alphabet['z'] = 25;


                    //???????????°?????¢?´¢
                    for (int j = 0; j < word.Length; j++)
                    {
                        if (word[j].Length == 4)
                        {
                            //?????°??????
                            X = ThatOrThis(word[j], alphabet);
                            if (X.a != 0) break;
                        }
                    }
                    //??????
                    for (int j = 0; j < word.Length; j++)
                    {
                        after[j] = Recover(word[j], alphabet, X);
                        if (j == 0)
                        {
                            output.Append(after[j]);
                        } else
                        {
                            output.Append(" ");
                            output.Append(after[j]);
                        }
                    }

                    

                    Console.WriteLine(output);
                }
            }
        }

        public struct variable {
            public int a;
            public int b;

            public variable (int x, int y)
            {
                this.a = x;
                this.b = y;
            }
        }

        static variable ThatOrThis (string str, IDictionary<char, int> alpha)
        {
            int a = 0;
            int b = 0;
            int[] num = new int[str.Length];
            for (int i = 0; i < str.Length; i++)
            {
                num[i] = alpha[str[i]];
            }
            
            for (int i = 1; i < 26; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    if (12 * i == num[0]- num[1] + 26 * j)
                    {
                        b = (26 * j + num[0] - 19 * i) % 26;
                        if (b < 0) b += 26;
                        if((num[2] == b && num[3] == num[0]) || ((8 * i + b) % 26 == num[2] && (18 * i + b) % 26 == num[3]))
                        {
                            a = i;
                            break;
                        }    
                    } else if (12 * i < num[0] - num[1] + 26 * j)
                    {
                        break;
                    }
                }
                if (a != 0) break;
            }

            return new variable (a, b);
        }

        static string Recover (string str, IDictionary<char, int> alpha, variable X)
        {
            int[] num = new int[str.Length];
            char[] chr = new char[str.Length];

            for (int i = 0; i < str.Length; i++)
            {
                for (int j = 0; j < 26; j++)
                {
                    for (int k = 0; k < 100; k++)
                    {
                        if (X.a * j == alpha[str[i]] - X.b + 26 * k)
                        {
                            num[i] = j;
                            break;
                        } else if (X.a * j < alpha[str[i]] - X.b + 26 * k)
                        {
                            break;
                        }

                    }
                    if (num[i] != 0) break;
                }
                chr[i] = alpha.FirstOrDefault(k => k.Value == num[i]).Key;
            }
            string word = new string(chr);
            return word;
        }
    }
}

Measured memory_bytes: 9680