#include<bits/stdc++.h>
using namespace std;
int a[10000+10];
int main()
{
    int n,k,cn=0,sum=0;//c means
    cin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]<0)
            cn++;
    }
    if(cn==0)
    {
        if(k%2!=0)
            a[1]=-a[1];
        for(int i=1; i<=n; i++)
            sum+=a[i];
        cout<<sum;
        return 0;
    }
    else if(k<=cn)
    {
        for(int i=1; i<=k; i++)
            sum+=abs(a[i]);
        for(int i=k+1; i<=n; i++)
            sum+=a[i];
    }
    else
    {
        if(cn==n)
        {
            if(k%2==1)
                a[n]=-a[n];
            for(int i=1; i<cn; i++)
                sum+=abs(a[i]);
            for(int i=cn; i<=n; i++)
                sum+=a[i];
        }
        else if(n>cn)
        {
            int x=abs(a[cn]);
            int y=a[cn+1];
            int remains=k-cn;
            if(y<=x)
            {
                if(remains%2!=0)
                    a[cn+1]=-a[cn+1];
                for(int i=1; i<=cn; i++)
                    sum+=abs(a[i]);
                for(int i=cn+1; i<=n; i++)
                    sum+=a[i];

            }
            else
            {
                int remains=k-cn+1;
                for(int i=1; i<cn; i++)
                    sum+=abs(a[i]);
                if(k%2==1)
                    a[cn]=-a[cn];
                for(int i=cn; i<=n; i++)
                    sum+=a[i];
            }
        }

    }
    cout<<sum<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int a[100000+10];
int main()
{
    int n,k,cn=0,sum=0;//c means
    cin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]<0)
            cn++;
    }
    if(cn==0)
    {
        if(k%2!=0)
            a[1]=-a[1];
        for(int i=1; i<=n; i++)
            sum+=a[i];
        cout<<sum;
        return 0;
    }
    else if(k<=cn)
    {
        for(int i=1; i<=k; i++)
            sum+=abs(a[i]);
        for(int i=k+1; i<=n; i++)
            sum+=a[i];
    }
    else
    {
        if(cn==n)
        {
            int remains=k-cn+1;
            if(remains%2==1)
                a[n]=-a[n];
            for(int i=1; i<cn; i++)
                sum+=abs(a[i]);
            for(int i=cn; i<=n; i++)
                sum+=a[i];
        }
        else if(n>cn)
        {
            int x=abs(a[cn]);
            int y=a[cn+1];
            int remains=k-cn;
            if(y<=x)
            {
                if(remains%2!=0)
                    a[cn+1]=-a[cn+1];
                for(int i=1; i<=cn; i++)
                    sum+=abs(a[i]);
                for(int i=cn+1; i<=n; i++)
                    sum+=a[i];

            }
            else
            {
                int remains=k-cn+1;
                for(int i=1; i<cn; i++)
                    sum+=abs(a[i]);
                if(k%2==1)
                    a[cn]=-a[cn];
                for(int i=cn; i<=n; i++)
                    sum+=a[i];
            }
        }

    }
    cout<<sum<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a,sum=0,minn=1000000;
    scanf("%d%d",&n,&k);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a);
        if(a<0 && k>0)
        {
            a*=-1;
                  k--;
        }
        sum+=a;
        minn=min(minn,a);
    }
    if(k&1)
        sum-=2*minn;
    printf("%d",sum);

}


#include<bits/stdc++.h>
using namespace std;
int a[100000+10];
int main()
{
    int n,k,cn=0,sum=0;//c means
    cin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]<0)
            cn++;
    }
    if(cn==0)
    {
        if(k%2!=0)
            a[1]=-a[1];
        for(int i=1; i<=n; i++)
            sum+=a[i];
        cout<<sum;
        return 0;
    }
    else if(k<=cn)
    {
        for(int i=1; i<=k; i++)
            sum+=abs(a[i]);
        for(int i=k+1; i<=n; i++)
            sum+=a[i];
    }
    else
    {
        if(cn==n)
        {
            int remains=k-cn+1;
            if(remains%2==1)
                a[n]=-a[n];
            for(int i=1; i<cn; i++)
                sum+=abs(a[i]);
            for(int i=cn; i<=n; i++)
                sum+=a[i];
        }
        else if(n>cn)
        {
            int x=abs(a[cn]);
            int y=a[cn+1];
            int remains=k-cn;
            if(y<=x)
            {
                if(remains%2!=0)
                    a[cn+1]=-a[cn+1];
                for(int i=1; i<=cn; i++)
                    sum+=abs(a[i]);
                for(int i=cn+1; i<=n; i++)
                    sum+=a[i];

            }
            else
            {
                int remains=k-cn+1;
                for(int i=1; i<cn; i++)
                    sum+=abs(a[i]);
                if(remains%2==1)
                    a[cn]=-a[cn];
                for(int i=cn; i<=n; i++)
                    sum+=a[i];
            }
        }

    }
    cout<<sum<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int a[100000+50];
int main()
{
    int n,k,minn=10000000,cnt=0,sum=0;
    cin>>n>>k;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]<0 && k>0)
        {
            a[i]*=-1;
                  k--;
        }
        sum+=a[i];
        if(a[i]<minn)
            minn=a[i];
    }
    if(k%2==1)
        sum-=2*minn;
    cout<<sum;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a,sum=0,minn=1000000;
    scanf("%d%d",&n,&k);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a);
        if(a<0 && k>0)
        {
            a*=-1;
                  k--;
        }
        sum+=a;
        if(a<minn)
            minn=a;
    }
    if(k%2==1)
        sum-=2*minn;
    printf("%d",sum);

}


#include<bits/stdc++.h>
using namespace std;
int a[100000+50];
int main()
{
    int n,k,minn=10000000,cnt=0,sum=0;
    scanf("%d%d",&n,&k);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        if(a[i]<0 && k>0)
        {
            a[i]*=-1;
                  k--;
        }
        sum+=a[i];
        if(a[i]<minn)
            minn=a[i];
    }
    if(k%2==1)
        sum-=2*minn;
    printf("%d",sum);

}


#include<bits/stdc++.h>
using namespace std;
int a[10000+10];
int main()
{
    int n,k,cn=0,sum=0;//c means
    cin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]<0)
            cn++;
    }
    if(cn==0)
    {
        if(k%2!=0)
            a[1]=-a[1];
        for(int i=1; i<=n; i++)
            sum+=a[i];
        cout<<sum;
        return 0;
    }
    else if(k<=cn)
    {
        for(int i=1; i<=k; i++)
            sum+=abs(a[i]);
        for(int i=k+1; i<=n; i++)
            sum+=a[i];
    }
    else
    {
        if(cn==n)
        {
            int remains=k-cn+1;
            if(remains%2==1)
                a[n]=-a[n];
            for(int i=1; i<cn; i++)
                sum+=abs(a[i]);
            for(int i=cn; i<=n; i++)
                sum+=a[i];
        }
        else if(n>cn)
        {
            int x=abs(a[cn]);
            int y=a[cn+1];
            int remains=k-cn;
            if(y<=x)
            {
                if(remains%2!=0)
                    a[cn+1]=-a[cn+1];
                for(int i=1; i<=cn; i++)
                    sum+=abs(a[i]);
                for(int i=cn+1; i<=n; i++)
                    sum+=a[i];

            }
            else
            {
                int remains=k-cn+1;
                for(int i=1; i<cn; i++)
                    sum+=abs(a[i]);
                if(k%2==1)
                    a[cn]=-a[cn];
                for(int i=cn; i<=n; i++)
                    sum+=a[i];
            }
        }

    }
    cout<<sum<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i,neg=0,small=1000000,sum=0;
    cin>>n>>k;
    int a[n]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(abs(a[i])<small)
        small=abs(a[i]);
        if(a[i]<0)
        neg++;
    }
    if(k>=neg)
    {
        //cout<<"ok"<<" ";
        if((k-neg)%2==0)
        {
            for(i=0;i<n;i++)
            {
                sum=sum+abs(a[i]);
            }
        }
        else
        {
             //cout<<"ok"<<" ";
            for(i=0;i<n;i++)
            {
                sum+=abs(a[i]);
            }
            sum=sum-(2*small);
        }
    }
   else
   {
       for(i=0;i<n;i++)
       {
           if(k>0)
           {
               sum+=abs(a[i]);
           }
           else
           {
               sum+=a[i];
           }
       }
   }
   cout<<sum<<endl;
   return 0;
}


#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
   int n,k,i,neg=0,sum=0,pos=0,lp=0,sm=INT_MAX,smpos=0;
    cin>>n>>k;
    int a[n]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
     if(a[i]<0)
        {
            neg++;
        }
            if(abs(a[i])<sm)
            {
                sm=a[i];
                smpos=i;
            }
    }
    //cout<<neg<<" "<<smpos;
    if(k>=n)
    {
        if((k-neg)%2==0)
        {
            for(i=0;i<n;i++)
            {
                sum=sum+abs(a[i]);
            }
        }
        else
        {
          for(i=0;i<n;i++)
            {
                if(i==smpos)
                {
                    sum=sum+abs(a[i])*-1;
                }
                else
                {
                    sum=sum+abs(a[i]);
                }
            }
        }
    }
    else
    {
        if(k<=neg)
        {
           // cout<<"hi"<<endl;
           for(i=0;i<n;i++)
            {
                sum=sum+abs(a[i]);
            }
        }
        else
        {
         if((k-neg)%2==0)
        {
            for(i=0;i<n;i++)
            {
                sum=sum+abs(a[i]);
            }
        }
        else
        {
          for(i=0;i<n;i++)
            {
                if(i==smpos)
                {
                    sum=sum+abs(a[i])*-1;
                }
                else
                {
                    sum=sum+abs(a[i]);
                }
            }
        }
        }
    }
        cout<<sum<<endl;
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i,neg=0,small=1000000,sum=0;
    cin>>n>>k;
    int a[n]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(abs(a[i])<small)
        small=abs(a[i]);
        if(a[i]<0)
        neg++;
    }
    if(k>=neg)
    {
        //cout<<"ok"<<" ";
        if((k-neg)%2==0)
        {
            for(i=0;i<n;i++)
            {
                sum=sum+abs(a[i]);
            }
        }
        else
        {
             //cout<<"ok"<<" ";
            for(i=0;i<n;i++)
            {
                sum+=abs(a[i]);
            }
            sum=sum-(2*small);
        }
    }
   else
   {
       for(i=0;i<n;i++)
       {
           if(k>0)
           {
               sum+=abs(a[i]);
               k--;
           }
           else
           {
               sum+=a[i];
           }
       }
   }
   cout<<sum<<endl;
   return 0;
}


