SP8392 YOUTUBE - Youtube

Description

N students are bored in computer class so they watch funny video clips on YouTube. The site contains K popular clips, numbered 1 through N. When a video clip is watched, a list of similar video clips is displayed on the side. Every student picks a video clip from the main page and starts watching it. After exactly one minute every student gets bored of his or her video clip, so he opens the **first** video clip from the list of similar clips on the side (even if he already watched that clip). Write a program that determines for each student which video clip he will be watching **during the M-th minute** of the class.

Input Format

The first line contains three integers N, K and M (1 The second line contains N integers, each between 1 and K, the indices of video clips the students start watching. The third line contains K integers, each between 1 and K, the index of the first similar clip for each video clip.

Output Format

Output N integers, the indices of video clips that students will be watching during the M-th minute.