#include #include using namespace std; using ll = long long; template istream& operator >> (istream& is, vector& vec) { for(T& x : vec) is >> x; return is; } template ostream& operator << (ostream& os, const vector& vec) { if(vec.empty()) return os; os << vec[0]; for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it; return os; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while(T--){ int n, k, x; cin >> n >> k >> x; vector a(n), sv(k), cnt(k); cin >> a; for(int i = 0; i < k; i++){ for(int j = i; j < n; j += k){ sv[i] += a[j]; cnt[i]++; } } bool ans = true; pair pa2 = {0, 1}; for(int i = 0; i < k; i++){ auto pa = atcoder::crt({sv[i], 0}, {x, cnt[i]}); if(pa.second == 0){ ans = false; break; } /*pa2 = atcoder::crt({pa2.first, pa.first}, {pa2.second, pa.second}); if(pa2.second == 0){ ans = false; break; }*/ } cout << (ans ? "Yes" : "No") << '\n'; } }