#include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ int n, h, x; cin >> n >> h >> x; vector score(n+1); int G; cin >> G; rep(i,0,G){ int g; cin >> g; g--; score[g]++; } int B; cin >> B; rep(i,0,B){ int b; cin >> b; b--; score[b]--; } vector> dp(x+1, vector(h+1, -1e9)); dp[0][0] = 0; int piv = 0; rep(i,1,n+1){ piv++; piv %= x+1; int prev = (piv+x)%(x+1); int xbak = (piv+1)%(x+1); dp[piv][0] = dp[prev][0] + score[i]; rep(j,1,h+1){ dp[piv][j] = max(dp[prev][j], dp[xbak][j-1]) + score[i]; } } cout << max(dp[piv]) << endl; }