-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLecture284B.java
More file actions
34 lines (29 loc) · 1021 Bytes
/
Lecture284B.java
File metadata and controls
34 lines (29 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Created by MalhotR1 on 02/06/2018.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class Lecture284B {
public static void main(String[] args) throws IOException {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
String[] in = br.readLine().trim().split(" ");
int n = Integer.parseInt(in[0]);
int m = Integer.parseInt(in[1]);
HashMap<String, String> hm = new HashMap<>();
for (int i = 0; i < m; i++) {
in = br.readLine().trim().split(" ");
if (in[0].length() <= in[1].length()) {
hm.put(in[0], in[0]);
} else {
hm.put(in[0], in[1]);
}
}
in = br.readLine().trim().split(" ");
for (String str : in) {
System.out.print(hm.get(str) + " ");
}
}
}
}