#include using namespace std; struct Mast{ int n; int w; vector y; int &operator[](int i){ return y[i]; } int64_t area(){ return w*(int64_t)w; } void read(){ cin>>n>>w; y.resize(n); for (auto &i: y) cin>>i; sort(y.begin(),y.end()); } }; int gap; Mast a,b,c; bool overlap(pair a,pair b){ if (a.firstgap; } int64_t solve(int ai,int bi,int ci){ if (ai==-1 or bi==-1 or ci==-1) return 0; static map,int64_t> memo; auto const key=make_tuple(ai,bi,ci); if (memo.count(key)) return memo[key]; auto &best=memo[key]; int level=INT32_MAX; if (ai=0 and a[aj]<=level) and (bi==b.n or not overlap({a[aj],a.w},{b[bi],b.w}))){ best=max(best,solve(aj,bi,ci)+a.area()); } } for (int bj=0; bj=0 and b[bj]<=level) and (ai==a.n or not overlap({b[bj],b.w},{a[ai],a.w})) and (ci==c.n or not overlap({b[bj],b.w},{c[ci],c.w}))){ best=max(best,solve(ai,bj,ci)+b.area()); } } for (int cj=0; cj=0 and c[cj]<=level) and (bi==b.n or not overlap({c[cj],c.w},{b[bi],b.w}))){ best=max(best,solve(ai,bi,cj)+c.area()); } } return best; } int main(){ cin>>gap; a.read(); b.read(); c.read(); cout<