#include using namespace std; typedef long long ll; int main(){ int n, h, x; cin >> n >> h >> x; set g; int G; cin >> G; for (int i=0; i> a; g.insert(a); } set b; int B; cin >> B; for (int i=0; i> a; b.insert(a); } set newb; newb.insert(0); newb.insert(n); for (int a: b){ for (int i=a-x; i<=a+x; i++){ if (0 <= i && i <= n){ newb.insert(i); } } } int ans_base = 0; for (int a: g){ if (newb.find(a) == newb.end()){ ans_base++; } } int m = newb.size(); vector score(m); int piv = 0; for (int a: newb){ if (b.find(a) != b.end()){ score[piv]--; } if (g.find(a) != g.end()){ score[piv]++; } piv++; } int r = min(B, h); vector> dp(m, vector(r+1, -1e9)); dp[0][0] = 0; for (int i=1; i= 1 && i-x >= 0){ dp[i][j] = max(dp[i][j], dp[i-x][j-1] + score[i]); } } } int ans = -1e9; for (int i=0; i