
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val n = readLine.trim.toInt
  for (_ ← 0 until n){
    val a = readLine.trim.split(' ').map(_.toInt)
    val b = readLine.trim.split(' ').map(_.toInt)
    println(
      (a.permutations.map{c ⇒
      c.zip(b).map{
        case (a, b) if a > b ⇒ a + b
        case (a, b) ⇒ -a - b
      }.sum.let{it ⇒ if (it > 0) 1 else 0: Int}
    }.sum.toDouble / (2 to 9).fold(1){case (a, b) ⇒ a * b}
    ).let{it ⇒
        s"${it.toString.take(7)} ${(1-it).toString.take(7)}"
      }
    )
  }

  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
/*

 */
