All = (1..9).to_a.inject(:*).to_f
Sum = (1..18).to_a.inject(:+)
gets.to_i.times do
  g = gets.split.map(&:to_i)
  j = gets.split.map(&:to_i)
  win = 0.0
  j.sort.permutation do |card|
     point = 0
     g.zip(card) do |a, b|
       point += a + b if a > b
     end
     win += 1 if point > Sum / 2
  end
  printf "%.5f %.5f\n", win / All, 1.0 - win / All
end