#include<stdio.h>
void inPut(char hand[][7],char eyes[][7],char mouth[][7],int *num);
void inPut(char hand[][7],char eyes[][7],char mouth[][7],int *num){
int i = 1,j = 1,k = 1;
char c;
while( (c=getchar()) != '\n'){
if(c == '['){
num[0] = i;
scanf("%[^]]",hand[i++]);
}
}
while( (c=getchar()) != '\n'){
if(c == '['){
num[1] = j;
scanf("%[^]]",eyes[j++]);
}
}
while( (c=getchar()) != '\n'){
if(c == '['){
num[2] = k;
scanf("%[^]]",mouth[k++]);
}
}
}
int main(){
char hand[11][7];
char eyes[11][7];
char mouth[11][7];
int num[3] = {0,0,0};
inPut(hand,eyes,mouth,num);
int K;
int leftHand;
int leftEyes;
int mouthIndex;
int rightEyes;
int rightHand;
scanf("%d",&K);
for(int i = 0;i < K;K++){
scanf("%d %d %d %d %d",&leftHand,&leftEyes,&mouthIndex,&rightEyes,&rightHand);
if(leftHand > num[0] || rightHand > num[0] || leftEyes > num[1] || rightEyes > num[1] || mouthIndex > num[2]){
printf("Are you kidding me? @\\/@");
}else{
printf("%s(%s%s%s)%s",hand[leftHand],eyes[leftEyes],mouth[mouthIndex],eyes[rightEyes],hand[rightHand]);
printf("\n");
}
}
return 0;
}