/*
Mail to : miyubai@gamil.com
My Blog : www.baiyun.me
Link : http://www.cnblogs.com/MiYu || http://www.cppblog.com/MiYu
Author By : MiYu
Test : 1
Complier : g++ mingw32-3.4.2
Program : HDU_3082
Doc Name : Simplify The Circuit
*/
//#pragma warning( disable:4789 )
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <queue>
#include <stack>
#include <list>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;
char str[110];
char *tok;
int main ()
{
int T;
scanf ( "%d",&T );
while ( T -- ) {
int N;
double res = 0;
scanf ( "%d", &N );
for ( int i = 1; i <= N; ++ i ) {
scanf ( "%s", str );
tok = strtok ( str, "-" );
int t = atoi ( tok );
int r = t;
while ( tok = strtok ( NULL, "-" ) ) {
t = atoi ( tok );
r += t;
}
res += 1.0 / r;
}
printf ( "%.2lf\n", 1.0 / res );
}
return 0;
}