#import int x[99],m,c,z,o,i;main(){for(;i++<25;)std::cin>>z,x[z]=i;for(std::cin>>i;std::cin>>z;){c|=1<