#include #include #include using namespace std; void solve() { int n, k, x; cin >> n >> k >> x; vector h(n), cnt(n); for (int i = 0; i < n; ++i) cin >> h[i]; int mi = 1e9; for (int i = 0; i < n; ++i) mi = min(mi, h[i]); for (int i = 0; i < k - 1; ++i) { if (h[i] < h[i + 1]) { cout << "No" << endl; return; } } for (int i = 0; i < k - 1; ++i) { if (h[n - i - 1] < h[n - i - 1]) { cout << "No" << endl; return; } } for (int i = 0; i < n - 1; ++i) { int d = abs(h[i] - h[i + 1]); if (d % x) { cout << "No" << endl; return; } } long long sum = 0; for (int i = 0; i < n; ++i) sum += (h[i] - mi) / x; int g = __gcd(n, k); cout << (sum % g ? "No" : "Yes") << endl; } int main() { int t; cin >> t; while (t--) solve(); }