#include<stdio.h> int main() { int N,n,i,j,s,cheat,step; int f[1000001][2],b[1000001]; scanf("%d",&N); for(step=1;step<=N;step++) { scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d=%d",&f[i][1],&f[i][2]); scanf("%d",&cheat); for(i=1;i<=cheat;i++) scanf("%d",&b[i]); for(i=1;i<=cheat;i++) { A:{for(j=1;j<=n;j++) { for(s=1;s<=2;s++) { if(b[i]==f[j][s]) { printf("%d\n",f[j][s%2+1]); i++; if(i>cheat) goto B; else if(i<=cheat) goto A; } } } } if(j==n+1&&s==3) printf("UNKONW\n"); } B:; } return 0; } |
Double click to view unformatted code.