//卡格式的题目
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int T,i;
double money,sum,overage;
cin >> T;
while (T--){
sum = 0.00;
for (i = 0; i < 12; i++){
cin >> money;
sum += money;
}
overage = sum/12;
int m = (overage + 0.005) * 100; //比如1.002变为100,1.005变为101此处四舍五入法则
cout << "$"; //掉了这个会一直WA下去
if (m % 100 == 0) //说明两位小数都为0
cout << setiosflags(ios::fixed) << setprecision(0) <<overage<< endl;
else if (m % 10 == 0) //说明最后一位小数位0
cout << setiosflags(ios::fixed) << setprecision(1) << overage << endl;
else //否则最后两位不为0
cout << setiosflags(ios::fixed) << setprecision(2) << overage << endl;
}
return 0;
}