#include<bits/stdc++.h>
using namespace std;
long long a[100000],x,dem[10000000],n,m;
int main() {
cin>>n>>m;
for(int i=1; i<=n; i++)
cin>>a[i];
for(int i=n; i>=1; i--)
dem[a[i]]=i;
for(int i=1; i<=m; i++){
cin>>x;
cout<<dem[x]<<" ";
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKbG9uZyBsb25nIGFbMTAwMDAwXSx4LGRlbVsxMDAwMDAwMF0sbixtOwppbnQgbWFpbigpIHsKCWNpbj4+bj4+bTsKCWZvcihpbnQgaT0xOyBpPD1uOyBpKyspCgljaW4+PmFbaV07Cglmb3IoaW50IGk9bjsgaT49MTsgaS0tKQoJZGVtW2FbaV1dPWk7Cglmb3IoaW50IGk9MTsgaTw9bTsgaSsrKXsKCQljaW4+Png7Cgljb3V0PDxkZW1beF08PCIgIjsKCX0KCXJldHVybiAwOwp9