728x90
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;
public class PocketMonster {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine()," ");
int n = Integer.parseInt(st.nextToken());
int m = Integer.parseInt(st.nextToken());
String monster ="";
int num = 1;
HashMap <String, String> stoi = new HashMap<>();
for(int i=0; i<n; i++){
monster =br.readLine();
stoi.put(monster, Integer.toString(num));
stoi.put(Integer.toString(num),monster);
num++;
}
String line;
for(int i=0; i<m; i++){
line = br.readLine();
System.out.println(stoi.get(line));
}
}
}