/* ********************************* Author :clogos Created Time :2016/07/30 19:07:05 File Name :A.cpp ********************************** */ #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef pair pii; #define fi first #define se second const int inf = 0x3f3f3f3f; const int N = 100000 + 10; int A[N]; int n, m; set S; set::iterator it; int main() { //freopen("out", "w", stdout); //freopen("in", "r", stdin); int cases; scanf("%d", &cases); while(cases--) { scanf("%d%d", &n, &m); int sum = 0; S.clear(); for(int i = 0; i < n; ++i) { scanf("%d", &A[i]); sum = (sum + A[i]) % m; S.insert(make_pair(sum, i)); } bool ok = false; int cheak = 0; for(int i = 0; i < n; ++i) { it = lower_bound(S.begin(), S.end(), make_pair(cheak, 0)); while(it != S.end() && (*it).fi <= cheak) { if((*it).se >= i) { ok = true; break; } S.erase(it++); } if(ok) break; cheak = (cheak + A[i]) % m; } if(ok) printf("YES\n"); else printf("NO\n"); } return 0; }