#include #include #include #include #include #include #include #include #include #include #include using namespace std; map dir; queue a[100100]; int main() { int n,m; while (scanf("%d%d",&n,&m) != EOF) { int k; for (int i = 1;i <= n; i++) { scanf("%d",&k); if (!dir.count(k)) dir[k] = dir.size(); a[dir[k]].push(i); } for (int i = 1;i <= m; i++) { scanf("%d",&k); if (dir.count(k) && !a[dir[k]].empty()) { int ans = a[dir[k]].front();a[dir[k]].pop(); printf("%d\n",ans); } else { printf("%d\n",-1); } } for (int i = 0;i < dir.size(); i++) { while (!a[i].empty()) a[i].pop(); } dir.clear(); } return 0; }