/** * - Meet Brahmbhatt * - Hard work always pays off **/ #include"bits/stdc++.h" using namespace std; #ifdef MeetBrahmbhatt #include "debug.h" #else #define dbg(...) 72 #endif #define endl "\n" #define int long long const long long INF = 4e18; void solve() { int n, k; cin >> n >> k; int m1; cin >> m1; vector S(n + 1); for (int i = 0; i < m1; i++) { int x; cin >> x; S[x] = 1; } int m2; cin >> m2; for (int i = 0; i < m2; i++) { int x; cin >> x; S[x] = -1; } vector> dp(n + 1, vector(2)); dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int x : vector {i + 1, i + k}) { if (x <= n) { for (int j = 0; j < 2; j++) { if (!dp[i][j]) { continue; } if (S[x] == 1) { dp[x][1] = 1; } else if (S[x] == -1) { dp[x][0] = 1; } else { dp[x][j] = dp[i][j]; } } } } } cout << (dp.back()[0] == 1 ? "Yes" : "No"); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(9); int tt = 1; // cin >> tt; while (tt--) solve(); return 0; }