#include using namespace std; int n,i,j; char st[111]; string s,t; vector a; map m; int main() { scanf("%d",&n); gets(st); while (n--) { gets(st); s=t=""; for (i=0; st[i]; i++) if (st[i]=='=') { s=t; t=""; } else t+=st[i]; m[s]=t; } gets(st); s=""; for (i=0; st[i]!=',' && st[i]; i++); if (st[i]==0) { puts(st); return 0; } for (i++; st[i]; i++) if (st[i]==',') { a.push_back(m[s]); s=""; } else s+=st[i]; a.push_back(m[s]); s=""; for (i=j=0; ; i++) if (st[i]==' ' || st[i]==',') { if (s[0]=='%') { if (s[int(s.length())-1]=='d') { istringstream ss(a[j]); int x; ss>>x; printf(s.c_str(),x); } else if (s[int(s.length())-1]=='f') { istringstream ss(a[j]); double x; ss>>x; printf(s.c_str(),x); } else printf("%s",a[j].c_str()); j++; } else printf("%s",s.c_str()); if (st[i]==',') break; putchar(' '); s=""; } else s+=st[i]; putchar('\n'); return 0; }