#include <iostream>
using namespace std;
const int N = 1000005;
int n, m, q[N];
int find(int x)
{
int l = 0, r = n - 1;
while(l < r)
{
int mid = (l + r) / 2;
if (q[mid] >= x) r = mid;
else l = mid + 1;
}
if (q[l] == x) return l + 1;
else return -1;
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> q[i];
while (m--)
{
int x;
cin >> x;
int ans = find(x);
cout << ans << endl;
}
return 0;
}