//
//  main3.cpp
//  main3
//
//  Created by Rajveer Singh on 05/11/20.
//  Copyright © 2020 Rajveer Singh. All rights reserved.
//
 
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <time.h>
#include <chrono>
#include <array>
#include <random>
#include <ctime>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
#include <unordered_map>
#include <numeric>
 
//MARK:- PRACTICE
 
typedef long long ll;
typedef long double ld;
 
int main() {

    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    ll t;
    
    t=1;
        
    for(int i=0;i<=t-1;i++) {
        
        ll n, q;
        
        std::cin>>n>>q;
        
        std::vector<ll> a(n), b(100, -1);
        
        for(int i=0;i<=n-1;i++) {
            
            std::cin>>a[i];
            
            if(b[a[i]]==-1) {
                
                b[a[i]]=i+1;
            }
        }
        
        for(int i=0;i<=q-1;i++) {
            
            ll val;
            
            std::cin>>val;
            
            std::cout<<b[val]<<" ";
            
            for(int i=1;i<=50;i++) {
                
                if(i!=val && b[val]>b[i]) {
                    
                    if(b[i]<n) {
                        
                        b[i]++;
                    } else {
                        
                        b[i]=0;
                    }
                }
            }
            
            //1 4 3 3 3 3 9 8 2 10
            //9
            
            b[val]=1;
        }
        
        std::cout<<"\n";
    }
}