#include #include #include #include using namespace std; int main() { int N,H,X,G,B; cin >> N >> H >> X >> G; map m; m[0] = m[N] = 1; vector g(G); for(int i=0;i> g[i]; for(int j=-X;j<=X;j++)m[g[i]+j] = 1; } cin >> B; vector b(B); for(int i=0;i> b[i]; for(int j=-X;j<=X;j++)m[b[i]+j] = 1; } vector v; for(auto i : m)v.push_back(i.first); sort(v.begin(),v.end()); for(int i=0;i t(v.size(),0),f(v.size(),false); for(int i=0;i> dp(v.size(),vector(2020,0)); dp[m[0]][1000] = H; for(int i=0;i