import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); scanner.nextInt(); while (scanner.hasNext()){ int n = scanner.nextInt(); int[] nums = new int[n]; int k = scanner.nextInt(); for (int i = 0; i < n; i++) { nums[i] = scanner.nextInt(); } System.out.println(getResult(nums,n,k)); } scanner.close(); } private static int getResult(int[] nums, int n, int k) { Arrays.sort(nums); int minX = nums[0]-k; nums[0] = minX; for (int i = 1; i < n; i++) { if(nums[i-1]+1>=nums[i]-k&&nums[i-1]+1<=nums[i]+k){ nums[i] = nums[i-1]+1; }else if(nums[i-1]+1