import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); MyMap exists = new MyMap(); for (int i = 0; i < n; i++) { long x = sc.nextLong(); exists.add(x); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < m; i++) { if (i > 0) { sb.append(" "); } sb.append(exists.get(sc.nextLong())); } System.out.println(sb); } static class MyMap { Unit[][] list; public MyMap() { list = new Unit[1000][100]; } public void add(long x) { int hash = (int)(x % 1000); int idx = 0; while (list[hash][idx] != null && list[hash][idx].idx != x) { idx++; if (idx >= 100) { hash++; hash %= 1000; idx = 0; } } if (list[hash][idx] == null) { list[hash][idx] = new Unit(x, 1); } else { list[hash][idx].value++; } } public int get(long x) { int hash = (int)(x % 1000); int idx = 0; while (list[hash][idx] != null && list[hash][idx].idx != x) { idx++; if (idx >= 100) { hash++; hash %= 1000; idx = 0; } } if (list[hash][idx] == null) { return 0; } else { return list[hash][idx].value; } } } static class Unit { long idx; int value; public Unit(long idx, int value) { this.idx = idx; this.value = value; } public String toString() { return idx + ":" + value; } } }