#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e4+10;
const ll inf=1e18;
#define int ll
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=m,opp=m;
for(int i=opl;i<=min(m,opr);i++)
{
int oth=cost(i,m) + dp[i-1][k-1];
if(oth<=dp[m][k])
{
if(oth<dp[m][k])
opp=i;
dp[m][k]=oth;
opi=i;
}
}
DnC(k,l,m-1,opl,opi);
DnC(k,m+1,r,opp,opr);
}
int32_t 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]=inf;
}
}
dp[0][0]=0;
for(int j=1;j<=s;j++)
{
DnC(j,j,t,1,t);
cout<<dp[t][j]<<endl;
}
}