def solve(): n, k, x = map(int, input().split()) H = list(map(int, input().split())) if len(set(h % x for h in H)) != 1: print("No") return tot = [0] * k H = [h // x for h in H] ma = max(H) for i, h in enumerate(H): tot[i % k] += ma - h bef = tot[: n % k] aft = tot[n % k :] if bef and len(set(bef)) >= 2: print("No") return if aft and len(set(aft)) >= 2: print("No") return if bef and aft: if bef[0] > aft[0]: print("No") return d = aft[0] - bef[0] goal = ma + d minus = [0] * n tot = 0 for i, h in enumerate(H): tot -= minus[i] h += tot if h > goal: print("No") return tot += goal - h if i + k < n: minus[i + k] = goal - h print("Yes") for _ in range(int(input())): solve()