#include <bits/stdc++.h>
using namespace std;

const int N = 300010;

int a[N], mi[52];
int n, q;

void init()
{
	for (int i = 0; i <= 51; i ++ )
	{
		mi[i] = 1e7;
	}
}

int main()
{
	cin >> n >> q;
	init();
	for (int i = 1; i <= n; i ++ )
	{
		cin >> a[i];
		mi[a[i]] = min(mi[a[i]], i);
	}
	for (int i = 0; i < q; i ++ )
	{
		int x;
		cin >> x;
		int pos = mi[x];
		cout << pos << ' ';
		mi[x] = 1;
		for (int i = 1; i <= 51; i ++ )
		{
			if (i != x && mi[i] < pos) mi[i] ++;
		}
	}
	return 0;
}