for _ in range(int(input())): n, l, k = map(int, input().split()) x = sorted(map(int, input().split())) lb = 0 ub = (l + 1) // 2 while ub - lb > 1: c = (lb + ub) // 2 evs = [] now = 0 for xi in x: if 0 <= xi - c: evs.append((xi - c, -1)) else: evs.append((xi - c + l, -1)) now += 1 if xi + c < l: evs.append((xi + c, 1)) else: evs.append((xi + c - l, 1)) now += 1 evs.sort() ok = now >= k if c == 171: print(x, now) print(*evs, sep='\n') for t, sub in evs: now -= sub if now < k: ok = False if ok: ub = c else: lb = c print(ub)