#include<bits/stdc++.h>
using namespace std;
bool isnum(char c){
if(c>='0'&&c<='9')return 1;
else return 0;
}
main(){
int t;
double ans=0;
string s;
string numline;
cin>>t;
while(t--){
cin>>s;
for(int i=0;i<s.size();++i){
if(isnum(s[i]))continue;
int j=i+1;
if(s[i]=='C'){
if(isnum(s[j])){
while(isnum(s[j])){
numline+=s[j];
j++;
if(j>s.size())break;
}
stringstream ss;
ss<<numline;
int temp;
ss>>temp;
numline.clear();
ans+=12.01*temp;
//cout<<"*"<<ans<<"*"<<endl<<"#"<<i<<endl;
}
else {
ans+=12.01;
//cout<<"*"<<ans<<"*"<<endl<<i<<endl;
}
}
if(s[i]=='H'){
if(isnum(s[j])){
while(isnum(s[j])){
numline+=s[j];
j++;
if(j>s.size())break;
}
stringstream ss;
ss<<numline;
int temp;
ss>>temp;
numline.clear();
ans+=1.008*temp;
//cout<<"*"<<ans<<"*"<<endl<<"#"<<i<<endl;
}
else {
ans+=1.008;
//cout<<"*"<<ans<<"*"<<endl<<i<<endl;
}
}
if(s[i]=='O'){
if(isnum(s[j])){
while(isnum(s[j])){
numline+=s[j];
j++;
if(j>s.size())break;
}
stringstream ss;
ss<<numline;
int temp;
ss>>temp;
numline.clear();
ans+=16.00*temp;
//cout<<"*"<<ans<<"*"<<endl<<"#"<<i<<endl;
}
else {
ans+=16.00;
//cout<<"*"<<ans<<"*"<<endl<<i<<endl;
}
}
if(s[i]=='N'){
if(isnum(s[j])){
while(isnum(s[j])){
numline+=s[j];
j++;
if(j>s.size())break;
}
stringstream ss;
ss<<numline;
int temp;
ss>>temp;
numline.clear();
ans+=14.01*temp;
//cout<<"*"<<ans<<"*"<<endl<<"#"<<i<<endl;
}
else {
ans+=14.01;
//cout<<"*"<<ans<<"*"<<endl<<i<<endl;
}
}
}
//cout<<ans<<endl;
printf("%.3lf",ans);
cout<<endl;
ans=0;
}
}