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.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

public class Main {

	public Main() throws FileNotFoundException {

//		File file = Paths.get("input.txt").toFile();
//		if (file.exists()) {
//			System.setIn(new FileInputStream(file));
//		}
		// long t = System.currentTimeMillis();

		InputReader reader = new InputReader();

		int n = reader.nextInt();
		int q = reader.nextInt();

		int[] a = new int[n];

		int[] seen = new int[60];

		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {

			int color = reader.nextInt();
			list.add(color);
			if (seen[color] == 0) {
				seen[color] = 1;
			}

		}

		int[] c = new int[51];
		Arrays.fill(c, -1);
		int addedCounter = 0;
		// System.out.println(list);
		for (int i = 0; i < q; i++) {
			int color = reader.nextInt();

			// 5 2 3 1 5
			if (seen[color] == 1) {

				int pos = addedCounter;

				int[] vis = new int[60];
				for (int j = 0; j < list.size(); j++) {
					int co = list.get(j);
					if (seen[co] == 0) {
						if (vis[co] == 0) {
							vis[co] = 1;
							pos--;
						}
					}
					if (co == color) {
						System.out.print((j + 1 + pos) + " ");
						break;
					}
				}
				seen[color] = 0;
				addedCounter++;

				for (int cc = 1; cc < c.length; cc++) {
					if (cc == color) {
						c[color] = 0;
					} else if (c[cc] > -1) {
						c[cc]++;
					}
				}
			} else {

				System.out.print((c[color]+1) + " ");

				int idxColor=c[color];
				for (int cc = 1; cc < c.length; cc++) {
					if (cc == color) {
						c[color] = 0;
					}
					if(c[cc]>-1&&c[cc]<idxColor&&cc!=color) {
						c[cc]++;
					}
				}
			}

		}

	}

	static class InputReader {
		private byte[] buf = new byte[16384];
		private int curChar;
		private int numChars;

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = System.in.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

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

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	public static void main(String[] args) throws FileNotFoundException {
		new Main();
	}

}
