#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<iomanip>
#include<algorithm>

using namespace std;

#define debug(x) cout<< #x <<" : "<< x << endl;
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n);
#define int long long

const int INF = (1<<30);
const int MOD = (int)1e9 + 7;

const int NUM = 9;

bool check(vector<int> &a, vector<int> &b){
    int A = 0, B = 0;
    for(int i = 0; i < a.size(); i++){
        if(a[i] > b[i]) A += a[i] + b[i];
        else B += a[i] + b[i];
    }

    return A > B;
}

signed main(){
    cout<<fixed<<setprecision(7);
    int n;

    cin>>n;


    for(int i = 0; i < n; i++){
        vector<int> a(NUM),b(NUM);
        int con = 0;
        int k = 1;

        for(int j = 0; j < NUM; j++){
            cin>>a[j];
            k *= (j+1);
        }

        for(int j = 0; j < NUM; j++){
            cin>>b[j];
        }

        sort(a.begin(), a.end());

        while(true){

            bool flag = next_permutation(a.begin(), a.end());

            con += check(a, b);

            if(flag ==  false) break;
        }

        cout<<((double)con/k)<<" "<<((double)(k-con)/k)<<endl;
    }

    return 0;
}


