#include #include #include using std::vector; using std::cin; using std::cout; int main() { int N, Q, P; cin >> N >> Q >> P; vector A(N); for (auto &x: A) { cin >> x; } while (Q--) { int l, r, k; cin >> l >> r >> k; l -= 1; vector make(P); bool ans = false; for (int i = l; i < r; ++i) { vector next(P); for (int j = 0; j < P; ++j) { if (make[j]) { next[j] = true; next[(j * A[i]) % P] = true; } } next[A[i]] = true; make = std::move(next); if (make[k]) { ans = true; break; } } if (ans) { cout << "Yes\n"; } else { cout << "No\n"; } } return 0; }