You have a card deck of n cards, numbered from top to bottom, i. e. the top card has index 1 and bottom card — index n. Each card has its color: the i-th card has color a_i.

You should process q queries. The j-th query is described by integer t_j. For each query you should: 

  * find the highest card in the deck with color t_j, i. e. the card with minimum index; 
  * print the position of the card you found; 
  * take the card and place it on top of the deck. 

Input

The first line contains two integers n and q (2 ≤ n ≤ 3 ⋅ 10^5; 1 ≤ q ≤ 3 ⋅ 10^5) — the number of cards in the deck and the number of queries.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 50) — the colors of cards.

The third line contains q integers t_1, t_2, ..., t_q (1 ≤ t_j ≤ 50) — the query colors. It's guaranteed that queries ask only colors that are present in the deck.

Output

Print q integers — the answers for each query.

Example

Input


7 5
2 1 1 4 3 3 1
3 2 1 1 4


Output


5 2 3 1 5 

Note

Description of the sample: 

  1. the deck is [2, 1, 1, 4, \underline{3}, 3, 1] and the first card with color t_1 = 3 has position 5; 
  2. the deck is [3, \underline{2}, 1, 1, 4, 3, 1] and the first card with color t_2 = 2 has position 2; 
  3. the deck is [2, 3, \underline{1}, 1, 4, 3, 1] and the first card with color t_3 = 1 has position 3; 
  4. the deck is [\underline{1}, 2, 3, 1, 4, 3, 1] and the first card with color t_4 = 1 has position 1; 
  5. the deck is [1, 2, 3, 1, \underline{4}, 3, 1] and the first card with color t_5 = 4 has position 5. 
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main{
    static InputReader sc;
    static PrintWriter pw;
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        sc = new InputReader(inputStream);
        pw = new PrintWriter(outputStream);
        solve();
        pw.close();
    }
    // static int L,R,top,bottom;
    // static int cnt,edge;
    // static long ans;
    public static void solve() {
        // int t=sc.nextInt();           
        int t=1;
        u:while(t-->0){ 
            int n=s(0);
            int q=s(0);            
            int []arr=new int [n];
            int []idx=new int [51];
            Arrays.fill(idx,Integer.MAX_VALUE);
            feedArr(arr);
            for(int i=0;i<n;i++)
                if(idx[arr[i]]==Integer.MAX_VALUE){
                    idx[arr[i]]=i+1;
                }      
            int p,ans;      
            while(q-->0){
                p=s(0);
                ans=idx[p];
                for(int i=0;i<51;i++)
                    if(idx[i]<ans)
                        idx[i]++;
                idx[p]=1;
                p(ans+" ");
            }
            pln("");            
        }       
    }      
    public static int find(int n){
        return (n*(n+1))/2;
    } 
    public static long helper(int i, int k, int d, long [][][]dp, long MOD, long val, int n){
        if(i>n||i<=0||k==1){
            return val;
        }
        if(dp[i][k][d]!=-1l){            
            return dp[i][k][d];
        }
        if(d==0){
            dp[i][k][0]=helper(i+1,k,0,dp,MOD,val,n);
            if(k>1)
                dp[i][k][0]=(dp[i][k][0]+helper(i-1, k-1, 1, dp, MOD, val, n))%MOD;
            return dp[i][k][0];
        }
        dp[i][k][1]=helper(i-1,k,1,dp,MOD,val,n);
        if(k>1)
            dp[i][k][1]=(dp[i][k][1]+helper(i+1, k-1, 0, dp, MOD, val, n))%MOD;
        return dp[i][k][1];        
    }
    public static long sum(long n){
        long val=0l;
        while(n>0){
            val+=n%10;
            n/=10;
        }
        return val;
    }
    static class Node{
        int left,right;
        Node prev,next;
        Node(int i, int v){
            left=i;
            right=v;
            prev=next=null;
        }
        void remove(){
            this.prev.next=this.next;
            this.next.prev=this.prev;
        }
        void insert(Node node){
            node.next=this;
            node.prev=this.prev;
            node.prev.next=node;
            this.prev=node;
        }
    } 
    public static int  findDiameter(int r, List<List<Integer>>list){
        return findFarthest(findFarthest(r,list)[0],list)[1];
    }
    public static int[] findFarthest(int u, List<List<Integer>>list){
        int n=list.size();
        boolean []vis=new boolean[n+1];
        Queue<Integer>q=new LinkedList<>();
        q.offer(u);
        vis[u]=true;
        int s,pr,cnt=0;
        int []ar=new int[]{u,0};
        while(q.size()>0){
            s=q.size();
            while(s-->0){
                pr=q.poll();
                if(ar[1]<cnt){
                    ar[1]=cnt;
                    ar[0]=pr;
                }
                for(int i:list.get(pr)){
                    if(!vis[i]){
                        vis[i]=true;
                        q.offer(i);
                    }
                }
            }
            cnt++;
        }
        return ar;
    }
    public static long atMostK(char []chrr, int k){
        if(k<0)
            return 0;
        int l=0,cnt=0;
        long ans=0l;
        for(int i=0;i<chrr.length;i++){
            if(chrr[i]=='1')
                cnt++;
            while(cnt>k){
                if(chrr[l++]=='1')
                    cnt--;
            }
            ans+=(long)(i-l)+1l;
        }
        return ans;
    }
    public static int ask(int l){
        System.out.println(l);
        System.out.flush();
        return sc.nextInt();
    }
    public static void sort(long []arr){
        ArrayList<Long> list=new ArrayList<>();
        for(int i=0;i<arr.length;i++)
            list.add(arr[i]);
        Collections.sort(list);
        for(int i=0;i<arr.length;i++)
            arr[i]=list.get(i);
    }
    public static void swap(char []chrr, int i, int j){
        char temp=chrr[i];
        chrr[i]=chrr[j];
        chrr[j]=temp;
    }
    public static int countSetBits(long n){
        int a=0;
        while(n>0){
            a+=(n&1);
            n>>=1;
        }
        return a;
    }
    static class Pair{
        int v,w;
        Pair(int W, int V){
            v=V;
            w=W;
        }
     //*
    }
    /*/
        public int compareTo(Pair p){
            return (b-p.b);
        }
        public int hashCode(){
            int hashcode = (a+" "+b).hashCode();
            return hashcode;
        }
        public boolean equals(Object obj){
            if (obj instanceof Pair) {
                Pair p = (Pair) obj;
                return (p.a==this.a && p.b == this.b);
            }
            return false;
        }
    }
    //*/
    static boolean isPrime(int n) { 
        if (n <= 1) 
            return false; 
        if (n <= 3) 
            return true; 
        if (n % 2 == 0 || n % 3 == 0) 
            return false; 
        for (int i = 5; i * i <= n; i = i + 6) 
            if (n % i == 0 || n % (i + 2) == 0) 
                return false; 
        return true; 
    } 
    static long gcd(long a, long b) { 
        if (b == 0) 
            return a; 
        return a>b?gcd(b, a % b):gcd(a, b % a);  
    } 
    static long fast_pow(long base,long n,long M){
        if(n==0)
           return 1;
        if(n==1)
        return base;
        long halfn=fast_pow(base,n/2,M);
        if(n%2==0)
            return ( halfn * halfn ) % M;
        else
            return ( ( ( halfn * halfn ) % M ) * base ) % M;
    }
    static long modInverse(long n,long M){
        return fast_pow(n,M-2,M);
    }
    public static int s(int n){
        return sc.nextInt();
    }
    public static long s(long n){
        return sc.nextLong();
    }
    public static String s(String n){
        return sc.next();
    }
    public static double s(double n){
        return sc.nextDouble();
    }
    public static void p(int n){
        pw.print(n);
    }
    public static void p(long n){
        pw.print(n);
    }
    public static void p(String n){
        pw.print(n);
    }
    public static void p(double n){
        pw.print(n);
    }
    public static void pln(int n){
        pw.println(n);
    }
    public static void pln(long n){
        pw.println(n);
    }
    public static void pln(String n){
        pw.println(n);
    }
    public static void pln(double n){
        pw.println(n);
    }
    public static void feedArr(long []arr){
        for(int i=0;i<arr.length;i++)
            arr[i]=sc.nextLong();
    }
    public static void feedArr(double []arr){
        for(int i=0;i<arr.length;i++)
            arr[i]=sc.nextDouble();
    }
    public static void feedArr(int []arr){
        for(int i=0;i<arr.length;i++)
            arr[i]=sc.nextInt();
    }
    public static void feedArr(String []arr){
        for(int i=0;i<arr.length;i++)
            arr[i]=sc.next();
    }
    public static String printArr(int []arr){
        StringBuilder sbr=new StringBuilder();
        for(int i:arr)
            sbr.append(i+" ");
        return sbr.toString();
    }
    public  static String printArr(long []arr){
        StringBuilder sbr=new StringBuilder();
        for(long i:arr)
            sbr.append(i+" ");
        return sbr.toString();
    }
    public static String printArr(String []arr){
        StringBuilder sbr=new StringBuilder();
        for(String i:arr)
            sbr.append(i+" ");
        return sbr.toString();
    }
    public static String printArr(double []arr){
        StringBuilder sbr=new StringBuilder();
        for(double i:arr)
            sbr.append(i+" ");
        return sbr.toString();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}