#include<iostream>
#include<algorithm>
using namespace std;
int a[9], b[9], c[9] = { 0,1,2,3,4,5,6,7,8 };
int main() {
	int n; cin >> n;
	for (int v = 0; v < n; v++) {
		for (int i = 0; i < 18; i++) { if (i < 9)cin >> a[i]; else cin >> b[i - 9]; }
		int cnt = 0; sort(a, a + 9); sort(b, b + 9);
		do {
			int c2 = 0;
			for (int i = 0; i < 9; i++) {
				if (a[i] > b[c[i]])c2 += a[i] + b[c[i]];
			}
			if (c2 > 85)cnt++;
		} while (next_permutation(c, c + 9));
		printf("%.5f %.5f\n", 1.0*cnt / 362880, 1.0 - 1.0*cnt / 362880);
	}
}