#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define BRUTE (9*8*7*6*5*4*3*2)

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int ge[9], ja[9];

int dfs(int n, int gp, int jp, int *used){
  //  printf("%d %d %d\n", n, gp, jp);
  if(n == 9){
    if(gp > jp) return 1;
    else return 0;
  }
  int res = 0;
  rep(i, 9){
    if(used[i]) continue;
    used[i] = 1;
    res += dfs(n+1, gp + (ge[n]>ja[i]?ge[n]+ja[i]:0), jp + (ja[i]>ge[n]?ja[i]+ge[n]:0),  used);
    used[i] = 0;
  }
  return res;
}

int main(){
  int n;
  scanf("%d", &n);
  rep(i, n){
    rep(j, 9) scanf("%d", ge+j);
    rep(j, 9) scanf("%d", ja+j);
    int used[9] = {};
    int win = dfs(0, 0, 0, used);
    printf("%lf %lf\n", (double)win/BRUTE, 1-(double)win/BRUTE);
  }
  return 0;
}