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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Random;
import java.util.StringTokenizer;

// CFPS -> CodeForcesProblemSet
public final class CFPSOptimized {
	static FastReader fr = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		int n = fr.nextInt(), q = fr.nextInt();
		int[] cardColors = fr.nextIntArray(n);
		int[] queries = fr.nextIntArray(q);
		
		// An array to store the topmost position for
		// each color.
		int[] colorTop = new int[50];
		// Initializing: 
		for (int i = 0; i < n; i++) {
			if (colorTop[cardColors[i] - 1] == 0)
				colorTop[cardColors[i] - 1] = i + 1;
		}
		
		for (int color : queries) {
			int colorIdx = color - 1;
			out.print(colorTop[colorIdx] + " ");
			// All the cards above this card will
			// move downwards by 1. This card will
			// move to the top.
			for (int i = 0; i < 50; i++) {
				// If the top card of color 'x' is at position 'k',
				// if the position is above that of the current color,
				// it will be incremented by 1.
				if (colorTop[i] < colorTop[colorIdx])
					colorTop[i]++;
			}
			colorTop[colorIdx] = 1;
		}
		out.close();
	}
	
	static int gcd(int n1, int n2) {
		if (n1 > n2) {
			n1 += n2;
			n2 = n1 - n2;
			n1 -= n2;
		}
		for (int i = n1; i > 0; i--)
			if (n1 % i == 0 && n2 % i == 0)
				return i;
		return 1;
	}
	
	static void shuffleArray(long[] arr, int startPos, int endPos){
        Random rnd = new Random();
        for(int i=startPos; i<endPos; ++i){
            long tmp = arr[i];
            int randomPos = i + rnd.nextInt(endPos-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }   
}
	
	static class Tuple implements Comparable<Tuple> {
		long mem; 
		int idx;
		int conv;
		double memPerConv;
		
		Tuple() {mem = idx = 0;}
		
		Tuple(long a, int b, int c) {
			this.mem = a;
			this.idx = b;
			this.conv = c;
			this.memPerConv = this.mem / this.conv;
		}
		
		@Override
		public int compareTo(CFPSOptimized.Tuple o) {
			if (this.memPerConv > o.memPerConv)
				return -1;
			if (this.memPerConv < o.memPerConv)
				return 1;
			return 0;
		}
	}
	
	static class tupIdx2Comparator implements Comparator<Tuple> {
		@Override
		public int compare(CFPSOptimized.Tuple o1, CFPSOptimized.Tuple o2) {
			if (o1.idx > o2.idx)
				return 1;
			if (o1.idx < o2.idx)
				return -1;
			return 0;
		}
	}
	
	// Code from geeksforgeeks.org
	// Time Complexity: O(sqrt(n))
	static boolean isPrime(int n) {
		// Corner cases
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		// This is checked so that we can skip
		// middle five numbers in below loop
		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 int hash(String s, int arrayLen) {
		return (s.hashCode() & 0x7fffffff) % arrayLen;
	}

	static class FastReader {
		// The input stream is read and stored into a buffer which can be used to
		// retrieve
		// data whenever required. This reduces the # of IO operations thus ensuring
		// fast input.

		// BufferedReader for input buffering and StringTokenizer for splitting the
		// input
		// line by line into string tokens which can be parsed manually for the desired
		// data.
		private BufferedReader bfr;
		private StringTokenizer st;

		public FastReader() {
			// Passing an InputStreamReader to the BufferedReader constructor (using the
			// console
			// input stream).
			bfr = new BufferedReader(new InputStreamReader(System.in));
		}

		// Method to return the next String token which can be parsed further.
		String next() {
			// Initializing (if required)/Resetting by creating tokens from the
			// next line.
			// If there are no more elements from the current line:
			if (st == null || !st.hasMoreElements()) {
				try {
					// Creating tokenizer using the next line.
					st = new StringTokenizer(bfr.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		// Parsing the next token to an Integer.
		int nextInt() {
			return Integer.parseInt(next());
		}

		// Parsing the next token to a Long.
		long nextLong() {
			return Long.parseLong(next());
		}

		// Parsing the next token to a Double.
		double nextDouble() {
			return Double.parseDouble(next());
		}

		// Parsing the next token to a Character.
		char nextChar() {
			return next().toCharArray()[0];
		}

		// Reading a whole string.
		String nextString() {
			return next();
		}

		// Parsing the input tokens to an integer array of
		// the specified size.
		int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}

		// Parsing the input token to a double array of
		// the specified size.
		double[] nextDoubleArray(int n) {
			double[] arr = new double[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextDouble();
			return arr;
		}

		long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextLong();
			return arr;
		}

		public char[] nextCharArray(int n) {
			char[] chars = new char[n];
			for (int i = 0; i < n; i++)
				chars[i] = fr.nextChar();
			return chars;
		}
	}
}