#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
  long long int n,k,i,neg=0,sum=0,pos=0,lp=0,sm=INT_MAX,smpos=0;
    cin>>n>>k;
   long long int a[n]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
     if(a[i]<0)
        {
            neg++;
        }
            if(abs(a[i])<sm)
            {
                sm=a[i];
                smpos=i;
            }
    }
    //cout<<neg<<" "<<smpos;
    if(k>=n)
    {
        if((k-neg)%2==0)
        {
            for(i=0;i<n;i++)
            {
                sum=sum+abs(a[i]);
            }
        }
        else
        {
          for(i=0;i<n;i++)
            {
                if(i==smpos)
                {
                    sum=sum+abs(a[i])*-1;
                }
                else
                {
                    sum=sum+abs(a[i]);
                }
            }
        }
    }
    else
    {
        if(k<=neg)
        {
           // cout<<"hi"<<endl;
           for(i=0;i<n;i++)
            {
                if(k>0)
                {
                sum=sum+abs(a[i]);
                k--;
                }
                else
                {
                    sum=sum+a[i];
                }
            }
        }
        else
        {
         if((k-neg)%2==0)
        {
            for(i=0;i<n;i++)
            {
                sum=sum+abs(a[i]);
            }
        }
        else
        {
          for(i=0;i<n;i++)
            {
                if(i==smpos)
                {
                    sum=sum+abs(a[i])*-1;
                }
                else
                {
                    sum=sum+abs(a[i]);
                }
            }
        }
        }
    }
        cout<<sum<<endl;
        return 0;
}


#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
    int n,k,i,neg=0,sum=0,pos=0,lp=0;
    cin>>n>>k;
    int a[n]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<0)
        {
            neg++;
        }
    }
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        if(a[i]>=0)
        {
            pos=i;
            break;
        }
        else if(a[i]<0 && k>0)
        {
            lp=i;
            sum=sum+a[i]*(-1);
            k--;
        }
    }
    if(k>0)
    {
        if(k%2==0)
        {
          for(i=pos;i<n;i++)
         {
             sum=sum+a[i];
         }
        }
        else
        {
            sum=sum+a[pos]*(-1);
             for(i=pos+1;i<n;i++)
         {
             sum=sum+a[i];
         }
        }
    }
    else
    {
       for(i=lp+1;i<n;i++)
         {
             sum=sum+a[i];
         }
    }
    cout<<sum<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
  long long int n,k,i,neg=0,sum=0,pos=0,lp=0,sm=INT_MAX,smpos=0;
    cin>>n>>k;
    int a[n]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
     if(a[i]<0)
        {
            neg++;
        }
            if(abs(a[i])<sm)
            {
                sm=a[i];
                smpos=i;
            }
    }
    //cout<<neg<<" "<<smpos;
    if(k>=n)
    {
        if((k-neg)%2==0)
        {
            for(i=0;i<n;i++)
            {
                sum=sum+abs(a[i]);
            }
        }
        else
        {
          for(i=0;i<n;i++)
            {
                if(i==smpos)
                {
                    sum=sum+abs(a[i])*-1;
                }
                else
                {
                    sum=sum+abs(a[i]);
                }
            }
        }
    }
    else
    {
        if(k<=neg)
        {
           // cout<<"hi"<<endl;
           for(i=0;i<n;i++)
            {
                if(k>0)
                {
                sum=sum+abs(a[i]);
                k--;
                }
                else
                {
                    sum=sum+a[i];
                }
            }
        }
        else
        {
         if((k-neg)%2==0)
        {
            for(i=0;i<n;i++)
            {
                sum=sum+abs(a[i]);
            }
        }
        else
        {
          for(i=0;i<n;i++)
            {
                if(i==smpos)
                {
                    sum=sum+abs(a[i])*-1;
                }
                else
                {
                    sum=sum+abs(a[i]);
                }
            }
        }
        }
    }
        cout<<sum<<endl;
        return 0;
}


#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
   int n,k,i,neg=0,sum=0,pos=0,lp=0,sm=INT_MAX,smpos=0;
    cin>>n>>k;
    int a[n]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
     if(a[i]<0)
        {
            neg++;
        }
            if(abs(a[i])<sm)
            {
                sm=a[i];
                smpos=i;
            }
    }
    //cout<<neg<<" "<<smpos;
    if(k>=n)
    {
        if((k-neg)%2==0)
        {
            for(i=0;i<n;i++)
            {
                sum=sum+abs(a[i]);
            }
        }
        else
        {
          for(i=0;i<n;i++)
            {
                if(i==smpos)
                {
                    sum=sum+abs(a[i])*-1;
                }
                else
                {
                    sum=sum+abs(a[i]);
                }
            }
        }
    }
    else
    {
        if(k<=neg)
        {
           // cout<<"hi"<<endl;
           for(i=0;i<n;i++)
            {
                if(k>0)
                {
                sum=sum+abs(a[i]);
                k--;
                }
                else
                {
                    sum=sum+a[i];
                }
            }
        }
        else
        {
         if((k-neg)%2==0)
        {
            for(i=0;i<n;i++)
            {
                sum=sum+abs(a[i]);
            }
        }
        else
        {
          for(i=0;i<n;i++)
            {
                if(i==smpos)
                {
                    sum=sum+abs(a[i])*-1;
                }
                else
                {
                    sum=sum+abs(a[i]);
                }
            }
        }
        }
    }
        cout<<sum<<endl;
        return 0;
}


#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
  long long int n,k,i,neg=0,sum=0,pos=0,lp=0,sm=INT_MAX,smpos=0;
    cin>>n>>k;
   long long int a[n]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
     if(a[i]<0)
        {
            neg++;
        }
            if(abs(a[i])<sm)
            {
                sm=a[i];
                smpos=i;
            }
    }
    //cout<<neg<<" "<<smpos;
    if(k>=neg)
    {
        if((k-neg)%2==0)
        {
            for(i=0;i<n;i++)
            {
                sum=sum+abs(a[i]);
            }
        }
        else
        {
          for(i=0;i<n;i++)
            {
                if(i==smpos)
                {
                    sum=sum+abs(a[i])*-1;
                }
                else
                {
                    sum=sum+abs(a[i]);
                }
            }
        }
    }
    else
    {
        if(k<=neg)
        {
           // cout<<"hi"<<endl;
           for(i=0;i<n;i++)
            {
                if(k>0)
                {
                sum=sum+abs(a[i]);
                k--;
                }
                else
                {
                    sum=sum+a[i];
                }
            }
        }
       }
        cout<<sum<<endl;
     return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	long long n, k, a[100001];
	cin >> n >> k;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}

	int m = 0;
	for(int i=n-1;i>=0;i--)
	{
		if(a[i] < 0)
		{
			a[i] = -1 * a[i];
			m++;
		}
		if(m == k)
			break;
	}
	if(m < k)
	{
		if((k-m)%2==1)
			a[0] = -1 * a[0];

	}
	long long sum = 0;
	for(int i=0;i<n;i++)
		sum += a[i];

	cout << sum << "\n";
}


#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	long long n, k, a[100001];
	cin >> n >> k;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}

	int m = 0;
	for(int i=0;i<n;i++)
	{
		if(a[i] < 0)
		{
			a[i] = -1 * a[i];
			m++;
		}
		if(m == k)
			break;
	}
	if(m < k)
	{
		if((k-m)%2==1)
		{
			if(a[n-1] < 0)
				a[n-1] = -1 * a[n-1];
			else
				a[0] = -1 * a[0];
		}

	}
	long long sum = 0;
	for(int i=0;i<n;i++)
		sum += a[i];

	cout << sum << "\n";
}


import java.util.*;
import java.io.*;
public class Main {
public static void main(String [] args)throws Exception{
	BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st=new StringTokenizer(bf.readLine());
	int n=Integer.parseInt(st.nextToken());
	int m=Integer.parseInt(st.nextToken());
	int t=Integer.parseInt(st.nextToken());
	int array[][]=new int[n][m];
	for(int i=0;i<n;i++){
		st=new StringTokenizer(bf.readLine());
		for(int j=0;j<m;j++)
		array[i][j]=Integer.parseInt(st.nextToken());
	}
	int ans[]=new int[m];
	int low=0;int high=n;
	while(low < high){
		int mid=(low+high)/2;
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n-mid+1;i++){
			int cur=0;
			for(int k=0;k<m;k++){
				int max=0;
			    for(int j=i;j<i+mid;j++){
			    max=Math.max(array[j][k],max);
			    }
			    cur+=max;
			}
			 min=Math.min(min,cur);
			 if(min==cur){
			 for(int k=0;k<m;k++){
				int max=0;
			           for(int j=i;j<i+mid;j++){
			           max=Math.max(array[j][k],max);
			    }
			    ans[k]=max;
			}
		}
	}
			if(min > t)high=mid;
			else low=mid+1;
			//System.out.println(low+" "+high+" "+mid);
		}
	StringBuilder sb=new StringBuilder();
	for(int i=0;i<m;i++){
		sb.append(ans[i]+" ");
	}
	System.out.print(sb);
}
}


import java.io.*;
import java.util.*;

public class Smile {
	static Scanner in;
	static PrintWriter out;
	static int n, m, k, list;
	static int[][] arr;

	static int search(int l, int r) {
		int res = r;
		for (int i = r + 1; i < n; i++) {
			if (myget(l, i) <= k) {
				res = i;
			} else {
				break;
			}
		}
		return res;
	}

	static int myget(int l, int r) {
		if (l > r) return 0;
		return sum(get(1, 0, list - 1, l, r));
	}

	static int sum(int[] a) {
		int res = 0;
		for (int i = 0; i < m; i++) {
			res += a[i];
		}
		return res;
	}

	static int[] mymax(int[] a, int[] b) {
		int[] res = new int[m];
		for (int i = 0; i < m; i++) {
			res[i] = Math.max(a[i], b[i]);
		}
		return res;
	}

