Bubble Gum, Bubble Gum, in the Dish, How Many Pieces Do You Wish?

Time limit1sMemory limit128 MB

Problem

Alex and Karyn are at it again. The two elementary-school sisters are playing their favorite game to decide who gets to use the computer next.

The rules are simple. Given $p$ people ($p > 0$), one of them picks a number $n$ ($n > p$) representing the number of pieces of bubble gum they want. Once this number is chosen, the people are counted one at a time from left to right, starting with the person who chose the number. The first person counted is number 1. Counting proceeds in a circle: after the rightmost person comes the leftmost person again. When the count reaches $n$, the person at that position is the winner.

Given the list of names, the name of the person choosing the number, and the number they chose, determine the winner of the game.

Input

The first value is an integer $t$ ($0 < t < 1000$), the number of test cases. Each test case then consists of:

  • Line 1: the list of names, separated by single spaces. Each name is at most 20 characters long and all names are distinct. The number of people $p$ is at most 20.
  • Line 2: the name of the person choosing the number of pieces of bubble gum.
  • Line 3: the chosen number $n$ ($p < n < 1000$).

Output

For each test case, print the name of the winner on its own line.