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