	static int[] get(int v, int a, int b, int l, int r) {
		if (r < a || b < l) {
			int[] zero = new int[m];
			Arrays.fill(zero, 0);
			return zero;
		}
		if (l <= a && b <= r) {
			return arr[v];
		}
		int mid = (a + b) / 2;
		return mymax(get(v * 2, a, mid, l, r),
				get(v * 2 + 1, mid + 1, b, l, r));
	}

	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		n = in.nextInt();
		m = in.nextInt();
		k = in.nextInt();
		int ans = 0;
		int[] s = new int[m];
		list = 1;
		while (list < n) list *= 2;
		arr = new int[2 * list][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				arr[list + i][j] = in.nextInt();
			}
		}
		for (int i = list - 1; i > 0; i--) {
			for (int j = 0; j < m; j++) {
				arr[i][j] = Math.max(arr[2 * i][j], arr[2 * i + 1][j]);
			}
		}
		int r = -1;
		for (int i = 0; i < n; i++) {
			int l = i;
			r = search(l, r);
			if (r - l + 1 > ans) {
				ans = r - l + 1;
				s = get(1, 0, list - 1, l, r);
			}
		}
		for (int i = 0; i < m; i++) {
			out.print (s[i] + " ");
		}
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class Smile {
	static Scanner in;
	static PrintWriter out;
	static int n, m, k, list;
	static int[][] arr;

	static int binSearch(int l) {
		int lf = l - 1;
		int rg = n - 1;
		while (lf < rg) {
			int mid = (lf + rg + 1) / 2;
			if (myget(l, mid) <= k) {
				lf = mid;
			} else {
				rg = mid - 1;
			}
		}
		return lf;
	}

	static int myget(int l, int r) {
		if (l > r) return 0;
		return sum(get(1, 0, list - 1, l, r));
	}

	static int sum(int[] a) {
		int res = 0;
		for (int i = 0; i < m; i++) {
			res += a[i];
		}
		return res;
	}

	static int[] mymax(int[] a, int[] b) {
		int[] res = new int[m];
		for (int i = 0; i < m; i++) {
			res[i] = Math.max(a[i], b[i]);
		}
		return res;
	}

	static int[] get(int v, int a, int b, int l, int r) {
		if (r < a || b < l) {
			int[] zero = new int[m];
			Arrays.fill(zero, 0);
			return zero;
		}
		if (l <= a && b <= r) {
			return arr[v];
		}
		int mid = (a + b) / 2;
		return mymax(get(v * 2, a, mid, l, r),
				get(v * 2 + 1, mid + 1, b, l, r));
	}

	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		n = in.nextInt();
		m = in.nextInt();
		k = in.nextInt();
		int ans = 0;
		int[] s = new int[m];
		list = 1;
		while (list < n) list *= 2;
		arr = new int[2 * list][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				arr[list + i][j] = in.nextInt();
			}
		}
		for (int i = list - 1; i > 0; i--) {
			for (int j = 0; j < m; j++) {
				arr[i][j] = Math.max(arr[2 * i][j], arr[2 * i + 1][j]);
			}
		}
		for (int i = 0; i < n; i++) {
			int l = i;
			int r = binSearch(l);
			if (r - l + 1 > ans) {
				ans = r - l + 1;
				s = get(1, 0, list - 1, l, r);
			}
		}
		for (int i = 0; i < m; i++) {
			out.print (s[i] + " ");
		}
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class Smile {
	static Scanner in;
	static PrintWriter out;
	static int n, m, k, list;
	static int[][] arr;

	static int search(int l, int r) {
		int res = r;
		for (int i = r + 1; i < n; i++) {
			if (myget(l, i) <= k) {
				res = i;
			} else {
				break;
			}
		}
		return res;
	}

	static int myget(int l, int r) {
		if (l > r) return 0;
		return sum(get(1, 0, list - 1, l, r));
	}

	static int sum(int[] a) {
		int res = 0;
		for (int i = 0; i < m; i++) {
			res += a[i];
		}
		return res;
	}

	static int[] mymax(int[] a, int[] b) {
		int[] res = new int[m];
		for (int i = 0; i < m; i++) {
			res[i] = Math.max(a[i], b[i]);
		}
		return res;
	}

	static int[] get(int v, int a, int b, int l, int r) {
		if (r < a || b < l) {
			int[] zero = new int[m];
			Arrays.fill(zero, 0);
			return zero;
		}
		if (l <= a && b <= r) {
			return arr[v];
		}
		int mid = (a + b) / 2;
		return mymax(get(v * 2, a, mid, l, r),
				get(v * 2 + 1, mid + 1, b, l, r));
	}

	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		n = in.nextInt();
		m = in.nextInt();
		k = in.nextInt();
		int ans = 0;
		int[] s = new int[m];
		list = 1;
		while (list < n) list *= 2;
		arr = new int[2 * list][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				arr[list + i][j] = in.nextInt();
			}
		}
		for (int i = list - 1; i > 0; i--) {
			for (int j = 0; j < m; j++) {
				arr[i][j] = Math.max(arr[2 * i][j], arr[2 * i + 1][j]);
			}
		}
		int r = 0;
		for (int i = 0; i < n; i++) {
			int l = i;
			r = search(l, r);
			if (r - l + 1 > ans) {
				ans = r - l + 1;
				s = get(1, 0, list - 1, l, r);
			}
		}
		for (int i = 0; i < m; i++) {
			out.print (s[i] + " ");
		}
		out.close();
	}
}


import java.util.*;
import java.io.*;
public class d {
public static void main(String[] args) throws IOException
{
    input.init(System.in);
    int n = input.nextInt(), m = input.nextInt(), k = input.nextInt();
    RMQ[] rmqs = new RMQ[m];
    int[][] data = new int[m][n];
    for(int i = 0; i<n; i++)
        for(int j = 0; j<m; j++)
        {
            data[j][i] = input.nextInt();
        }
    for(int i = 0; i<m; i++) rmqs[i] = new RMQ(data[i]);
    int max = 0;
    int[] need = new int[m];
    for(int i = 0; i<n; i++)
    {
        int lo = i-1, hi = n;
        while(lo < hi - 1)
        {
            int mid = (lo+hi)>>1;
            int[] cur = new int[m];
            for(int j = 0; j<m; j++)
            {
                cur[j] = rmqs[j].query(i, mid);
            }
            int sum = 0;
            for(int j = 0; j<m; j++)
            {
                sum += cur[j];
            }
            if(sum <= k) lo = mid;
            else hi = mid;
        }
        int ans = (lo - i + 1);
        if(ans > max)
        {
            for(int j = 0; j<m; j++)
            {
                need[j] = rmqs[j].query(i, lo);
            }
            max = ans;
        }
    }
    for(int x : need) System.out.print(x+" ");
}
static class RMQ
{
/*
 * RMQ - range minimum query
 * O(nlogn) preprocessing, O(1) query
 * Store the array in a, then call preprocess().
 * Then, query(i, j) will return minimum between indices i and j (i<=j).
 */
    RMQ(int[] a)
    {
        this.a = a;
        preprocess();
    }
int[][] rmq;
int[] a;
int[] memo;
int log(int x)
{
    if(memo[x] != -1) return memo[x];
    return memo[x] = Integer.numberOfTrailingZeros(Integer.highestOneBit(x));
}
void preprocess()
{
    int n = a.length;
    memo = new int[n+1];
    Arrays.fill(memo, -1);
    rmq = new int[n][log(n)+1];
    for(int i = 0; i<n; i++) rmq[i][0] = i;
    for(int j = 1; (1<<j) <= n; j++)
        for(int i = 0; i + (1<<j) <= n; i++)
            if(a[rmq[i][j-1]] > a[rmq[i+(1<<(j-1))][j-1]])
                rmq[i][j] = rmq[i][j-1];
            else rmq[i][j] = rmq[i+(1<<(j-1))][j-1];
}
int query(int i, int j)
{
    if(j < i) return 0;
    int k = log(j - i + 1);
    return Math.max(a[rmq[i][k]], a[rmq[j-(1<<k)+1][k]]);
}
}
public static class input {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}
}


import java.io.*;
import java.text.DecimalFormat;
import java.util.*;

public class Main {
    static int mod = (int)1e9+7;
    static int N = (int)1e5+10;
    static int ci[] = {1, 0, -1, 0};
    static int cj[] = {0, 1, 0, -1};
    int n, m, k;
    int[][] a = new int[5][N];
    int[] ans = new int[5], t = new int[N];
    int[][][] c = new int[5][20][N];

    void init() {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j)
                c[j][0][i] = a[j][i];
        }
        for (int k = 1; k < 20; ++k) {
            for (int i = 0; i + (1 << k) - 1 < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    c[j][k][i] = Math.max(c[j][k - 1][i], c[j][k - 1][i + (1 << (k - 1))]);
                }
            }
        }
        int k = 0;
        for (int i = 1; i <= n; ++i) {
            t[i] = k;
            if (i + 1 >= 1 << (k + 1))
                k++;
        }
    }
    int getMax(int p, int l, int r) {
        int len = r - l + 1;
        return Math.max(c[p][t[len]][l], c[p][t[len]][r - (1 << t[len]) + 1]);
    }

    boolean check(int len) {
        for (int i = 0; i < n - len + 1; ++i) {
            int sum = 0;
            for (int j = 0; j < m; ++j) {
                ans[j] = getMax(j, i, i + len - 1);
                sum += ans[j];
            }
            if (sum <= k)
                return true;
        }
        return false;
    }
    void work() throws Exception {
        //in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        //
        Scanner cin = new Scanner(System.in);
        /////////////////////////////////////////

        n = cin.nextInt();
        m = cin.nextInt();
        k = cin.nextInt();
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                a[j][i] = cin.nextInt();
            }
        }
        init();

        int l = 0, r = n + 1;
        while (l + 1 < r) {
            int mid = (l + r) / 2;
            if (check(mid)) l = mid;
            else r = mid;
        }
        Arrays.fill(ans, 0);
        if (l != 0) check(l);
        for (int i = 0; i < m; ++i)
            out.println(ans[i]);
    }
  //  BufferedReader in;
  //  StringTokenizer str = null;
    static PrintWriter out;
