#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define mod 1000000007
int prime[1000009];
void prime_seive()
{
   for(int i=2;i*i<1000009;i++)
   {
      if(!prime[i])
      {
         for(int j=i*i;j<1000009;j+=i)
          prime[j]=1;
      }
   }
}
long long myceil_ll(long long a,long long b)
{
   return (a+b-1)/b;
}
int myceil_int(int a,int b)
{
   return (a+b-1)/b;
}
void found(int key,int pos,int n,int &lcount,int &rcount)
{
   long long low=0,high=n;
   //if(b<0)return false;
   int count=0;
        while(low<high)
        {
           long long mid=(low+high)/2;
        //cout << low << " " << mid << " " << high << endl;
           if(mid>pos)
           {
             rcount++;high=mid;
           }
           else if(mid<pos)
           {
             lcount++;low=mid+1;
           }
           else
            return ;
        }
        return;
}
bool is_ans(int temp)
{
   int po=sqrt(temp);
   if(po*1ll*po==temp)
    return true;
  return false;
}
bool isvalid(char grid[][4],int r,int c)
{
   if(r<0 || r>=4 || c<0 || c>3)
    return false;
   if(grid[r][c]=='p'|| grid[r][c]=='X')
    return false;
   return true;
}
void findpath(char grid[][4],int i,int j,int& found)
{
   // cout << i << " " << j << endl;
    if(!isvalid(grid,i,j))return;
    if(grid[i][j]=='g')
    {
      cout << i << " " << j << endl;
      found=true;
      return;
    }
    if(isvalid(grid,i+1,j))
      findpath(grid,i+1,j,found);
    if(found)
    {
       cout << i << " " << j << endl;
       return ;
    }
    if(isvalid(grid,i,j+1))
      findpath(grid,i,j+1,found);
    if(found)
    {
      cout << i << " " << j << endl;
      return;
    }

}
bool equal(vector<int> diff)
{
   for(int i=1;i<diff.size();i++)
   {
     if(diff[i]!=diff[i-1])return false;
   }
   return true;
}
int LCSubStr(char* X, char* Y, int m, int n)
{
    // Create a table to store
    // lengths of longest
    // common suffixes of substrings.  
    // Note that LCSuff[i][j] contains
    // length of longest common suffix
    // of X[0..i-1] and Y[0..j-1].
 
    int LCSuff[m + 1][n + 1];
    int result = 0; // To store length of the
                    // longest common substring
 
    /* Following steps build LCSuff[m+1][n+1] in
        bottom up fashion. */
    for (int i = 0; i <= m; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            if (i == 0 || j == 0)
                LCSuff[i][j] = 0;
 
            else if (X[i - 1] == Y[j - 1]) {
                LCSuff[i][j] = LCSuff[i - 1][j - 1] + 1;
                result = max(result, LCSuff[i][j]);
            }
            else
                LCSuff[i][j] = 0;
        }
    }
    return result;
}
int partition(int arr[],int start,int end)
{
   int pivot = start+rand()%(end-start+1);
   swap(arr[pivot],arr[end]);
   int greater_index=start;
   for(int i=start;i<end;i++)
   {
     if(arr[i]<arr[end])
      {
        swap(arr[i],arr[greater_index]);
        greater_index++;
      }
   }
   swap(arr[greater_index],arr[end]);
   return greater_index;
}
void quick_sort(int arr[],int start,int end,int n)
{
   if(start>=end)return;
   int pivot = partition(arr,start,end);
   quick_sort(arr,start,pivot-1,n);
   quick_sort(arr,pivot+1,end,n);
}
int len(long long num)
{
   int count=0;
   while(num>0)
   {
     num/=10;
     count++;
   }
   return count;
}
int ok(string &curr,string &prev)
{
  //cout << "I" << endl;
  string  a=curr;
  string b=prev;
  int times=b.size()-a.size();
  if(times<=0)return 0;
  string another=curr;
  for(int i=0;i<times;i++)
   {
      another.push_back('0');
   }
  if(another>prev)
    {
      curr=another;
      return times;
    }
  for(int i=0;i<times;i++)
     {
      a.push_back('9');
    }
  if(a>prev)
  {
    curr=prev;
    char ch=curr.back();
    curr.pop_back();
    int num=ch-'0';
    num++;
    curr.push_back(num+'0');
    return times;
  }
  return 0;
}
long long fact(int num)
{
  long long prod=1;
  for(int i=2;i<=num;i++)
  {
    prod*=i;
    prod%=mod;
  }
  return prod;
}
int len(int num)
{
   int count=0;
   while(num>0)
   {
     count++;
     num/=10;
   }
   return count;
}
int power(int a,int b)
{
   int ans=1;
   for(int i=0;i<b;i++)
     ans*=a;
   return ans;
}
void update(int color[],int col)
{
   for(int i=1;i<51;i++)
   {
     if(color[i]!=0 && color[i]<color[col])color[i]++;
   }
   color[col]=1;
}
void t_c()
 {
   int n;
   cin >> n;
   int q;
   cin >> q;
   int arr[n];
   for(int i=0;i<n;i++)
     cin >> arr[i];
   int color[51]={0};
   for(int i=0;i<n;i++)
   {
     if(color[arr[i]]==0)
     {
       color[arr[i]]=i+1;
     }
   }
  //  for(int i=1;i<5;i++)
  //   cout << color[i] << " ";
  // cout << endl;
   for(int i=0;i<q;i++)
   {
      int col;cin >> col;
      cout << color[col] << " ";
      update(color,col);
   }
 }
int main()
{
   //prime_seive();
  /*
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  */
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t=1;
  //cin >> t;
  for(int i=0;i<t;i++)
  {
     t_c();
  }
}