```cpp
#include<iostream>
using namespace std;
long long ansl,n1,n2,n3,temp1,temp2,ans,k,n,lplp=4,a[25];
bool b[25];
long long mi(int k){
long long lp=1;
for(int i=0;i<k;i++){
lp*=2;
}
return lp;
}
int main(){
cin>>n>>n1>>n2>>n3;
for(int i=1;i<=n;++i){
b[i]=0;
cin>>a[i];
}
ansl=0x3f3f3f;
k=mi(n);
for(int i=1;i<=k;i++){
if(b[n]==1){
for(int j=n;j>0;j--){
if(b[j]==0){
b[j]=1;
break;
}
else b[j]=0;
}
}else b[n]=1;
temp1=0;
temp2=0;
for(int j=1;j<=n;j++){
if(b[j])
temp1+=a[j];
else
temp2+=a[j];
}
if(temp1<temp2){
temp1=temp2;
}
if(temp1<ansl)
ansl=temp1;
}
// cout<<ansl<<endl<<endl;
ans+=ansl;
ansl=0x3f3f3f;
for(int i=1;i<=n1;++i){
b[i]=0;
cin>>a[i];
}
k=mi(n1);
for(int i=1;i<=k;i++){
if(b[n1]){
for(int j=n1;j>0;j--){
if(b[j]==0){
b[j]=1;
break;
}
else b[j]=0;
}
}else b[n1]=1;
temp1=0;
temp2=0;
for(int j=1;j<=n1;j++){
if(b[j])
temp1+=a[j];
else
temp2+=a[j];
}
if(temp1<temp2){
temp1=temp2;
}
if(temp1<ansl)
ansl=temp1;
}
//cout<<ansl<<endl<<endl;
ans+=ansl;
ansl=0x3f3f3f;
for(int i=1;i<=n2;++i){
b[i]=0;
cin>>a[i];
}
k=mi(n2);
for(int i=1;i<=k;i++){
if(b[n2]==1){
for(int j=n2;j>0;j--){
if(b[j]==0){
b[j]=1;
break;
}else b[j]=0;
}
}else b[n2]=1;
temp1=0;
temp2=0;
for(int j=1;j<=n2;j++){
if(b[j])
temp1+=a[j];
else
temp2+=a[j];
}
if(temp1<temp2){
temp1=temp2;
}
if(temp1<ansl)
ansl=temp1;
}
ans+=ansl;
//cout<<ansl<<endl<<endl;
ansl=0x3f3f3f;
for(int i=1;i<=n3;++i){
b[i]=0;
cin>>a[i];
}
k=mi(n);
for(int i=1;i<=k;i++){
if(b[n3]==1){
for(int j=n3;j>0;j--){
if(b[j]==0){
b[j]=1;
break;
}else b[j]=0;
}
}else b[n3]=1;
temp1=0;
temp2=0;
for(int j=1;j<=n3;j++){
if(b[j])
temp1+=a[j];
else
temp2+=a[j];
}
if(temp1<temp2){
temp1=temp2;
}
if(temp1<ansl)
ansl=temp1;
}
ans+=ansl;
// cout<<ansl<<endl<<endl;
cout<<ans<<endl;
return 0;
}