//    private String next() throws Exception{
//      while (str == null || !str.hasMoreElements())
//          str = new StringTokenizer(in.readLine());
//      return str.nextToken();
//    }
//    private int nextInt() throws Exception{
//      return Integer.parseInt(next());
//    }
//    private long nextLong() throws Exception{
//      return Long.parseLong(next());
//    }
    static int dx[] = {0,1,0,-1};
    static int dy[] = {1,0,-1,0};
    class pair implements Comparable<pair>{
        int first, second;
        pair(int x, int y) {
            first = x;
            second = y;
        }
        public int compareTo(pair o) {
            // TODO auto-generated method stub
            if(first != o.first) return ((Integer)first).compareTo(o.first);
            else return ((Integer)second).compareTo(o.second);
        }
    }
    DecimalFormat df=new DecimalFormat("0.00");
    public static void main(String[] args) throws Exception{
        Main wo = new Main();
        wo.work();
        out.close();
    }
}


import java.util.Map;
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;

public class Main {
    public void solve() {
        Parser parser = new Parser();

        int n = parser.nextInteger();
        int m = parser.nextInteger();
        int k = parser.nextInteger();

        int[][] counts = parser.nextIntegers(m, n);

        TreeMap<Integer, Integer>[] maxCounts = new TreeMap[m];
        for(int i = 0; i < m; ++i) {
            maxCounts[i] = new TreeMap<Integer, Integer>();
        }
        int maxLength = 0;
        int[] maxLengthCounts = new int[m];

        int start = 0;
        int end = 0;
        while(end <= n){
            int shoots = 0;
            if(maxCounts[0].size() > 0)
            for(int i = 0; i < m; ++i){

                shoots += maxCounts[i].lastKey();
            }
            if(end - start > maxLength && shoots <= k){
                maxLength = end - start;
                for(int i = 0; i < m; ++i){
                    maxLengthCounts[i] = maxCounts[i].lastKey();
                }
            }
            if(end == n) break;
            if(shoots <= k){
                for(int i = 0; i < m; ++i){
                    int i1 = counts[i][end];
                    Integer curr = maxCounts[i].get(i1);
                    maxCounts[i].put(i1, curr == null ? 1 : curr + 1);
                }
                ++end;
            } else {
                for(int i = 0; i < m; ++i){
                    int i1 = counts[i][start];
                    Integer curr = maxCounts[i].get(i1);
                    if(curr == 1){
                        maxCounts[i].remove(i1);
                    } else {
                        maxCounts[i].put(i1, curr - 1);
                    }
                }
                ++start;
            }
        }

        for(int i = 0; i < m; ++i){
            System.out.print(maxLengthCounts[i]);
            System.out.print(" ");
        }
    }

    public static void main(String[] args) {
        new Main().solve();
    }

    static public class Parser{
        Scanner scanner;

        public Parser() {
            scanner = new Scanner(System.in);
        }

        public Parser(String str) {
            scanner = new Scanner(str);
        }

        long nextLong(){
            return scanner.nextLong();
        }

        int nextInteger(){
            return scanner.nextInt();
        }

        double nextDouble(){
            return scanner.nextDouble();
        }

        String nextLine(){
            return scanner.nextLine();
        }

        int[] nextIntegers(int count){
            int[] result = new int[count];
            for(int i = 0; i < count; ++i){
                result[i] = nextInteger();
            }
            return result;
        }

        long[] nextLongs(int count){
            long[] result = new long[count];
            for(int i = 0; i < count; ++i){
                result[i] = nextLong();
            }
            return result;
        }

        int[][] nextIntegers(int fields, int count){
            int[][] result = new int[fields][];
            for(int i = 0; i < fields; ++i){
                result[i] = new int[count];
            }
            for(int c = 0; c < count; ++c){
                for(int i = 0; i < fields; ++i){
                    result[i][c] = nextInteger();
                }
            }
            return result;
        }
    }
}


import java.io.*;
import java.util.*;

public class Main {

	static class Assert {

		static void check(boolean e) {
			if (!e) {
				throw new Error();
			}
		}
	}

	static class Scanner {

		StreamTokenizer in;

		Scanner(Reader r) {
			in = new StreamTokenizer(new BufferedReader(r));
			in.resetSyntax();
			in.whitespaceChars(0, 32);
			in.wordChars(33, 255);
		}

		String next() {
			try {
				in.nextToken();
				Assert.check(in.ttype == in.TT_WORD);
				return in.sval;
			} catch (IOException e) {
				throw new Error(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (IOException e) {
                System.err.println(e);
                System.exit(1);
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

	double nextDouble() {
		return Double.parseDouble(next());
	}
    }

	FastScanner in;

	//Scanner in;

	PrintWriter out;

	final int INF = (int)1e9;

	class SegmentTree {

		private int size;
		private int[] tree;

		public SegmentTree(int _size) {
			size = _size;
			tree = new int[4 * size];
		}

		public void buildTree(int[] array, int v, int left, int right) {
			if (left == right) {
				tree[v] = array[left];
			} else {
				int middle = (left + right) / 2;
				buildTree(array, v * 2, left, middle);
				buildTree(array, v * 2 + 1, middle + 1, right);
				tree[v] = Math.max(tree[v * 2], tree[v * 2 + 1]);
			}
		}

		public int getMax(int v, int left, int right, int leftQuery, int rightQuery) {
			if (leftQuery > rightQuery) {
				return 0;
			}
			if (left == leftQuery && right == rightQuery) {
				return tree[v];
			}
			int middle = (left + right) / 2;
			return Math.max(getMax(v * 2, left, middle, leftQuery, Math.min(middle, rightQuery)),
					getMax(v * 2 + 1, middle + 1, right, Math.max(leftQuery, middle + 1), rightQuery));
		}
	}

	void solve() {
		int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();
		int[][] details = new int[m][n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				details[j][i] = in.nextInt();
			}
		}
		SegmentTree[] trees = new SegmentTree[m];
		for (int i = 0; i < m; ++i) {
			trees[i] = new SegmentTree(n);
			trees[i].buildTree(details[i], 1, 0, n - 1);
		}
		int left = 0, right = n + 1;
		while (right - left > 1) {
			int middle = (left + right) / 2;
			boolean f = false;
			for (int i = 0; i + middle - 1 < n; ++i) {
				int res = 0;
				for (int j = 0; j < m; ++j) {
					res += trees[j].getMax(1, 0, n - 1, i, i + middle - 1);
				}
				if (res <= k) {
					f = true;
				}
			}
			if (f) {
				left = middle;
			} else {
				right = middle;
			}
		}
		int[] ans = new int[m];
		for (int i = 0; i + left - 1 < n; ++i) {
			int res = 0;
			int[] curr = new int[m];
			for (int j = 0; j < m; ++j) {
				curr[j] = trees[j].getMax(1, 0, n - 1, i, i + left - 1);
				res += curr[j];
			}
			if (res <= k) {
				ans = curr;
			}
		}
		for (int i = 0; i < ans.length; ++i) {
			out.print(ans[i] + " ");
		}
		out.println();
	}

	void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			//in = new Scanner(new FileReader("input.txt"));
			//out = new PrintWriter(new FileWriter("output.txt"));
		} catch (IOException e) {
			throw new Error(e);
		}
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}


import java.io.*;
import java.util.*;

public class Main {

	static class Assert {

		static void check(boolean e) {
			if (!e) {
				throw new Error();
			}
		}
	}

	static class Scanner {

		StreamTokenizer in;

		Scanner(Reader r) {
			in = new StreamTokenizer(new BufferedReader(r));
			in.resetSyntax();
			in.whitespaceChars(0, 32);
			in.wordChars(33, 255);
		}

		String next() {
			try {
				in.nextToken();
				Assert.check(in.ttype == in.TT_WORD);
				return in.sval;
			} catch (IOException e) {
				throw new Error(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (IOException e) {
                System.err.println(e);
                System.exit(1);
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

	double nextDouble() {
		return Double.parseDouble(next());
	}
    }

	FastScanner in;

	//Scanner in;

	PrintWriter out;

	final int INF = (int)1e9;

	class SegmentTree {

		private int size;
		private int[] tree;

		public SegmentTree(int _size) {
			size = _size;
			tree = new int[4 * size];
		}

		public void buildTree(int[] array, int v, int left, int right) {
			if (left == right) {
				tree[v] = array[left];
			} else {
				int middle = (left + right) / 2;
				buildTree(array, v * 2, left, middle);
				buildTree(array, v * 2 + 1, middle + 1, right);
				tree[v] = Math.max(tree[v * 2], tree[v * 2 + 1]);
			}
		}

		public int getMax(int v, int left, int right, int leftQuery, int rightQuery) {
			if (leftQuery > rightQuery) {
				return -INF;
			}
			if (left == leftQuery && right == rightQuery) {
				return tree[v];
			}
			int middle = (left + right) / 2;
			return Math.max(getMax(v * 2, left, middle, leftQuery, Math.min(middle, rightQuery)),
					getMax(v * 2 + 1, middle + 1, right, Math.max(leftQuery, middle + 1), rightQuery));
		}
	}

	void solve() {
		int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();
		int[][] details = new int[m][n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				details[j][i] = in.nextInt();
			}
		}
		SegmentTree[] trees = new SegmentTree[m];
		for (int i = 0; i < m; ++i) {
			trees[i] = new SegmentTree(n);
			trees[i].buildTree(details[i], 1, 0, n - 1);
		}
		int left = 0, right = n + 1;
		while (right - left > 1) {
			int middle = (left + right) / 2;
			boolean f = false;
			for (int i = 0; i + middle - 1 < n; ++i) {
				int res = 0;
				for (int j = 0; j < m; ++j) {
					res += trees[j].getMax(1, 0, n - 1, i, i + middle - 1);
				}
				if (res <= k) {
					f = true;
				}
			}
			if (f) {
				left = middle;
			} else {
				right = middle;
			}
		}
		int[] ans = new int[m];
		for (int i = 0; i + left - 1 < n; ++i) {
			int res = 0;
			int[] curr = new int[m];
			for (int j = 0; j < m; ++j) {
				curr[j] = trees[j].getMax(1, 0, n - 1, i, i + left - 1);
				res += curr[j];
			}
			if (res <= k) {
				ans = curr;
			}
		}
		for (int i = 0; i < ans.length; ++i) {
			out.print(ans[i] + " ");
		}
		out.println();
	}

	void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			//in = new Scanner(new FileReader("input.txt"));
			//out = new PrintWriter(new FileWriter("output.txt"));
		} catch (IOException e) {
			throw new Error(e);
		}
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}


import java.io.*;
import java.util.*;

public class Main {

	static class Assert {

