You are given an array π of π positive integers and an integer π₯. You can do theβ¦
- User
You are given an array π of π positive integers and an integer π₯. You can do the following two-step operation any (possibly zero) number of times:
Choose an index π (1β€πβ€π). Increase ππ by π₯, in other words ππ:=ππ+π₯. Find the maximum value of the MEX of π if you perform the operations optimally.
The MEX (minimum excluded value) of an array is the smallest non-negative integer that is not in the array. For example:
The MEX of [2,2,1] is 0 because 0 is not in the array. The MEX of [3,1,0,1] is 2 because 0 and 1 are in the array but 2 is not. The MEX of [0,3,1,2] is 4 because 0, 1, 2 and 3 are in the array but 4 is not. Input Each test contains multiple test cases. The first line contains the number of test cases π‘ (1β€π‘β€5000). The description of the test cases follows.
The first line of each test case contains two integers π and π₯ (1β€πβ€2β 105; 1β€π₯β€109) β the length of the array and the integer to be used in the operation.
The second line of each test case contains π integers π1,π2,β¦,ππ (0β€ππβ€109) β the given array.
It is guaranteed that the sum of π over all test cases does not exceed 2β 105.
Output For each test case, output a single integer: the maximum MEX of π if you perform the operations optimally.
- Assistant