{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eYou have a card deck of $$$n$$$ cards, numbered from top to bottom, i.\u0026nbsp;e. the top card has index $$$1$$$ and bottom card\u0026nbsp;— index $$$n$$$. Each card has its color: the $$$i$$$-th card has color $$$a_i$$$.\u003c/p\u003e\u003cp\u003eYou should process $$$q$$$ queries. The $$$j$$$-th query is described by integer $$$t_j$$$. For each query you should: \u003c/p\u003e\u003cul\u003e \u003cli\u003e find the highest card in the deck with color $$$t_j$$$, i.\u0026nbsp;e. the card with minimum index; \u003c/li\u003e\u003cli\u003e print the position of the card you found; \u003c/li\u003e\u003cli\u003e take the card and place it on top of the deck. \u003c/li\u003e\u003c/ul\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains two integers $$$n$$$ and $$$q$$$ ($$$2 \\le n \\le 3 \\cdot 10^5$$$; $$$1 \\le q \\le 3 \\cdot 10^5$$$)\u0026nbsp;— the number of cards in the deck and the number of queries.\u003c/p\u003e\u003cp\u003eThe second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 50$$$)\u0026nbsp;— the colors of cards.\u003c/p\u003e\u003cp\u003eThe third line contains $$$q$$$ integers $$$t_1, t_2, \\dots, t_q$$$ ($$$1 \\le t_j \\le 50$$$)\u0026nbsp;— the query colors. It\u0027s guaranteed that \u003cspan class\u003d\"tex-font-style-bf\"\u003equeries ask only colors that are present in the deck\u003c/span\u003e.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint $$$q$$$ integers\u0026nbsp;— the answers for each query.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e7 5\n2 1 1 4 3 3 1\n3 2 1 1 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5 2 3 1 5 \u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eDescription of the sample: \u003c/p\u003e\u003col\u003e \u003cli\u003e the deck is $$$[2, 1, 1, 4, \\underline{3}, 3, 1]$$$ and the first card with color $$$t_1 \u003d 3$$$ has position $$$5$$$; \u003c/li\u003e\u003cli\u003e the deck is $$$[3, \\underline{2}, 1, 1, 4, 3, 1]$$$ and the first card with color $$$t_2 \u003d 2$$$ has position $$$2$$$; \u003c/li\u003e\u003cli\u003e the deck is $$$[2, 3, \\underline{1}, 1, 4, 3, 1]$$$ and the first card with color $$$t_3 \u003d 1$$$ has position $$$3$$$; \u003c/li\u003e\u003cli\u003e the deck is $$$[\\underline{1}, 2, 3, 1, 4, 3, 1]$$$ and the first card with color $$$t_4 \u003d 1$$$ has position $$$1$$$; \u003c/li\u003e\u003cli\u003e the deck is $$$[1, 2, 3, 1, \\underline{4}, 3, 1]$$$ and the first card with color $$$t_5 \u003d 4$$$ has position $$$5$$$. \u003c/li\u003e\u003c/ol\u003e"}}]}