		static void check(boolean e) {
			if (!e) {
				throw new Error();
			}
		}
	}

	static class Scanner {

		StreamTokenizer in;

		Scanner(Reader r) {
			in = new StreamTokenizer(new BufferedReader(r));
			in.resetSyntax();
			in.whitespaceChars(0, 32);
			in.wordChars(33, 255);
		}

		String next() {
			try {
				in.nextToken();
				Assert.check(in.ttype == in.TT_WORD);
				return in.sval;
			} catch (IOException e) {
				throw new Error(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (IOException e) {
                System.err.println(e);
                System.exit(1);
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

	double nextDouble() {
		return Double.parseDouble(next());
	}
    }

	FastScanner in;

	//Scanner in;

	PrintWriter out;

	final int INF = (int)1e9;

	class SegmentTree {

		private int size;
		private int[] tree;

		public SegmentTree(int _size) {
			size = _size;
			tree = new int[4 * size];
		}

		public void buildTree(int[] array, int v, int left, int right) {
			if (left == right) {
				tree[v] = array[left];
			} else {
				int middle = (left + right) / 2;
				buildTree(array, v * 2, left, middle);
				buildTree(array, v * 2 + 1, middle + 1, right);
				tree[v] = Math.max(tree[v * 2], tree[v * 2 + 1]);
			}
		}

		public int getMax(int v, int left, int right, int leftQuery, int rightQuery) {
			if (leftQuery > rightQuery) {
				return 0;
			}
			if (left == leftQuery && right == rightQuery) {
				return tree[v];
			}
			int middle = (left + right) / 2;
			return Math.max(getMax(v * 2, left, middle, leftQuery, Math.min(middle, rightQuery)),
					getMax(v * 2 + 1, middle + 1, right, Math.max(leftQuery, middle + 1), rightQuery));
		}
	}

	void solve() {
		int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();
		int[][] details = new int[m][n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				details[j][i] = in.nextInt();
			}
		}
		SegmentTree[] trees = new SegmentTree[m];
		for (int i = 0; i < m; ++i) {
			trees[i] = new SegmentTree(n);
			trees[i].buildTree(details[i], 1, 0, n - 1);
		}
		int left = 0, right = n + 1;
		while (right - left > 1) {
			int middle = (left + right) / 2;
			boolean f = false;
			for (int i = 0; i + middle - 1 < n; ++i) {
				int res = 0;
				for (int j = 0; j < m; ++j) {
					res += trees[j].getMax(1, 0, n - 1, i, i + middle - 1);
				}
				if (res <= k) {
					f = true;
					break;
				}
			}
			if (f) {
				left = middle;
			} else {
				right = middle;
			}
		}
		int[] ans = new int[m];
		for (int i = 0; i + left - 1 < n; ++i) {
			int res = 0;
			int[] curr = new int[m];
			for (int j = 0; j < m; ++j) {
				curr[j] = trees[j].getMax(1, 0, n - 1, i, i + left - 1);
				res += curr[j];
			}
			if (res <= k) {
				ans = curr;
			}
		}
		for (int i = 0; i < ans.length; ++i) {
			out.print(ans[i] + " ");
		}
		out.println();
	}

	void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			//in = new Scanner(new FileReader("input.txt"));
			//out = new PrintWriter(new FileWriter("output.txt"));
		} catch (IOException e) {
			throw new Error(e);
		}
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}


import java.io.*;
import java.util.*;

public class Main {

	static class Assert {

		static void check(boolean e) {
			if (!e) {
				throw new Error();
			}
		}
	}

	static class Scanner {

		StreamTokenizer in;

		Scanner(Reader r) {
			in = new StreamTokenizer(new BufferedReader(r));
			in.resetSyntax();
			in.whitespaceChars(0, 32);
			in.wordChars(33, 255);
		}

		String next() {
			try {
				in.nextToken();
				Assert.check(in.ttype == in.TT_WORD);
				return in.sval;
			} catch (IOException e) {
				throw new Error(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (IOException e) {
                System.err.println(e);
                System.exit(1);
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

	double nextDouble() {
		return Double.parseDouble(next());
	}
    }

	FastScanner in;

	//Scanner in;

	PrintWriter out;

	final int INF = (int)1e9;

	class SegmentTree {

		private int size;
		private int[] tree;

		public SegmentTree(int _size) {
			size = _size;
			tree = new int[4 * size];
		}

		public void buildTree(int[] array, int v, int left, int right) {
			if (left == right) {
				tree[v] = array[left];
			} else {
				int middle = (left + right) / 2;
				buildTree(array, v * 2, left, middle);
				buildTree(array, v * 2 + 1, middle + 1, right);
				tree[v] = Math.max(tree[v * 2], tree[v * 2 + 1]);
			}
		}

		public int getMax(int v, int left, int right, int leftQuery, int rightQuery) {
			if (leftQuery > rightQuery) {
				return -INF;
			}
			if (left == leftQuery && right == rightQuery) {
				return tree[v];
			}
			int middle = (left + right) / 2;
			return Math.max(getMax(v * 2, left, middle, leftQuery, Math.min(middle, rightQuery)),
					getMax(v * 2 + 1, middle + 1, right, Math.max(leftQuery, middle + 1), rightQuery));
		}
	}

	void solve() {
		int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();
		int[][] details = new int[m][n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				details[j][i] = in.nextInt();
			}
		}
		SegmentTree[] trees = new SegmentTree[m];
		for (int i = 0; i < m; ++i) {
			trees[i] = new SegmentTree(n);
			trees[i].buildTree(details[i], 1, 0, n - 1);
		}
		int left = 0, right = n;
		while (right - left > 1) {
			int middle = (left + right) / 2;
			boolean f = false;
			for (int i = 0; i + middle - 1 < n; ++i) {
				int res = 0;
				for (int j = 0; j < m; ++j) {
					res += trees[j].getMax(1, 0, n - 1, i, i + middle - 1);
				}
				if (res <= k) {
					f = true;
				}
			}
			if (f) {
				left = middle;
			} else {
				right = middle;
			}
		}
		int[] ans = new int[m];
		for (int i = 0; i + left - 1 < n; ++i) {
			int res = 0;
			int[] curr = new int[m];
			for (int j = 0; j < m; ++j) {
				curr[j] = trees[j].getMax(1, 0, n - 1, i, i + left - 1);
				res += curr[j];
			}
			if (res <= k) {
				ans = curr;
			}
		}
		for (int i = 0; i < ans.length; ++i) {
			out.print(ans[i] + " ");
		}
		out.println();
	}

	void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			//in = new Scanner(new FileReader("input.txt"));
			//out = new PrintWriter(new FileWriter("output.txt"));
		} catch (IOException e) {
			throw new Error(e);
		}
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}


import java.io.*;
import java.util.*;

public class Main {

	static class Assert {

		static void check(boolean e) {
			if (!e) {
				throw new Error();
			}
		}
	}

	static class Scanner {

		StreamTokenizer in;

		Scanner(Reader r) {
			in = new StreamTokenizer(new BufferedReader(r));
			in.resetSyntax();
			in.whitespaceChars(0, 32);
			in.wordChars(33, 255);
		}

