n = gets.to_i
n.times do
  prob = 0
  a = gets.split.map(&:to_i)
  gets.split.map(&:to_i).permutation(9).each do |b|
    score = [0, 0]
    (0..8).each do |i|
      score[a[i] > b[i] ? 0 : 1] += a[i] + b[i]
    end
    prob += 1.0 if score[0] > score[1]
  end
  prob /= (1..9).to_a.inject(:*)
  printf("%07f %07f\n", prob, 1 - prob)
end
