#include #include using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) using mint = atcoder::modint998244353; int main(){ int n,h,x; cin>>n>>h>>x; vector> eve; int g; cin>>g; rep(i,g){ int a; cin>>a; eve.push_back({a,1}); } int b; cin>>b; rep(i,b){ int a; cin>>a; eve.push_back({a,-1}); } sort(eve.begin(),eve.end()); if(h>b){ map mp; mp[0]=0; int bf=0; for(auto[nw,dx]:eve){ auto itr=mp.end(); itr--; mp[nw]=itr->second+dx; if(nwsecond+dx); litr++; } bf=nw; } cout<second<> dp(m+1,vector(h+1,-1e9)); dp.at(0).at(0)=0; int bf=0; rep(i,m){ int l=-1,r=-1; if(eve.at(i).first>=x){ auto ritr=upper_bound(eve.begin(),eve.end(),make_pair(eve.at(i).first-x,2)); auto litr=upper_bound(eve.begin(),eve.end(),make_pair(bf-x,2)); if(litr==ritr&&litr!=eve.begin()) litr--; l=litr-eve.begin()+1; r=ritr-eve.begin()+1; } rep(j,h+1){ if(dp.at(i).at(j)!=-1e9) dp.at(i+1).at(j)=max(dp.at(i+1).at(j),dp.at(i).at(j)+eve.at(i).second); for(int k=l;k