		String next() {
			try {
				in.nextToken();
				Assert.check(in.ttype == in.TT_WORD);
				return in.sval;
			} catch (IOException e) {
				throw new Error(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (IOException e) {
                System.err.println(e);
                System.exit(1);
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

	double nextDouble() {
		return Double.parseDouble(next());
	}
    }

	//FastScanner in;

	//Scanner in;

	PrintWriter out;

	final int INF = (int)1e9;

	class SegmentTree {

		private int size;
		private int[] tree;

		public SegmentTree(int _size) {
			size = _size;
			tree = new int[4 * size];
		}

		public void buildTree(int[] array, int v, int left, int right) {
			if (left == right) {
				tree[v] = array[left];
			} else {
				int middle = (left + right) / 2;
				buildTree(array, v * 2, left, middle);
				buildTree(array, v * 2 + 1, middle + 1, right);
				tree[v] = Math.max(tree[v * 2], tree[v * 2 + 1]);
			}
		}

		public int getMax(int v, int left, int right, int leftQuery, int rightQuery) {
			if (leftQuery > rightQuery) {
				return 0;
			}
			if (left == leftQuery && right == rightQuery) {
				return tree[v];
			}
			int middle = (left + right) / 2;
			return Math.max(getMax(v * 2, left, middle, leftQuery, Math.min(middle, rightQuery)),
					getMax(v * 2 + 1, middle + 1, right, Math.max(leftQuery, middle + 1), rightQuery));
		}
	}

	class FastReader extends BufferedReader {

	    public FastReader(InputStream is) {
	        super(new InputStreamReader(is));
	    }

	    public int read() {
	        try {
	            int ret = super.read();
//	            if (isEOF && ret < 0) {
//	                throw new InputMismatchException();
//	            }
//	            isEOF = ret == -1;
	            return ret;
	        } catch (IOException e) {
	            throw new InputMismatchException();
	        }
	    }

	    boolean isWhiteSpace(int c) {
	        return c >= 0 && c <= 32;
	    }

	    public int nextInt() {
	        int c = read();
	        while (isWhiteSpace(c)) {
	            c = read();
	        }
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = read();
	        }
	        int ret = 0;
	        while (c >= 0 && !isWhiteSpace(c)) {
	            if (c < '0' || c > '9') {
	                throw new NumberFormatException("digit expected " + (char) c
	                        + " found");
	            }
	            ret = ret * 10 + c - '0';
	            c = read();
	        }
	        return ret * sgn;
	    }

	    public String readLine() {
	        try {
	            return super.readLine();
	        } catch (IOException e) {
	            return null;
	        }
	    }

	}

	void solve() throws IOException {
		FastScanner in = new FastScanner(System.in);
		int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();
		int[][] details = new int[m][n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				details[j][i] = in.nextInt();
			}
		}
		SegmentTree[] trees = new SegmentTree[m];
		for (int i = 0; i < m; ++i) {
			trees[i] = new SegmentTree(n);
			trees[i].buildTree(details[i], 1, 0, n - 1);
		}
		int left = 0, right = n + 1;
		while (right - left > 1) {
			int middle = (left + right) / 2;
			boolean f = false;
			for (int i = 0; i + middle - 1 < n; ++i) {
				int res = 0;
				for (int j = 0; j < m; ++j) {
					res += trees[j].getMax(1, 0, n - 1, i, i + middle - 1);
				}
				if (res <= k) {
					f = true;
					break;
				}
			}
			if (f) {
				left = middle;
			} else {
				right = middle;
			}
		}
		int[] ans = new int[m];
		for (int i = 0; i + left - 1 < n; ++i) {
			int res = 0;
			int[] curr = new int[m];
			for (int j = 0; j < m; ++j) {
				curr[j] = trees[j].getMax(1, 0, n - 1, i, i + left - 1);
				res += curr[j];
			}
			if (res <= k) {
				ans = curr;
			}
		}
		for (int i = 0; i < ans.length; ++i) {
			out.print(ans[i] + " ");
		}
		out.println();
	}

	void run() throws IOException {
		//in = new FastScanner(System.in);
		out = new PrintWriter(System.out);
		//in = new Scanner(new FileReader("input.txt"));
		//out = new PrintWriter(new FileWriter("output.txt"));
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public static void main(String args[]) throws IOException {
		new Main().run();
	}
}


import java.io.*;
import java.util.*;

public class Main {

	static class Assert {

		static void check(boolean e) {
			if (!e) {
				throw new Error();
			}
		}
	}

	static class Scanner {

		StreamTokenizer in;

		Scanner(Reader r) {
			in = new StreamTokenizer(new BufferedReader(r));
			in.resetSyntax();
			in.whitespaceChars(0, 32);
			in.wordChars(33, 255);
		}

		String next() {
			try {
				in.nextToken();
				Assert.check(in.ttype == in.TT_WORD);
				return in.sval;
			} catch (IOException e) {
				throw new Error(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (IOException e) {
                System.err.println(e);
                System.exit(1);
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

	double nextDouble() {
		return Double.parseDouble(next());
	}
    }

	FastScanner in;

	//Scanner in;

	PrintWriter out;

	final int INF = (int)1e9;

	class SegmentTree {

		private int size;
		private int[] tree;

		public SegmentTree(int _size) {
			size = _size;
			tree = new int[4 * size];
		}

		public void buildTree(int[] array, int v, int left, int right) {
			if (left == right) {
				tree[v] = array[left];
			} else {
				int middle = (left + right) / 2;
				buildTree(array, v * 2, left, middle);
				buildTree(array, v * 2 + 1, middle + 1, right);
				tree[v] = Math.max(tree[v * 2], tree[v * 2 + 1]);
			}
		}

		public int getMax(int v, int left, int right, int leftQuery, int rightQuery) {
			if (leftQuery > rightQuery) {
				return 0;
			}
			if (left == leftQuery && right == rightQuery) {
				return tree[v];
			}
			int middle = (left + right) / 2;
			return Math.max(getMax(v * 2, left, middle, leftQuery, Math.min(middle, rightQuery)),
					getMax(v * 2 + 1, middle + 1, right, Math.max(leftQuery, middle + 1), rightQuery));
		}
	}

	void solve() {
		int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();
		int[][] details = new int[m][n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				details[j][i] = in.nextInt();
			}
		}
		SegmentTree[] trees = new SegmentTree[m];
		for (int i = 0; i < m; ++i) {
			trees[i] = new SegmentTree(n);
			trees[i].buildTree(details[i], 1, 0, n - 1);
		}
		int left = 0, right = n;
		while (right - left > 1) {
			int middle = (left + right) / 2;
			boolean f = false;
			for (int i = 0; i + middle - 1 < n; ++i) {
				int res = 0;
				for (int j = 0; j < m; ++j) {
					res += trees[j].getMax(1, 0, n - 1, i, i + middle - 1);
				}
				if (res <= k) {
					f = true;
				}
			}
			if (f) {
				left = middle;
			} else {
				right = middle;
			}
		}
		int[] ans = new int[m];
		for (int i = 0; i + left - 1 < n; ++i) {
			int res = 0;
			int[] curr = new int[m];
			for (int j = 0; j < m; ++j) {
				curr[j] = trees[j].getMax(1, 0, n - 1, i, i + left - 1);
				res += curr[j];
			}
			if (res <= k) {
				ans = curr;
			}
		}
		for (int i = 0; i < ans.length; ++i) {
			out.print(ans[i] + " ");
		}
		out.println();
	}

	void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			//in = new Scanner(new FileReader("input.txt"));
			//out = new PrintWriter(new FileWriter("output.txt"));
		} catch (IOException e) {
			throw new Error(e);
		}
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}


import java.io.*;
import java.util.*;

public class Main {

	static class Assert {

		static void check(boolean e) {
			if (!e) {
				throw new Error();
			}
		}
	}

	static class Scanner {

		StreamTokenizer in;

		Scanner(Reader r) {
			in = new StreamTokenizer(new BufferedReader(r));
			in.resetSyntax();
			in.whitespaceChars(0, 32);
			in.wordChars(33, 255);
		}

		String next() {
			try {
				in.nextToken();
				Assert.check(in.ttype == in.TT_WORD);
				return in.sval;
			} catch (IOException e) {
				throw new Error(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (IOException e) {
                System.err.println(e);
                System.exit(1);
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

	double nextDouble() {
		return Double.parseDouble(next());
	}
    }

	//FastScanner in;

	//Scanner in;

	PrintWriter out;

	final int INF = (int)1e9;

	class SegmentTree {

		private int size;
		private int[] tree;

		public SegmentTree(int _size) {
			size = _size;
			tree = new int[4 * size];
		}

		public void buildTree(int[] array, int v, int left, int right) {
			if (left == right) {
				tree[v] = array[left];
			} else {
				int middle = (left + right) / 2;
				buildTree(array, v * 2, left, middle);
				buildTree(array, v * 2 + 1, middle + 1, right);
				tree[v] = Math.max(tree[v * 2], tree[v * 2 + 1]);
			}
		}

		public int getMax(int v, int left, int right, int leftQuery, int rightQuery) {
			if (leftQuery > rightQuery) {
				return 0;
			}
			if (left == leftQuery && right == rightQuery) {
				return tree[v];
			}
			int middle = (left + right) / 2;
			return Math.max(getMax(v * 2, left, middle, leftQuery, Math.min(middle, rightQuery)),
					getMax(v * 2 + 1, middle + 1, right, Math.max(leftQuery, middle + 1), rightQuery));
		}
	}

	class FastReader extends BufferedReader {

	    public FastReader(InputStream is) {
	        super(new InputStreamReader(is));
	    }

	    public int read() {
	        try {
	            int ret = super.read();
//	            if (isEOF && ret < 0) {
//	                throw new InputMismatchException();
//	            }
//	            isEOF = ret == -1;
	            return ret;
	        } catch (IOException e) {
	            throw new InputMismatchException();
	        }
	    }

	    boolean isWhiteSpace(int c) {
	        return c >= 0 && c <= 32;
	    }

	    public int nextInt() {
	        int c = read();
	        while (isWhiteSpace(c)) {
	            c = read();
	        }
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = read();
	        }
	        int ret = 0;
	        while (c >= 0 && !isWhiteSpace(c)) {
	            if (c < '0' || c > '9') {
	                throw new NumberFormatException("digit expected " + (char) c
	                        + " found");
	            }
	            ret = ret * 10 + c - '0';
	            c = read();
	        }
	        return ret * sgn;
	    }

	    public String readLine() {
	        try {
	            return super.readLine();
	        } catch (IOException e) {
	            return null;
	        }
	    }

	}

	void solve() throws IOException {
		FastScanner in = new FastScanner(System.in);
		int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();
		int[][] details = new int[m][n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				details[j][i] = in.nextInt();
			}
		}
		SegmentTree[] trees = new SegmentTree[m];
		for (int i = 0; i < m; ++i) {
			trees[i] = new SegmentTree(n);
			trees[i].buildTree(details[i], 1, 0, n - 1);
		}
		int left = 0, right = n + 1;
		while (right - left > 1) {
			int middle = (left + right) / 2;
			boolean f = false;
			for (int i = 0; i + middle - 1 < n; ++i) {
				int res = 0;
				for (int j = 0; j < m; ++j) {
					res += trees[j].getMax(1, 0, n - 1, i, i + middle - 1);
				}
				if (res <= k) {
					f = true;
				}
			}
			if (f) {
				left = middle;
			} else {
				right = middle;
			}
		}
		int[] ans = new int[m];
		for (int i = 0; i + left - 1 < n; ++i) {
			int res = 0;
			int[] curr = new int[m];
			for (int j = 0; j < m; ++j) {
				curr[j] = trees[j].getMax(1, 0, n - 1, i, i + left - 1);
				res += curr[j];
			}
			if (res <= k) {
				ans = curr;
			}
		}
		for (int i = 0; i < ans.length; ++i) {
			out.print(ans[i] + " ");
		}
		out.println();
	}

	void run() throws IOException {
		//in = new FastScanner(System.in);
		out = new PrintWriter(System.out);
		//in = new Scanner(new FileReader("input.txt"));
		//out = new PrintWriter(new FileWriter("output.txt"));
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public static void main(String args[]) throws IOException {
		new Main().run();
	}
}


import java.util.*;
import java.io.*;

public class D
{
   public static void main(String[] args)
   {
      PrintWriter out = new PrintWriter(System.out);
      new D(new FastScanner(), out);
      out.close();
   }

   void add(int v, ArrayDeque<Integer> q)
   {
      while (q.size() > 0 && q.peekLast().intValue() < v)
         q.pollLast();
      q.addLast(v);
   }

   void remove(int v, ArrayDeque<Integer> q)
   {
      if (q.peekFirst().intValue() == v)
         q.pollFirst();
   }

   int M;
   ArrayDeque<Integer>[] qs;
   int score(int[] vv)
   {
      int res = 0;
      for (int i=0; i<M; i++)
      {
         int v = vv[i];
         if (qs[i].size() > 0)
            v = Math.max(v, qs[i].peekFirst());
         res += v;
      }
      return res;
   }

   public D(FastScanner in, PrintWriter out)
   {
      int N = in.nextInt();
      M = in.nextInt();
      int K = in.nextInt();
      int[][] vs = new int[N][M];
      for (int i=0; i<N; i++)
         for (int j=0; j<M; j++)
            vs[i][j] = in.nextInt();
      qs = new ArrayDeque[M];
      for (int i=0; i<M; i++)
         qs[i] = new ArrayDeque<>();

      int[] bestScore = new int[M];
      int bestVal = 0;

      int j = 0;
      for (int i=0; i<N; i++)
      {
         while (j < N && score(vs[j]) <= K)
         {
            for (int x=0; x<M; x++)
               add(vs[j][x], qs[x]);
            j++;
         }
         int rr = j-i;
         if (rr > bestVal)
         {
            //System.out.printf("%d %d%n", i, j);
            bestVal = rr;
            for (int x=0; x<M; x++)
               bestScore[x] = qs[x].peekFirst();
            //System.out.println(Arrays.toString(bestScore));
         }

         if (i < j)
         {
            for (int x=0; x<M; x++)
               remove(vs[i][x], qs[x]);
         }
         else
            j = i+1;
      }

      for (int x=0; x<M; x++)
      {
         out.print(bestScore[x]);
         out.print(' ');
      }
      out.println();
   }
}

class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner()
    {
        stream = System.in;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


import java.util.*;
import java.io.*;

public class D
{
   public static void main(String[] args)
   {
      PrintWriter out = new PrintWriter(System.out);
      new D(new FastScanner(), out);
      out.close();
   }

   void add(int v, ArrayDeque<Integer> q)
   {
      while (q.size() > 0 && q.peekLast().intValue() < v)
         q.pollLast();
      q.addLast(v);
   }

   void remove(int v, ArrayDeque<Integer> q)
   {
      if (q.peekFirst().intValue() == v)
         q.pollFirst();
   }

   int M;
   ArrayDeque<Integer>[] qs;
   int score(int[] vv)
   {
      int res = 0;
      for (int i=0; i<M; i++)
      {
         int v = vv[i];
         if (qs[i].size() > 0)
            v = Math.max(v, qs[i].peekFirst());
         res += v;
      }
      return res;
   }

   public D(FastScanner in, PrintWriter out)
   {
      int N = in.nextInt();
      M = in.nextInt();
      int K = in.nextInt();
      int[][] vs = new int[N][M];
      for (int i=0; i<N; i++)
         for (int j=0; j<M; j++)
            vs[i][j] = in.nextInt();
      qs = new ArrayDeque[M];
      for (int i=0; i<M; i++)
         qs[i] = new ArrayDeque<>();

      int[] bestScore = new int[M];
      int bestVal = 0;

      int j = 0;
      for (int i=0; i<N; i++)
      {
         while (j < N && score(vs[j]) <= K)
         {
            for (int x=0; x<M; x++)
               add(vs[j][x], qs[x]);
            j++;
         }
         int rr = j-i+1;
         if (rr > bestVal)
         {
            //System.out.printf("%d %d%n", i, j);
            bestVal = rr;
            for (int x=0; x<M; x++)
               bestScore[x] = qs[x].peekFirst();
            //System.out.println(Arrays.toString(bestScore));
         }

         if (i < j)
         {
            for (int x=0; x<M; x++)
               remove(vs[i][x], qs[x]);
         }
         else
            j = i+1;
      }

      for (int x=0; x<M; x++)
      {
         out.print(bestScore[x]);
         out.print(' ');
      }
      out.println();
   }
}

class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner()
    {
        stream = System.in;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


// package Div2;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class Sketch {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int m = input.nextInt();
		int k = input.nextInt();

		int[][] A = new int[n][m];
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				A[i][j] = input.nextInt();
			}
		}
		input.close();

		int x = 1;
		int logn = 0;
		while(x <= n){
			x *= 2;
			logn++;
		}

		int[][][] RMQ = new int[m][n][logn];
		for(int i=0; i<m; i++){
			int of = 1;
			for(int offset=0; offset<logn; offset++, of*=2){
				for(int j=0; j<=n-of; j++){
					if(offset == 0){
						RMQ[i][j][0] = A[j][i];
					}
					else {
						RMQ[i][j][offset] = Math.max(RMQ[i][j][offset-1], RMQ[i][j+of/2][offset-1]);
					}
				}
			}
		}

		int[] result = new int[m];
		int[] buf = new int[m];

		int hd = 1;
		int tl = n;

		while(true){
			int mid = (hd+tl)/2;
			int lg = 0;
			int max2pow = 1;
			while(max2pow*2 <= mid){
				lg++;
				max2pow *= 2;
			}

			boolean flag = false;
			for(int i=0; i<n-mid+1; i++){
				int cnt = 0;
				for(int j=0; j<m; j++){
					buf[j] = Math.max(RMQ[j][i][lg], RMQ[j][i+mid-max2pow][lg]);
					cnt += buf[j];
				}
				if(cnt <= k){
					flag = true;
					for(int j=0; j<m; j++)
						result[j] = buf[j];
				}
			}

			if(flag){
				hd = mid+1;
				if(hd > tl)
					break;
			}
			else {
				if(tl == hd)
					break;
				tl = mid;
			}
		}

		for(int i=0; i<m; i++)
			System.out.print(result[i] + " ");
	}
}


// package Div2;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class Sketch {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int m = input.nextInt();
		int k = input.nextInt();

		int[][] A = new int[n][m];
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				A[i][j] = input.nextInt();
			}
		}
		input.close();

		int x = 1;
		int logn = 0;
		while(x <= n){
			x *= 2;
			logn++;
		}

		int[][][] RMQ = new int[m][n][logn];
		for(int i=0; i<m; i++){
			int of = 1;
			for(int offset=0; offset<logn; offset++, of*=2){
				for(int j=0; j<=n-of; j++){
					if(offset == 0){
						RMQ[i][j][0] = A[j][i];
					}
					else {
						RMQ[i][j][offset] = Math.max(RMQ[i][j][offset-1], RMQ[i][j+of/2][offset-1]);
					}
				}
			}
		}

		int[] result = new int[m];
		int[] buf = new int[m];

		int hd = 1;
		int tl = n;

		while(hd != tl){
			int mid = (hd+tl)/2;
			int lg = 0;
			int max2pow = 1;
			while(max2pow*2 <= mid){
				lg++;
				max2pow *= 2;
			}

			boolean flag = false;
			for(int i=0; i<n-mid+1; i++){
				int cnt = 0;
				for(int j=0; j<m; j++){
					buf[j] = Math.max(RMQ[j][i][lg], RMQ[j][i+mid-max2pow][lg]);
					cnt += buf[j];
				}
				if(cnt <= k){
					flag = true;
					for(int j=0; j<m; j++)
						result[j] = buf[j];
				}
			}

			if(flag){
				hd = mid+1;
			}
			else
				tl = mid;
		}

		for(int i=0; i<m; i++)
			System.out.print(result[i] + " ");
	}
}


// package Div2;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class Sketch {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int m = input.nextInt();
		int k = input.nextInt();

