#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
    ll t; t=1;
    while(t--) {
        ll topCard[51];
        ll n,q; cin>>n>>q;
        for(ll i=1; i<=50; i++) topCard[i]=n+1;
        for(ll i=1; i<=n; i++) {
            ll col; cin>>col;
            if(topCard[col] == n+1) topCard[col] = i;
        }
        for(ll i=0; i<q; i++) {
            ll col; cin>>col;
            cout<<topCard[col]<<" ";
            for(ll j=1; j<=50; j++) {
                if(topCard[j]<topCard[col]) topCard[j]++;
            }
            topCard[col]=1;
        }
    }
}