#include using namespace std; using ll = long long; template istream& operator >> (istream& is, vector& vec) { for(T& x : vec) is >> x; return is; } template ostream& operator << (ostream& os, const vector& vec) { if(vec.empty()) return os; os << vec[0]; for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it; return os; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, h, x, g, b; cin >> n >> h >> x >> g; vector G(g), ca; cin >> G >> b; vector B(b); cin >> B; ca.reserve(2 * x * (g + b)); for(auto &&v : G){ for(int d = -x; d <= x; d++){ int nv = v + d; if(nv < 0 || nv > n) continue; ca.push_back(nv); } } for(auto &&v : B){ for(int d = -x; d <= x; d++){ int nv = v + d; if(nv < 0 || nv > n) continue; ca.push_back(nv); } } for(int i = 0; i <= min(x, n); i++){ ca.push_back(i); ca.push_back(n - i); } sort(ca.begin(), ca.end()); ca.erase(unique(ca.begin(), ca.end()), ca.end()); int m = ca.size(); vector tb(m); for(auto &&v : G){ int j = lower_bound(ca.begin(), ca.end(), v) - ca.begin(); tb[j] = 1; } for(auto &&v : B){ int j = lower_bound(ca.begin(), ca.end(), v) - ca.begin(); tb[j] = -1; } h = min({h, m, b}); vector> dp(m, vector(h + 1, -(1 << 30))); dp[0][h] = 0; for(int i = 0; i + 1 < m; i++){ for(int j = 0; j <= h; j++){ dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + tb[i + 1]); if(j >= 1 && i + x < m){ dp[i + x][j - 1] = max(dp[i + x][j - 1], dp[i][j] + tb[i + x]); } } } cout << *max_element(dp.back().begin(), dp.back().end()) << '\n'; }