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

int main() {
    ll n , q;
    unordered_map<ll , ll> mp;
    cin>>n>>q;
    for(int i=1;i<=n;i++){
        int val;
        cin>>val;
        if(mp.find(val)==mp.end()){
            mp[val] = i;
        }
    }
    for(int i=0;i<q;i++){
        int val;
        cin>>val;
        int pos = mp[val];
        for(auto c: mp){
            if(c.second<pos){
                // cout<<c.second<<" ";
                
                mp[c.first] = mp[c.first]+1;
                // cout<<c.second<<endl;
            }
        }
        mp[val] = 1;
        cout<<pos<<" ";
    }
    return 0;
}
