시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 69 21 18 48.649%

문제

Sogang ACM-ICPC Team은 전통적으로 1학기에 신입생들에게 C언어를 가르쳐준다. 올해는 상근이가 C언어를 가르쳐 주기로 했다.

어느날, 링크드 리스트를 설명하는 날이었다. 상근이는 앞에서, 구조체와 malloc을 이용해 링크드 리스트를 구현하는 방법을 설명하고 있었다.

2시간에 걸친 설명을 듣던 중, 지루해진 N명의 학생들은 남은 M분 동안 상근이 몰래 YouTube를 보기로 했다.

YouTube에는 K개의 동영상이 있고, 1번부터 K번까지 번호가 매겨져 있다. 동영상을 볼 때, 우측에는 추천 동영상이 떠있다.

모든 학생은 메인 페이지에서 동영상 하나를 시청한다. 동영상을 시청하고 1분이 지나면, 추천 동영상 중 가장 위에 있는 동영상을 시청한다. (모든 동영상은 정확히 1분만 시청한다)

각 학생이 처음에 시청한 동영상 번호와, 각 동영상의 추천 동영상 중 가장 위에 있는 동영상의 번호가 주어졌을 때, M분에 각 학생이 시청한 동영상 번호를 출력하는 프로그램을 작성하시오.

입력

첫째 줄에 N, K, M이 주어진다. (1 ≤ N,K ≤ 100,000) (1 ≤  M ≤  1,000,000,000) N은 학생의 수, K는 동영상의 개수, M은 남은 수업 시간이다.

둘째 줄에는 1보다 크거나 같고, K보다 작거나 같은 수가 N개 주어진다. 이 수는 각 학생이 제일 처음 시청하는 동영상 번호이다.

셋재 줄에는 1보다 크거나 같고, K보다 작거나 같은 수 K개가 주어진다. 이 숫자는 각 동영상의 추천 동영상 중, 가장 위에 있는 동영상의 번호이다.

출력

첫째 줄에 각 학생이 M분에 시청하는 동영상 번호를 공백으로 구분해서 출력한다.

예제 입력 1

4 5 2
1 2 4 3
5 5 1 2 3

예제 출력 1

5 5 2 1
W3sicHJvYmxlbV9pZCI6IjMxMTciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJZb3VUdWJlIiwiZGVzY3JpcHRpb24iOiI8cD5Tb2dhbmcgQUNNLUl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