#include<cstring>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define int long long
using namespace std;
int n,m,k;
int map[1005][1005];
int now[1005];
int ans=0;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
signed main()
{
scanf("%lld%lld%lld",&n,&m,&k);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
scanf("%lld",&now[j]);
sort(now+1,now+1+m);
for(int j=1;j<=m;j++)
map[i][j]=now[j];
map[i][0]=1;
ans+=now[1];
q.push(make_pair(now[2],i));
}
printf("%lld ",ans);
int tt=2;
while(tt<=k)
{
int tmp,num;
tmp=q.top().second;
if(map[tmp][0]+1>m){
q.pop();
continue;
}
ans-=map[tmp][map[tmp][0]];
num=map[tmp][++map[tmp][0]];
ans+=num;
q.pop();
q.push(make_pair(num,tmp));
printf("%lld ",ans);
tt++;
}
printf("\n");
return 0;
}