#include using namespace std; //#pragma GCC optimize("Ofast") #define rep(i,n) for(ll i=0;i=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue,greater> #define all(x) (x).begin(),(x).end() #define CST(x) cout<> #define rev(x) reverse(x); using ll=long long; using vl=vector; using vvl=vector>; using pl=pair; using vpl=vector; using vvpl=vector; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=1e9+10; const ll INF=4e18; const ll dy[9]={0,1,-1,0,1,1,-1,-1,0}; const ll dx[9]={1,0,0,-1,1,-1,1,-1,0}; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int main(){ ll n,h,x;cin >> n >> h >> x;if(h>3000)h=3000; vl valid; ll g;cin >> g; vl gs(g); rep(i,g){ ll x;cin >> x;gs[i]=x; for(ll i=-6;i<=6;i++){ if(x+i>=0&&x+i<=n)valid.emplace_back(x+i); } } ll b;cin >> b; vl bs(b); rep(i,b){ ll x;cin >> x;bs[i]=x; for(ll i=-6;i<=6;i++){ if(x+i>=0&&x+i<=n)valid.emplace_back(x+i); } } valid.emplace_back(0);valid.emplace_back(n); sort(all(valid));valid.erase(unique(all(valid)),valid.end()); ll m=valid.size(); vvl dp(m,vl(h+1,-INF));dp[0][0]=0; //return 0; rep(i,m-1){ ll to=valid[i+1]; if(binary_search(all(gs),to)){ rep(j,h+1){ chmax(dp[i+1][j],dp[i][j]+1); } } else if(binary_search(all(bs),to)){ rep(j,h+1){ chmax(dp[i+1][j],dp[i][j]-1); } } else { rep(j,h+1){ chmax(dp[i+1][j],dp[i][j]); } } ll nx=valid[i]+x; ll idx=-1; for(ll j=i;j