#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e6+9;
int a[maxn];
int main()
{
int m,n;
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=m;i++)
{
LL num;
cin>>num;
int l = 1;
int r = n;
int ans = -1;
while(l<=r)
{
int mid = (r+l)/2;
if(a[mid]>num) r = mid-1;
else if(a[mid]<num) l = mid+1;
else
{
ans = mid;
while(a[mid]==ans)
{
ans = mid;
mid--;
}
break;
}
}
if(ans!=-1) printf("%d ",ans);
else printf("-1 ");
}
return 0;
}