#include<iostream>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<iomanip>
#include<list>
#include<stack>
using namespace std;
int i,m,n,j,k,km;
int a[20],b[20],c[20],d[20],e[20];
long ans,sum;
int jl[20],jj[20];
void dfs(int k,int n)
{
m+=1;
if (k==25&&n==6)
{
if (sum<=ans)
{
ans=sum;
for (int j=1;j<=5;++j)
jj[j]=jl[j];}
return;
}
if ((n==6&&k<25)||(k>25)||(n<6&&k==25))
return;
if (k+(6-n)*10<25) return;
for (int i=1;i<=10;++i)
{
if (n==1) sum+=a[i];
else if (n==2) sum+=b[i];
else if (n==3) sum+=c[i];
else if (n==4) sum+=d[i];
else if (n==5) sum+=e[i];
jl[n]=i;
dfs(k+i,n+1);
if (n==1) sum-=a[i];
else if (n==2) sum-=b[i];
else if (n==3) sum-=c[i];
else if (n==4) sum-=d[i];
else if (n==5) sum-=e[i];
}
}
int main()
{
freopen("marathon.in","r",stdin);
freopen("marathon.out","w",stdout);
for (i=1;i<=10;++i)
cin>>a[i];
for (i=1;i<=10;++i)
cin>>b[i];
for (i=1;i<=10;++i)
cin>>c[i];
for (i=1;i<=10;++i)
cin>>d[i];
for (i=1;i<=10;++i)
cin>>e[i];
km=0;sum=0;ans=1000000;
dfs(0,1);
cout<<ans<<endl;
for (i=1;i<=5;++i)
cout<<jj[i]<<" ";
}