시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 163 66 52 50.980%

문제

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
W3sicHJvYmxlbV9pZCI6IjMxMTciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJZb3VUdWJlIiwiZGVzY3JpcHRpb24iOiI8cD5Tb2dhbmcgQUNNLU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