Video Clips | 프로그래밍의 벗 PivotOJ
PivotOJ

Video Clips

시간 제한: 2000ms메모리 제한: 1024MB출처: Programmeringsolympiaden 2016 — katt2BOJ 21348

문제

On a popular web site, the NN KATT contestants can spend time watching video clips in between solving problems.

On the site, there are KK funny videos of cats jumping around on the keyboard, numbered between 00 and K1K - 1. When one of the videos has been viewed, a suggestion for the next funny cat video is shown, which you of course click on and start watching.

For each contestant, you will be given the initial cat video he or she views. Determine what the MM:th video that each contestant watches will be.

입력

The sample judge reads input in the following format:

  • line 11: K M
  • line 22: S[0] ... S[K - 1]
  • line 33: N: the number of calls made to clip(I).
  • line 44 I1 ... IN: the parameters of the NN calls to clip(I).

출력

The sample judge will write NN lines with the return values of clip(I).

예제

예제 1

입력
4 2
3 2 1 0
2
3 1
출력
0 2
코드를 제출하려면 로그인하세요.