import scala.io.StdIn.{readInt,readLine}

object Main {
  val alist = List(1,3,5,7,9,11,13,15,17,19,21,23,25)
  val blist = 0 to 25
  def inv(a:Int) = (0 to 25).find( i => (i*a) % 26 == 1).getOrElse(0)
  def encode(c:Int,a:Int,b:Int) = (((a*(c-97)+b) % 26)+97).toChar
  def decode(c:Int,a:Int,b:Int) = ((a*(c-97-b+26) % 26)+97).toChar

  def main(args:Array[String]) = {
    val n = readInt
    for(i <- 0 until n) {
      val l = readLine
      val (a,b) = {for(i<-alist;j<-blist) yield (i,j)}.find{ case (i,j) =>
            l.contains("that".map{encode(_,i,j)}) || l.contains("that".map{encode(_,i,j)})
      }.getOrElse((0,0))
      println( l.map { c=> if(c>=97 && c<=122) decode(c,inv(a),b) else c })
    }
  }
}