Valentina had a birthday recently. She got a special piano from parents. They told her about the piano melodies and the connection with the mathematical sequences. She got amazed and started to use piano keys to create her own musical sequences.
The piano has m keys, numbered 0 through
Valentina has already hit n keys
E.g., for
Given n, m and z, are you able to find
Input format
The first line of the input contains one integer T denoting the number of test cases.
The first line of each test case description contains three integers n, m and z.
The second line contains n integers
Output format
For each test case, output the answer in a separate line.
Constraints
Subtasks
Extra constraints | Points | Which tests |
---|---|---|
30 | 1-3 | |
40 | 4-7 | |
no extra constraints | 30 | 8-10 |
3 4 10 4 1 3 3 7 4 10 5 1 3 3 7 1 2 12345678987654321 1
6 9 1
In the first sample test case, we know the first
In the second sample test case, we are given the same first keys but we are asked to find
In the third sample test case, Valentina will hit the same key over and over, i.e.
Stack Limit for C++ is 8MB. You are allowed to increase it in your code, e.g. using setrlimit().
Please login to use the editor
You need to be logged in to access the code editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor