This page is still under construction.

Parts of this page are still being built. What you see may change.

Guessing Answers

Time limit1sMemory limit1024 MB

Summary
Given the correct answers and the set of problems guessed correctly, build an answer sequence where consecutive answers differ and exactly the listed problems are correct.
Level

Medium6 of 10

Topics
Greedy, Implementation, Array, Brute force
Solved
No attempts yet

Problem

Yunee did not study for the final exam. So Yunee decided to guess the answers to all problems in the final exam. The final exam consists of NN single choice questions numbered from 11 to NN, each with a choice of 11 to 55.

Yunee gets anxious when the answers to two successive problems are the same. So Yunee always selects an answer different from the answer to the previous problem (except for the first problem). After submitting the answers, Yunee received the grading result, which stated whether each answer was correct.

Given the correct answers to all problems and the MM problems that Yunee guessed correctly, reconstruct a possible sequence of Yunee's answers. It is guaranteed that at least one such sequence exists for each input.

Input

The first line contains two integers NN and MM (1≤N≤100,000,1≤M≤N)(1 \leq N \leq 100,000, 1\leq M \leq N). NN is the total number of problems. MM is the number of problems that Yunee guessed correctly.

The second line contains NN integers from 11 to 55. The ii-th integer represents the correct answer to the ii-th problem.

The third line contains MM distinct integers from 11 to NN. They represent the MM problems that Yunee guessed correctly.

Output

Output a possible sequence of Yunee's answers. Each number should be separated by a blank.

Examples2

  1. Example 1

    Input
    4 2
    1 1 2 3
    1 4
    
    Expected output
    1 5 4 3
    
  2. Example 2

    Input
    3 2
    1 2 3
    1 3
    
    Expected output
    1 4 3