Video Clips

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

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).

제한

  • N,K100,000N, K \le 100\\,000
  • 2M1092 \le M \le 10^9