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

object Main {
  def main(args:Array[String]) = {
    var n = 0
    while( {n=readInt;n} != 0 ) {
      (1 to n).foreach{ _ =>
        val s = readLine.split(" ").map(_.toInt)
        val x = s(0)*s(4)-s(1)*s(5)-s(2)*s(6)-s(3)*s(7)
        val y = s(0)*s(5)+s(1)*s(4)+s(2)*s(7)-s(3)*s(6)
        val z = s(0)*s(6)+s(2)*s(4)-s(1)*s(7)+s(3)*s(5)
        val w = s(0)*s(7)+s(3)*s(4)+s(1)*s(6)-s(2)*s(5)
        println(x + " " + y + " " + z + " " + w)
      }
    }
  }
}