#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e4+10;
int p[N];
ll rd[N][16];
int dp[N][51];
int cost(int l,int r)
{
// r[l]&r[l+1] ..
int lg=__lg(r-l+1);
return ( __builtin_popcountll(rd[l][lg]&rd[r-(1<<lg)+1][lg])*(p[r]-p[l-1]));
}
void DnC(int k,int l,int r,int opl,int opr)
{
if(r<l)return;
int m=(l+r)>>1;
int opi=-1;
for(int i=opl;i<=min(m,opr);i++)
{
int oth=cost(i,m) + dp[i-1][k-1];
if(oth<=dp[m][k])
{
dp[m][k]=oth;
opi=i;
}
}
// cout<<"just solved "<<m<<' '<<k<<' '<<opi<<endl;;
DnC(k,l,m-1,opl,opi);
DnC(k,m+1,r,opi,opr);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,t,s;
cin>>n>>t>>s;
for(int i=1;i<=t;i++)
{
cin>>p[i];
p[i]+=p[i-1];
}
for(int i=0;i<n;i++)
{
string q;
cin>>q;
for(int j=1;j<=t;j++)
{
if(q[j-1]=='1')
rd[j][0]|=(1ll<<i);
}
}
for(int j=1;j<16;j++)
{
for(int i=1;i+(1<<j)-1<=t;i++)
{
rd[i][j]=(rd[i][j-1]&rd[i+(1<<(j-1))][j-1]);
}
}
for(int i=0;i<=t;i++)
{
for(int j=0;j<=s;j++)
{
dp[i][j]=2e9+10;
}
}
dp[0][0]=0;
// for(int i=1;i<=t;i++)
// {
// for(int j=1;j<=s;j++)
// {
// ll ad=(1ll<<n)-1;
// cout<<"solving "<<i<<' '<<j<<endl;
// for(int ip=i;ip>0;ip--)
// {
// ad&=r[ip];
// int cst=dp[ip-1][j-1]+(__builtin_popcountll(ad)*(p[i]-p[ip-1]));
// if(cst<dp[i][j])
// {
// opt[i][j]=ip;
// }
// dp[i][j]=min(dp[i][j],cst);
// cout<<cst<<' ';
// }
// cout<<endl;
// }
// }
for(int j=1;j<=s;j++)
{
for(int i=j;i<=t;i++)
{
for(int ip=1;ip<=i;ip++)
{
dp[i][j]=min(dp[i][j],dp[ip-1][j-1]+cost(ip,i));
}
}
// DnC(j,j,t,j-1,t);
// for(int i=1;i<=t;i++)
// {
// // cout<<opt[i][j]<<' ';
// }
// cout<<endl;
cout<<dp[t][j]<<endl;
}
}