//ceil(a/b) is equal to (a+b-1)/b
#include<bits/stdc++.h>
 
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define int long long int
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define vec vector <int>
#define pr vector<pair<int,int>> 
#define vecv vector <vec>
#define vecs vector <string>
#define vecc vector <char>
 
#define pi 3.141592653589793238
#define mod 1000000007
#define Mod 998244353
#define inf 1e16
#define precise(i) fixed << setprecision(10) << i
#define endl "\n"
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define one cout<<-1<<endl;

#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;
#define loop(a) for(auto xyz:a)
#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(i,a,b) for(int i=b;i>=a;i--)

const long double eps = 1e-8;

#define lb lower_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS >= OUR VALUE 
#define ub upper_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS > OUR VALUE 
 
using namespace std;
 
signed main() {
     fastio
     int t=1;
     //cin>>t;
    // while(t--)
     {
         int n,q;
        cin>>n>>q;
        vec v(n);
        for(auto &i:v)
        cin>>i;
        vec col(53,inf);
        f(i,0,n)
        {
            if(col[v[i]]>i+1)
            col[v[i]]=i+1;
        }
       // cout<<col[1]<<endl;
        while(q--)
        {
            int x;
            cin>>x;
            cout<<col[x]<<" ";
           
            
            f(i,0,53)
            {
                if(col[i]<col[x])
                col[i]+=1;
            }
            
            col[x]=1;
        }
        
        
     }
}