//这题虽然给了两秒,但数据很大,而且一看就必须得嵌套循环
//普通位置对应颜色的筛查应该是行不通,但这题良心的只给了
//50种颜色...这不很明显嘛,用颜色标记位置!走起~
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int color[51] = { 0 };
int n, q;
cin >> n >> q;
int eveco, * answer;//储存答案
answer = (int*)malloc(q * sizeof(int));
for (int i = 1; i <= n; i++) {//储存颜色种类对应第一次出现的位置
cin >> eveco;
if (color[eveco] == 0) {
color[eveco] = i;
}
}
int t, j = 0;
for (int i = 0; i < q; i++) {
cin >> t;
answer[j++] = color[t];//储存答案
for (int k = 1; k <= 50; k++) {
if (color[k] < color[t] && color[k] != 0) {//比筛查样例小的位置+1
color[k]++;
}
else continue;
}
color[t] = 1;//把筛查样例放在最前面
}
for (int h = 0; h < j; h++) {
cout << answer[h] << ' ';
}
return 0;
}