#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream f("mian.in");
char v[105];
int main()
{
   cin.getline(v,101);
   while(v[0])
   {
       int s=0;
       int rap=1,ok=1;
       char *p;
       p=strstr(v,"char");
       if(p)
        {
            rap=1;
            ok=0;
        }
        if(ok==1)
       p=strstr(v,"short");
       if(p && ok==1)
        {
            rap=2;
            ok=0;
        }
        if(ok==1)
        p=strstr(v,"int");
       if(p && ok==1)
        {
            rap=4;
        }
        p=strstr(p," ");
        int pro=1;
        for(int i=0;i<strlen(p);i++)
        {
            if(p[i]=='[')
                {
                    i++;
                    int nr=0;
                    while(p[i]<='9' && p[i]>='0')
                        {
                            nr=nr*10 + p[i]-'0';
                            ++i;
                        }
                    pro*=nr;

                }
            if(p[i]==',')
            {
                s+=rap*pro;
                pro=1;
            }
        }
        s+=rap*pro;
        cout<<p<<' '<<s<<'\n';
        cin.getline(v,101);
   }



    return 0;
}