		int[][] A = new int[n][m];
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				A[i][j] = input.nextInt();
			}
		}
		input.close();

		int x = 1;
		int logn = 0;
		while(x <= n){
			x *= 2;
			logn++;
		}

		int[][][] RMQ = new int[m][n][logn];
		for(int i=0; i<m; i++){
			int of = 1;
			for(int offset=0; offset<logn; offset++, of*=2){
				for(int j=0; j<=n-of; j++){
					if(offset == 0){
						RMQ[i][j][0] = A[j][i];
					}
					else {
						RMQ[i][j][offset] = Math.max(RMQ[i][j][offset-1], RMQ[i][j+of/2][offset-1]);
					}
				}
			}
		}

		int[] result = new int[m];
		int[] buf = new int[m];

		int hd = 1;
		int tl = n;

		while(hd<=tl){
			int mid = (hd+tl)/2;
			int lg = 0;
			int max2pow = 1;
			while(max2pow*2 <= mid){
				lg++;
				max2pow *= 2;
			}

			boolean flag = false;
			for(int i=0; i<n-mid+1; i++){
				int cnt = 0;
				for(int j=0; j<m; j++){
					buf[j] = Math.max(RMQ[j][i][lg], RMQ[j][i+mid-max2pow][lg]);
					cnt += buf[j];
				}
				if(cnt <= k){
					flag = true;
					for(int j=0; j<m; j++)
						result[j] = buf[j];
				}
			}

			if(flag){
				hd = mid+1;
			}
			else
				tl = mid;
		}

		for(int i=0; i<m; i++)
			System.out.print(result[i] + " ");
	}
}


// package Div2;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class Sketch {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int m = input.nextInt();
		int k = input.nextInt();

		int[][] A = new int[n][m];
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				A[i][j] = input.nextInt();
			}
		}
		input.close();

		int x = 1;
		int logn = 0;
		while(x <= n){
			x *= 2;
			logn++;
		}

		int[][][] RMQ = new int[m][n][logn];
		for(int i=0; i<m; i++){
			int of = 1;
			for(int offset=0; offset<logn; offset++, of*=2){
				for(int j=0; j<=n-of; j++){
					if(offset == 0){
						RMQ[i][j][0] = A[j][i];
					}
					else {
						int a = RMQ[i][j][offset-1];
						int b = RMQ[i][j+of/2][offset-1];
						RMQ[i][j][offset] = (a > b)? a:b;
					}
				}
			}
		}

		int[] result = new int[m];
		int[] buf = new int[m];

		int hd = 1;
		int tl = n;

		while(true){
			int mid = (hd+tl)/2;
			int lg = 0;
			int max2pow = 1;
			while(max2pow*2 <= mid){
				lg++;
				max2pow *= 2;
			}

			boolean flag = false;
			for(int i=0; i<n-mid+1; i++){
				int cnt = 0;
				for(int j=0; j<m; j++){
					int a = RMQ[j][i][lg];
					int b = RMQ[j][i+mid-max2pow][lg];
					buf[j] = a>b? a:b;
					cnt += buf[j];
				}
				if(cnt <= k){
					flag = true;
					for(int j=0; j<m; j++)
						result[j] = buf[j];
				}
			}

			if(flag){
				hd = mid+1;
				if(hd > tl)
					break;
			}
			else {
				if(tl == hd)
					break;
				tl = mid;
			}
		}

		for(int i=0; i<m; i++)
			System.out.print(result[i] + " ");
	}
}


// package Div2;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class Sketch {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int m = input.nextInt();
		int k = input.nextInt();

