include include include
using namespace std;
int main(){
int num;
int c,h,o,n;
int count=0;
int m;
string a;
cin>>num;
while(num--){
c=h=o=n=0;
m=0;
cin>>a;
for(int i=0;i<a.length();i++){
if(a[i]>=48&&a[i]<=57&&a[i+1]>57){
count=int(a[i]-48);
for(int j=i-1;j>=m;j--){
switch(a[j]){
case 67:c+=count;count=1;break;
case 72:h+=count;count=1;break;
case 78:n+=count;count=1;break;
case 79:o+=count;count=1;break;
}
}
m=i+1;
}else if((a[i]>=48 && a[i]<=57) && (a[i+1]>=48&&a[i+1]<=57)){
count=(int(a[i])-48)*10+int(a[i+1])-48;
i++;
for(int j=i-1;j>=m;j--){
switch(a[j]){
case 67:c+=count;count=1;break;
case 72:h+=count;count=1;break;
case 78:n+=count;count=1;break;
case 79:o+=count;count=1;break;
}
}
m=i+1;
}
}
if(m<a.length()){
for(int i=m;i<a.length();i++){
switch(a[i]){
case 67:c++;break;
case 72:h++;break;
case 78:n++;break;
case 79:o++;break;
}
}
}
cout<<fixed<<setprecision(3)<<c*12.01+h*1.008+o*16+n*14.01<<endl;
}
return 0;
}