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|
    win += 1.0 if g.zip(card).inject(0) {|sum, a| sum += a[0]>a[1] ? a[0]+a[1] : 0} > Sum/2
  end
  printf "%.5f %.5f\n", win / All, 1.0 - win / All
end