have a card deck of n cards, numbered through and through, I. e. the top card has list 1 and base card — file n. Each card has its tone: the I-th card has shading artificial intelligence. You should handle q inquiries. The j-th inquiry is depicted by integer tj. For each inquiry you ought to:
Correct answer will be upvoted else downvoted. Computer science.
You have a card deck of n cards, numbered through and through, I. e. the top card has list 1 and base card — file n. Each card has its tone: the I-th card has shading
You should handle q inquiries. The j-th inquiry is depicted by integer tj. For each inquiry you ought to:
track down the most elevated card in the deck with shading tj, I. e. the card with least list;
print the situation of the card you found;
assume the card and position it on top of the deck.
Input
The primary line contains two integers n and q (2≤n≤3⋅105; 1≤q≤3⋅105) — the number of cards in the deck and the number of questions.
The subsequent line contains n integers a1,a2,… ,an (1≤ai≤50) — the shades of cards.
The third line contains q integers t1,t2,… ,tq (1≤tj≤50) — the inquiry tones. It's reliable that inquiries ask just shadings that are available in the deck.
Output
Print q integers — the responses for each inquiry
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)