#include <stdio.h>

int now[9];
/* 9!=362880 */
int list_num;
int all_list[362880][9];

void tansaku(int pos,int rest) {
	int i;
	if(pos>=9) {
		for(i=0;i<9;i++)all_list[list_num][i]=now[i];
		list_num++;
	} else {
		for(i=0;i<9;i++) {
			if(rest & (1<<i)) {
				now[pos]=i;
				tansaku(pos+1,rest & ~(1<<i));
			}
		}
	}
}

int main(void) {
	int d_num,d_cur;
	int g_cards[9];
	int j_cards[9];
	int i,j;
	int now_g,now_j;
	int g_win,j_win;
	tansaku(0,0xffff);
	scanf("%d",&d_num);
	for(d_cur=0;d_cur<d_num;d_cur++) {
		for(i=0;i<9;i++)scanf("%d",&g_cards[i]);
		for(i=0;i<9;i++)scanf("%d",&j_cards[i]);
		g_win=j_win=0;
		for(i=0;i<list_num;i++) {
			now_g=now_j=0;
			for(j=0;j<9;j++) {
				if(g_cards[j]>j_cards[all_list[i][j]]) {
					now_g+=g_cards[j]+j_cards[all_list[i][j]];
				} else {
					now_j+=g_cards[j]+j_cards[all_list[i][j]];
				}
			}
			if(now_g>now_j)g_win++;
			else if(now_j>now_g)j_win++;
		}
		printf("%.15f %.15f\n",
			(double)g_win/list_num,(double)j_win/list_num);
	}
	return 0;
}