#include using namespace std; template inline bool chmax(T &x, U y) { return (x < y) ? (x = y, true) : false; } int main(){ int n, h, x; cin >> n >> h >> x; h = min(h,1010); vector> mas; int g; cin >> g; while (g--){ int y; cin >> y; mas.emplace_back(y,1); } int b; cin >> b; while (b--){ int y; cin >> y; mas.emplace_back(y,-1); } ranges::sort(mas); vector a = {0}; int pre = 0; for (auto [y, p] : mas){ int w = y - pre - 1; if (w > 6) w = 6; while (w--) a.emplace_back(0); a.emplace_back(p); pre = y; } if (pre != n){ int w = n - pre - 1; if (w > 6) w = 6; while (w--) a.emplace_back(0); a.emplace_back(0); pre = n; } n = (int)(a.size()) - 1; vector> dp(n+1,vector(h+1,-1e9)); dp[0][0] = 0; for (int i = 0; i < n; i++) for (int j = 0; j <= h; j++) { chmax(dp[i+1][j],dp[i][j]+a[i+1]); if (i+x <= n && j+1 <= h){ chmax(dp[i+x][j+1],dp[i][j]+a[i+x]); } } int ans = -1e9; for (int i = 0; i <= h; i++) chmax(ans,dp[n][i]); cout << ans << endl; }