#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(int a[],int b[],int c[],int p){
  int i;
  int m=0,n=0,s=0;
  if(p==9){
    for(i=0;i<9;i++){
      if(a[i]<b[c[i]])
	n+=a[i]+b[c[i]];
      else
	m+=a[i]+b[c[i]];
    }
    return m>n;
  }
  for(i=0;i<9;i++){
    if(c[i]==-1){
      c[i]=p;
      s+=f(a,b,c,p+1);
      c[i]=-1;
    }
  }
  return s;
}
int main(){
  int i,j;
  int a[9],b[9],c[9],n,s;
  cin>>n;
  for(i=0;i<n;i++){
    for(j=0;j<9;j++)
      cin>>a[j];
    for(j=0;j<9;j++)
      cin>>b[j];
    memset(c,-1,sizeof(c));
    s=f(a,b,c,0);
    printf("%.5lf %.5lf\n",(double)s/(9*8*7*6*5*4*3*2),(double)(9*8*7*6*5*4*3*2-s)/(9*8*7*6*5*4*3*2));
  }
  return 0;
}