		int[][] A = new int[n][m];
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				A[i][j] = input.nextInt();
			}
		}
		input.close();

		int x = 1;
		int logn = 0;
		while(x <= n){
			x *= 2;
			logn++;
		}

		int[][][] RMQ = new int[m][n][logn];
		for(int i=0; i<m; i++){
			int of = 1;
			for(int offset=0; offset<logn; offset++, of*=2){
				for(int j=0; j<=n-of; j++){
					if(offset == 0){
						RMQ[i][j][0] = A[j][i];
					}
					else {
						RMQ[i][j][offset] = Math.max(RMQ[i][j][offset-1], RMQ[i][j+of/2][offset-1]);
					}
				}
			}
		}

		int[] result = new int[m];
		int[] buf = new int[m];

		int hd = 0;
		int tl = n;

		while(hd != tl){
			int mid = (hd+tl)/2;
			int lg = 0;
			int max2pow = 1;
			while(max2pow*2 <= mid){
				lg++;
				max2pow *= 2;
			}

			boolean flag = false;
			for(int i=0; i<n-mid+1; i++){
				int cnt = 0;
				for(int j=0; j<m; j++){
					buf[j] = Math.max(RMQ[j][i][lg], RMQ[j][i+mid-max2pow][lg]);
					cnt += buf[j];
				}
				if(cnt <= k){
					flag = true;
					for(int j=0; j<m; j++)
						result[j] = buf[j];
				}
			}

			if(flag){
				hd = mid+1;
			}
			else
				tl = mid;
		}

		for(int i=0; i<m; i++)
			System.out.print(result[i] + " ");
	}
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.SortedMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class SolverD {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		new SolverD().Run();
	}

	BufferedReader br;
	PrintWriter pw;
	StringTokenizer stok;

	public String nextToken() throws IOException {
		while (stok == null || !stok.hasMoreTokens()) {
			stok = new StringTokenizer(br.readLine());
		}
		return stok.nextToken();
	}

	public int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	int n, m;
	int max;
	int[][] kol;
	SortedMap<Integer, Integer>[] maps;
	int resLen = 0;
	int[] result;

	void removeNum(SortedMap<Integer, Integer> map, int num){
		Integer kol = map.get(num);
		if (kol!=null){
			kol--;
			if (kol<=0){
				map.remove(num);
			} else {
				map.put(num, kol);
			}
		}
	}

	void addNum(SortedMap<Integer, Integer> map, int num){
		Integer kol = map.get(num);
		if (kol==null)
			kol=0;
		kol++;
		map.put(num, kol);
	}

	int getMax(SortedMap<Integer, Integer> map) {
		Integer result = map.lastKey();
		if (result == null)
			return 0;
		return result;
	}

	public void solve() throws NumberFormatException, IOException {
		n = nextInt();
		m=nextInt();
		max=nextInt();
		kol=new int[n][m];
		for (int i=0; i<n; i++){
			for (int j=0; j<m; j++){
				kol[i][j]=nextInt();
			}
		}
		result = new int[m];
		maps = new SortedMap[m];
		for (int i=0; i<m; i++){
			maps[i]=new TreeMap<Integer, Integer>();
		}

		int curRes = 0;
		int nach = 0;
		int kon = 0;
		while (kon<n && curRes<=max){
			curRes = 0;
			for (int i=0; i<m; i++){
				addNum(maps[i], kol[kon][i]);
				curRes+=getMax(maps[i]);
			}
			kon++;
			if (curRes<=max && kon-nach>resLen){
				for (int i=0; i<m; i++){
					result[i]=getMax(maps[i]);
				}
			}
		}
		while (kon<n){
			while (curRes>max){
				curRes=0;
				for (int i=0; i<m; i++){
					removeNum(maps[i], kol[nach][i]);
					curRes+=getMax(maps[i]);
				}
				nach++;
			}

			while (kon<n && curRes<=max){
				curRes = 0;
				for (int i=0; i<m; i++){
					addNum(maps[i], kol[kon][i]);
					curRes+=getMax(maps[i]);
				}
				kon++;
				if (curRes<=max && kon-nach>resLen){
					for (int i=0; i<m; i++){
						result[i]=getMax(maps[i]);
					}
				}
			}
		}

		for (int i=0; i<m; i++){
			pw.print(result[i]);
			pw.print(' ');
		}
		pw.println();
	}

	public void Run() throws NumberFormatException, IOException {
//		br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter("output.txt");
		br=new BufferedReader(new InputStreamReader(System.in)); pw=new PrintWriter(new OutputStreamWriter(System.out));
		solve();
		pw.flush();
		pw.close();
	}

}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.SortedMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class SolverD {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		new SolverD().Run();
	}

	BufferedReader br;
	PrintWriter pw;
	StringTokenizer stok;

	public String nextToken() throws IOException {
		while (stok == null || !stok.hasMoreTokens()) {
			stok = new StringTokenizer(br.readLine());
		}
		return stok.nextToken();
	}

	public int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	int n, m;
	int max;
	int[][] kol;
	SortedMap<Integer, Integer>[] maps;
	int resLen = 0;
	int[] result;

	void removeNum(SortedMap<Integer, Integer> map, int num){
		Integer kol = map.get(num);
		if (kol!=null){
			kol--;
			if (kol<=0){
				map.remove(num);
			} else {
				map.put(num, kol);
			}
		}
	}

	void addNum(SortedMap<Integer, Integer> map, int num){
		Integer kol = map.get(num);
		if (kol==null)
			kol=0;
		kol++;
		map.put(num, kol);
	}

	int getMax(SortedMap<Integer, Integer> map) {
		Integer result = map.lastKey();
		if (result == null)
			return 0;
		return result;
	}

	public void solve() throws NumberFormatException, IOException {
		n = nextInt();
		m=nextInt();
		max=nextInt();
		kol=new int[n][m];
		for (int i=0; i<n; i++){
			for (int j=0; j<m; j++){
				kol[i][j]=nextInt();
			}
		}
		result = new int[m];
		maps = new SortedMap[m];
		for (int i=0; i<m; i++){
			maps[i]=new TreeMap<Integer, Integer>();
		}

		int curRes = 0;
		int nach = 0;
		int kon = 0;
		while (kon<n && curRes<=max){
			curRes = 0;
			for (int i=0; i<m; i++){
				addNum(maps[i], kol[kon][i]);
				curRes+=getMax(maps[i]);
			}
			kon++;
			if (curRes<=max && kon-nach>resLen){
				resLen=kon-nach;
				for (int i=0; i<m; i++){
					result[i]=getMax(maps[i]);
				}
			}
		}
		while (kon<n){
			while (curRes>max){
				curRes=0;
				for (int i=0; i<m; i++){
					removeNum(maps[i], kol[nach][i]);
					curRes+=getMax(maps[i]);
				}
				nach++;
			}

			while (kon<n && curRes<=max){
				curRes = 0;
				for (int i=0; i<m; i++){
					addNum(maps[i], kol[kon][i]);
					curRes+=getMax(maps[i]);
				}
				kon++;
				if (curRes<=max && kon-nach>resLen){
					resLen=kon-nach;
					for (int i=0; i<m; i++){
						result[i]=getMax(maps[i]);
					}
				}
			}
		}

		for (int i=0; i<m; i++){
			pw.print(result[i]);
			pw.print(' ');
		}
		pw.println();
	}

	public void Run() throws NumberFormatException, IOException {
//		br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter("output.txt");
		br=new BufferedReader(new InputStreamReader(System.in)); pw=new PrintWriter(new OutputStreamWriter(System.out));
		solve();
		pw.flush();
		pw.close();
	}

}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.SortedMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class SolverD {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		new SolverD().Run();
	}

	BufferedReader br;
	PrintWriter pw;
	StringTokenizer stok;

	public String nextToken() throws IOException {
		while (stok == null || !stok.hasMoreTokens()) {
			stok = new StringTokenizer(br.readLine());
		}
		return stok.nextToken();
	}

	public int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	int n, m;
	int max;
	int[][] kol;
	SortedMap<Integer, Integer>[] maps;
	int resLen = 0;
	int[] result;

	void removeNum(SortedMap<Integer, Integer> map, int num){
		Integer kol = map.get(num);
		if (kol!=null){
			kol--;
			if (kol<=0){
				map.remove(num);
			} else {
				map.put(num, kol);
			}
		}
	}

	void addNum(SortedMap<Integer, Integer> map, int num){
		Integer kol = map.get(num);
		if (kol==null)
			kol=0;
		kol++;
		map.put(num, kol);
	}

	int getMax(SortedMap<Integer, Integer> map) {
		if (map.isEmpty())
			return 0;
		Integer result = map.lastKey();
		return result;
	}

	public void solve() throws NumberFormatException, IOException {
		n = nextInt();
		m=nextInt();
		max=nextInt();
		kol=new int[n][m];
		for (int i=0; i<n; i++){
			for (int j=0; j<m; j++){
				kol[i][j]=nextInt();
			}
		}
		result = new int[m];
		maps = new SortedMap[m];
		for (int i=0; i<m; i++){
			maps[i]=new TreeMap<Integer, Integer>();
		}

		int curRes = 0;
		int nach = 0;
		int kon = 0;
		while (kon<n && curRes<=max){
			curRes = 0;
			for (int i=0; i<m; i++){
				addNum(maps[i], kol[kon][i]);
				curRes+=getMax(maps[i]);
			}
			kon++;
			if (curRes<=max && kon-nach>resLen){
				resLen=kon-nach;
				for (int i=0; i<m; i++){
					result[i]=getMax(maps[i]);
				}
			}
		}
		while (kon<n){
			while (curRes>max){
				curRes=0;
				for (int i=0; i<m; i++){
					removeNum(maps[i], kol[nach][i]);
					curRes+=getMax(maps[i]);
				}
				nach++;
			}

			while (kon<n && curRes<=max){
				curRes = 0;
				for (int i=0; i<m; i++){
					addNum(maps[i], kol[kon][i]);
					curRes+=getMax(maps[i]);
				}
				kon++;
				if (curRes<=max && kon-nach>resLen){
					resLen=kon-nach;
					for (int i=0; i<m; i++){
						result[i]=getMax(maps[i]);
					}
				}
			}
		}

		for (int i=0; i<m; i++){
			pw.print(result[i]);
			pw.print(' ');
		}
		pw.println();
	}

	public void Run() throws NumberFormatException, IOException {
//		br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter("output.txt");
		br=new BufferedReader(new InputStreamReader(System.in)); pw=new PrintWriter(new OutputStreamWriter(System.out));
		solve();
		pw.flush();
		pw.close();
	}

}