#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<map>

std::map<char, char*> vars;
char c, s[105], *vs;

char* next() {
	vs+=2;
	return vars[*vs];
}

int main(){
	int n;
	scanf("%d ", &n);
	while(n--){
		scanf("%c=%s ", &c, s);
		vars[c] = strdup(s);
	}
	fgets(s, 105, stdin);

	vs = strchr(s, ',') - 1;
	vs[1] = 0;

	char *w = strtok(s, " ");
	for(int argp = 0; w != NULL; w = strtok(NULL, " ")){
		char type = w[strlen(w) - 1];
		if(w[0] != '%')
			printf(w);
		else if(type == 's')
			printf(w, next());
		else if(type == 'd')
			printf(w, atoi(next()));
		else
			printf(w, atof(next()));
		putchar(' ');
	}

	return 0;
}