#include #include #include using namespace std; using ll = long long; int main() { ll n, k; cin >> n >> k; unordered_set dirty, mat; ll m1, m2; cin >> m1; for (ll i = 0; i < m1; i++) { ll a; cin >> a; dirty.insert(a); } cin >> m2; for (ll i = 0; i < m2; i++) { ll b; cin >> b; mat.insert(b); } vector dp(n + 1, 2); dp[0] = 0; vector foot = { 1,k }; for (ll i = 0; i < n; i++) { if (dp[i] == -1) continue; for (auto& v : foot) { if (i + v > n) continue; if (dirty.find(i + v) != dirty.end()) { dp[i + v] = 1; } else if (mat.find(i + v) != mat.end()) { dp[i + v] = 0; } else { dp[i + v] = min(dp[i + v], dp[i]); } } } if (dp[n]) { cout << "No\n"; } else { cout << "Yes\n"; } }