#include #include #include #include #include #include #include #include #include #include #include #pragma warning(disable:4996) using std::cin; using std::cout; using std::endl; using std::stringstream; using std::string; using std::vector; using std::list; using std::pair; using std::set; using std::multiset; using std::map; using std::multimap; using std::stack; using std::queue; using std::priority_queue; using std::bitset; int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int T; while (cin >> T) { while (T--) { int n, divisor; cin >> n >> divisor; vectorvalue(n); for (int i = 0; i < n; i++) { cin >> value[i]; value[i] = (int)fabs(value[i]) % divisor; } vector>dp(n, (vector)divisor); dp[0][value[0]] = true; for (int i = 1; i < n; i++) { for (int j = 0; j < divisor; j++) { if (dp[i - 1][j]) { dp[i][(divisor + value[i] + j) % divisor] = true; dp[i][(divisor - value[i] + j) % divisor] = true; } } } if (dp[n - 1][0]) { cout << "Divisible" << endl; } else { cout << "Not divisible" << endl; } } } return 0; }