On a popular web site, the N KATT contestants can spend time watching video clips in between solving problems.
On the site, there are K funny videos of cats jumping around on the keyboard, numbered between 0 and K−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 M:th video that each contestant watches will be.
The sample judge reads input in the following format:
K MS[0] ... S[K - 1]N: the number of calls made to clip(I).I1 ... IN: the parameters of the N calls to clip(I).The sample judge will write N lines with the return values of clip(I).