#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6+14;
int n,m;
map < int , int > mp;
void solve(){
cin >> n >> m;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
mp[x] = i;
}
for (int i = 1; i <= m; i++){
int x;
cin >> x;
if (!mp[x]) {
cout << -1 << '\n';
}
else cout << mp[x] << '\n';
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen("input.txt","r")){
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
}
solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBtYXhuPTFlNisxNDsKaW50IG4sbTsKbWFwIDwgaW50ICwgaW50ID4gbXA7CnZvaWQgc29sdmUoKXsKCWNpbiA+PiBuID4+IG07Cglmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIHsKCQlpbnQgeDsKCQljaW4gPj4geDsKCQltcFt4XSA9IGk7Cgl9CgkKCWZvciAoaW50IGkgPSAxOyBpIDw9IG07IGkrKyl7CgkJaW50IHg7CgkJY2luID4+IHg7CgkJaWYgKCFtcFt4XSkgewoJCQljb3V0IDw8IC0xIDw8ICdcbic7CgkJfQoJCWVsc2UgY291dCA8PCBtcFt4XSA8PCAnXG4nOwoJfQp9CmludCBtYWluKCl7Cglpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwoJY2luLnRpZSgwKTsgICAgY291dC50aWUoMCk7CglpZiAoZm9wZW4oImlucHV0LnR4dCIsInIiKSl7CgkJZnJlb3BlbigiaW5wdXQudHh0IiwiciIsc3RkaW4pOwoJCWZyZW9wZW4oIm91dHB1dC50eHQiLCJ3IixzdGRvdXQpOwoJfQoJc29sdmUoKTsKCXJldHVybiAwOwp9Cg==