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 cnt = [0] * k for i, h in enumerate(H): cnt[i % k] += h // x bef = cnt[: n % k] aft = cnt[n % k :] if bef and len(set(bef)) >= 2: print("No") return if aft and len(set(aft)) >= 2: print("No") return print("Yes") for _ in range(int(input())): solve()