
def revert_cipher(str, a, b)
  a %= 26
  new = Array.new
  ary = str.unpack("c*")
  ary.each {|c|
    if c == 0x20 then
      new.push(c)
      next
    end
    i = c - 0x61
    i -= b
    while (i < 0) do i += 26 end
    found = true
    26.times {|n|
      break if i % a == 0
      found = false if n == 25
      i += 26
    }
    return "" if not found
    i /= a
    i += 0x61
    new.push(i)
  }
  return new.pack("c*")
end

# that -> +19 +7 +0 +19
# i1 = (19 * a + b) mod 26
# i2 = (7 * a + b)  mod 26
# i3 = b
#
# i1 = (19 * a + i3) mod 26
# 19 * a = i1 * 26 * n - i3
# i1 * 26 * n - i3 が19の倍数になる時の値がa
def find_that(str)
  ary = str.unpack("c*")
  pos = 0
  i_ary = Array.new
  ary.each { |c|
    if (c == 0x20) then
      pos = 0
      next
    end
    next if pos >= 4 # 4文字以上の領域はスキップする
    i_ary[pos] = c - 0x61
    pos += 1
    if (pos == 4) then
      next if i_ary[0] != i_ary[3]
      a19 = i_ary[0] - i_ary[2]
      while (a19 < 0) do a19 += 26 end
      found = true
      26.times {|i|
          break if a19 % 19 == 0
          found = false if i == 25
          a19 += 26
      }
      next if not found
      a = a19 / 19
      next if i_ary[1] != (a * 7 + i_ary[2]) % 26
      return [a, i_ary[2]]
    end
  }
  return []
end

# this -> +19 +7 +8 +18
# i1 = (19 * a + b) mod 26
# i2 = (7 * a + b) mod 26
# i3 = (8 * a + b) mod 26
# i4 = (18 * a + b) mod 26
#  i1 - i4 = (19a + b) - (18a +b)
#  i1 - i4 = a
def find_this(str)
  ary = str.unpack("c*")
  pos = 0
  i_ary = Array.new
  ary.each { |c|
    if (c == 0x20) then
      pos = 0
      next
    end
    next if pos >= 4 # 4文字以上の領域はスキップする
    i_ary[pos] = c - 0x61
    pos += 1
    if (pos == 4) then
      i1 = i_ary[0]
      i3 = i_ary[2]
      i1 += 26 if i_ary[0] < i_ary[3]
      i1i4 = i1 - i_ary[3]
      i3 += 26 if i_ary[2] < i_ary[1]
      i3i2 = i3 - i_ary[1]
      next if i1i4 != i3i2
      b = i_ary[1] - i1i4 * 7
      while (b < 0) do b += 26 end
      next if i_ary[0] != (i1i4 * 19 + b) % 26
      next if i_ary[2] != (i1i4 * 8 + b) % 26
      next if i_ary[3] != (i1i4 * 18 + b) % 26
      return [i1i4, b]
    end
  }
  return []
end

lines = STDIN.gets.chomp
lines.to_i.times {|i|
  str = STDIN.gets.chomp
  ab = find_that(str)
  ab = find_this(str) if ab.empty?
  puts revert_cipher(str, ab[0], ab[1]) if not ab.empty?
}