#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    ll k;
    cin>>n>>m>>k;
    vector<multiset<int>> cnt(m);
    vector<int> ans(m);
    int mxlen=0;
    ll sum=0;
    vector a(n,vector(m,0));
    for(auto& v:a){
        for(auto& it:v) cin>>it;
    }
    int r=0;
    for(int l=0;l<n;l++){
        while(r<n+1&&sum<=k){
            if(r-l>mxlen){
                mxlen=r-l;
                forn(i,m) ans[i]=(cnt[i].empty()?0:*cnt[i].rbegin());
            }
            if(r==n) break;
            sum=0;
            forn(i,m){
                cnt[i].insert(a[r][i]);
                sum+=*cnt[i].rbegin();
            }
            r++;
        }
        sum=0;
        forn(i,m){
            cnt[i].erase(cnt[i].find(a[l][i]));
            if(!cnt[i].empty()) sum+=*cnt[i].rbegin();
        }
    }
    forn(i,m) cout<<ans[i]<<' ';
    return 0;
}


#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m,k;
    cin>>n>>m>>k;
    vector<multiset<int>> cnt(m),ans(m);
    int mxlen=0;
    ll sum=0;
    vector a(n,vector(m,0));
    for(auto& v:a){
        for(auto& it:v) cin>>it;
    }
    int r=0;
    for(int l=0;l<n;l++){
        while(r<n&&sum<=k){
            if(r-l>mxlen){
                mxlen=r-l;
                ans=cnt;
            }
            sum=0;
            forn(i,m){
                cnt[i].insert(a[r][i]);
                sum+=*cnt[i].rbegin();
            }
            r++;
        }
        sum=0;
        forn(i,m){
            cnt[i].erase(cnt[i].find(a[l][i]));
            if(!cnt[i].empty()) sum+=*cnt[i].rbegin();
        }
    }
    forn(i,m) cout<<(ans[i].empty()?0:*ans[i].rbegin())<<' ';
    return 0;
}


#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    ll k;
    cin>>n>>m>>k;
    vector<multiset<int>> cnt(m),ans(m);
    int mxlen=0;
    ll sum=0;
    vector a(n,vector(m,0));
    for(auto& v:a){
        for(auto& it:v) cin>>it;
    }
    int r=0;
    for(int l=0;l<n;l++){
        while(r<n+1&&sum<=k){
            if(r-l>mxlen){
                mxlen=r-l;
                ans=cnt;
            }
            if(r==n) break;
            sum=0;
            forn(i,m){
                cnt[i].insert(a[r][i]);
                sum+=*cnt[i].rbegin();
            }
            r++;
        }
        sum=0;
        forn(i,m){
            cnt[i].erase(cnt[i].find(a[l][i]));
            if(!cnt[i].empty()) sum+=*cnt[i].rbegin();
        }
    }
    forn(i,m) cout<<(ans[i].empty()?0:*ans[i].rbegin())<<' ';
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 100005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(1e6 + 2);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i <= 1e6 + 1; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j <= 1e6 + 2; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll n, m, k;
v<v<ll>> a(N, v<ll>(7));
v<ll> ans(7);
stack<pair<ll, ll>> in[7], out[7];
ll st, en, ST, EN, sum;

void empty_in()
{
    pair<ll, ll> temp;
    while (!in[1].empty())
    {
        for (int i = 1; i <= m; i++)
        {
            temp = in[i].top();
            in[i].pop();

            if (out[i].empty())
                out[i].push(make_pair(temp.second, temp.second));
            else
                out[i].push(make_pair(max(out[i].top().first, temp.second), temp.second));
        }
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin >> n >> m >> k;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    ST = 1, EN = 0;
    ll mx = 0;
    for (ll i = 1; i <= n; i++)
    {
        sum = 0;
        for (ll j = 1; j <= m; j++)
        {
            in[j].push({max((!in[j].empty()) ? in[j].top().fi : 0LL, a[i][j]), a[i][j]});
        }
        for (ll j = 1; j <= m; j++)
        {
            sum += max(in[j].top().fi, (!out[j].empty()) ? out[j].top().fi : 0LL);
        }
        EN++;
        if (sum <= k && mx < EN - ST + 1)
        {
            st = ST, en = EN;
            mx = EN - ST + 1;
        }
        else
        {
            empty_in();
            while (sum > k && ST <= EN + 1)
            {
                sum = 0, ST++;
                for (ll j = 1; j <= m; j++)
                {
                    out[j].pop();
                    sum += max((out[j].empty()) ? 0LL : out[j].top().fi, (in[j].empty()) ? 0LL : in[j].top().fi);
                }
            }
        }
    }
    for (ll i = st; i <= en; i++)
    {
        for (ll j = 1; j <= m; j++)
        {
            ans[j] = max(ans[j], a[i][j]);
        }
    }
    for (ll j = 1; j <= m; j++)
        cout << ans[j] << " ";
    cout << "\n";
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 100005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(1e6 + 2);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i <= 1e6 + 1; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j <= 1e6 + 2; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll n, m, k;
v<v<ll>> a(N, v<ll>(7));
v<ll> ans(7);
stack<pair<ll, ll>> in[7], out[7];
ll st, en, ST, EN, sum;

void empty_in()
{
    for (ll j = 1; j <= m; j++)
    {
        while (!in[j].empty())
        {
            auto temp = in[j].top();
            in[j].pop();
            if (out[j].empty())
                out[j].push({temp.se, temp.se});
            else
                out[j].push({max(out[j].top().fi, temp.se), temp.se});
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin >> n >> m >> k;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    ST = 1, EN = 0;
    ll mx = 0;
    for (ll i = 1; i <= n; i++)
    {
        sum = 0;
        for (ll j = 1; j <= m; j++)
        {
            in[j].push({max(!in[j].empty() ? in[j].top().fi : 0, a[i][j]), a[i][j]});
        }
        for (ll j = 1; j <= m; j++)
        {
            sum += max(in[j].top().fi, (!out[j].empty()) ? out[j].top().fi : 0);
        }
        EN++;
        if (sum <= k && mx < EN - ST + 1)
        {
            st = ST, en = EN;
            mx = EN - ST + 1;
        }
        else
        {
            empty_in();
            while (sum > k && ST <= EN)
            {
                sum = 0, ST++;
                for (ll j = 1; j <= m; j++)
                {
                    out[j].pop();
                    sum += max((out[j].empty()) ? 0 : out[j].top().fi, (in[j].empty()) ? 0 : in[j].top().fi);
                }
            }
        }
    }
    for (ll i = st; i <= en; i++)
    {
        for (ll j = 1; j <= m; j++)
        {
            ans[j] = max(ans[j], a[i][j]);
        }
    }
    for (ll j = 1; j <= m; j++)
        cout << ans[j] << " ";
    cout << "\n";
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 100005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(1e6 + 2);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i <= 1e6 + 1; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j <= 1e6 + 2; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll n, m, k;
v<v<ll>> a(N, v<ll>(7));
v<ll> ans(7);
stack<pair<ll, ll>> in[7], out[7];
ll st, en, ST, EN, sum;

void empty_in()
{
    pair<ll, ll> temp;
    while (!in[1].empty())
    {
        for (int i = 1; i <= m; i++)
        {
            temp = in[i].top();
            in[i].pop();

            if (out[i].empty())
                out[i].push(make_pair(temp.second, temp.second));
            else
                out[i].push(make_pair(max(out[i].top().first, temp.second), temp.second));
        }
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin >> n >> m >> k;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    ST = 1, EN = 1;
    ll mx = 0;
    for (ll i = 1; i <= n; i++)
    {
        sum = 0;
        for (ll j = 1; j <= m; j++)
        {
            in[j].push({max((!in[j].empty()) ? in[j].top().fi : 0LL, a[i][j]), a[i][j]});
        }
        for (ll j = 1; j <= m; j++)
        {
            sum += max(in[j].top().fi, (!out[j].empty()) ? out[j].top().fi : 0LL);
        }
        EN++;
        if (sum <= k && mx < EN - ST + 1)
        {
            st = ST, en = EN;
            mx = EN - ST + 1;
        }
        else
        {
            empty_in();
            while (sum > k && ST <= EN)
            {
                sum = 0, ST++;
                for (ll j = 1; j <= m; j++)
                {
                    out[j].pop();
                    sum += max((out[j].empty()) ? 0LL : out[j].top().fi, (in[j].empty()) ? 0LL : in[j].top().fi);
                }
            }
        }
    }
    for (ll i = st; i <= en; i++)
    {
        for (ll j = 1; j <= m; j++)
        {
            ans[j] = max(ans[j], a[i][j]);
        }
    }
    for (ll j = 1; j <= m; j++)
        cout << ans[j] << " ";
    cout << "\n";
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 100005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(1e6 + 2);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i <= 1e6 + 1; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j <= 1e6 + 2; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll n, m, k;
v<v<ll>> a(N, v<ll>(7));
v<ll> ans(7);
stack<pair<ll, ll>> in[7], out[7];
ll st, en, ST, EN, sum;

void empty_in()
{
    for (ll j = 1; j <= m; j++)
    {
        while (!in[j].empty())
        {
            auto temp = in[j].top();
            in[j].pop();
            if (out[j].empty())
                out[j].push({temp.se, temp.se});
            else
                out[j].push({max(out[j].top().fi, temp.se), temp.se});
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin >> n >> m >> k;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    ST = 1, EN = 0;
    ll mx = 0;
    for (ll i = 1; i <= n; i++)
    {
        sum = 0;
        for (ll j = 1; j <= m; j++)
        {
            in[j].push({max((!in[j].empty()) ? in[j].top().fi : 0LL, a[i][j]), a[i][j]});
        }
        for (ll j = 1; j <= m; j++)
        {
            sum += max(in[j].top().fi, (!out[j].empty()) ? out[j].top().fi : 0LL);
        }
        EN++;
        if (sum <= k && mx < EN - ST + 1)
        {
            st = ST, en = EN;
            mx = EN - ST + 1;
        }
        else
        {
            empty_in();
            while (sum > k && ST <= EN)
            {
                sum = 0, ST++;
                for (ll j = 1; j <= m; j++)
                {
                    out[j].pop();
                    sum += max((out[j].empty()) ? 0LL : out[j].top().fi, (in[j].empty()) ? 0LL : in[j].top().fi);
                }
            }
        }
    }
    for (ll i = st; i <= en; i++)
    {
        for (ll j = 1; j <= m; j++)
        {
            ans[j] = max(ans[j], a[i][j]);
        }
    }
    for (ll j = 1; j <= m; j++)
        cout << ans[j] << " ";
    cout << "\n";
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 100005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(1e6 + 2);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i <= 1e6 + 1; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j <= 1e6 + 2; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll n, m, k;
v<v<ll>> a(N, v<ll>(7));
v<ll> ans(7);
stack<pair<ll, ll>> in[7], out[7];
ll ST, EN;

void empty_in()
{
    pair<ll, ll> temp;
    while (!in[1].empty())
    {
        for (int i = 1; i <= m; i++)
        {
            temp = in[i].top();
            in[i].pop();

            if (out[i].empty())
                out[i].push(make_pair(temp.second, temp.second));
            else
                out[i].push(make_pair(max(out[i].top().first, temp.second), temp.second));
        }
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin >> n >> m >> k;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    ST = 1, EN = 0;
    ll mx = 0;
    for (ll i = 1; i <= n; i++)
    {
        ll sum = 0;
        for (ll j = 1; j <= m; j++)
        {
            if (!in[j].empty())
                in[j].push({max(in[j].top().fi, a[i][j]), a[i][j]});
            else
                in[j].push({a[i][j], a[i][j]});
        }
        for (ll j = 1; j <= m; j++)
        {
            sum += max(in[j].top().fi, (!out[j].empty()) ? out[j].top().fi : 0LL);
        }
        // cout << sum << "\n";
        EN++;
        if (sum <= k)
        {
            if (EN - ST + 1 > mx)
            {
                mx = EN - ST + 1;
                for (ll j = 1; j <= m; j++)
                {
                    ans[j] = max(in[j].top().first, (!out[j].empty()) ? out[j].top().first : 0);
                }
            }
        }
        else
        {
            empty_in();
            while (sum > k && ST <= EN)
            {
                sum = 0, ST++;
                for (ll j = 1; j <= m; j++)
                {
                    out[j].pop();
                    sum += max((out[j].empty()) ? 0LL : out[j].top().fi, (in[j].empty()) ? 0LL : in[j].top().fi);
                }
            }
        }
    }
    for (ll j = 1; j <= m; j++)
        cout << ans[j] << " ";
    cout << "\n";
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 100005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(1e6 + 2);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i <= 1e6 + 1; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j <= 1e6 + 2; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll n, m, k;
v<v<ll>> a(N, v<ll>(7));
v<ll> ans(7);
stack<pair<ll, ll>> in[7], out[7];
ll st, en, ST, EN, sum;

void empty_in()
{
    pair<ll, ll> temp;
    while (!in[1].empty())
    {
        for (int i = 1; i <= m; i++)
        {
            temp = in[i].top();
            in[i].pop();

            if (out[i].empty())
                out[i].push(make_pair(temp.second, temp.second));
            else
                out[i].push(make_pair(max(out[i].top().first, temp.second), temp.second));
        }
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin >> n >> m >> k;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    ST = 1, EN = 0;
    ll mx = 0;
    for (ll i = 1; i <= n; i++)
    {
        sum = 0;
        for (ll j = 1; j <= m; j++)
        {
            in[j].push({max((!in[j].empty()) ? in[j].top().fi : 0LL, a[i][j]), a[i][j]});
        }
        for (ll j = 1; j <= m; j++)
        {
            sum += max(in[j].top().fi, (!out[j].empty()) ? out[j].top().fi : 0LL);
        }
        EN++;
        if (sum <= k && mx < EN - ST + 1)
        {
            st = ST, en = EN;
            mx = EN - ST + 1;
            for (int j = 1; j <= m; j++)
            {
                ans[j] = max(in[j].top().first, (!out[j].empty()) ? out[j].top().first : 0);
            }
        }
        else
        {
            empty_in();
            while (sum > k && ST <= EN)
            {
                sum = 0, ST++;
                for (ll j = 1; j <= m; j++)
                {
                    out[j].pop();
                    sum += max((out[j].empty()) ? 0LL : out[j].top().fi, (in[j].empty()) ? 0LL : in[j].top().fi);
                }
            }
        }
    }
    for (ll j = 1; j <= m; j++)
        cout << ans[j] << " ";
    cout << "\n";
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 100005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(1e6 + 2);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i <= 1e6 + 1; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j <= 1e6 + 2; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll n, m, k;
v<v<ll>> a(N, v<ll>(7));
v<ll> ans(7);
stack<pair<ll, ll>> in[7], out[7];
ll st, en, ST, EN, sum;

void empty_in()
{
    pair<ll, ll> temp;
    while (!in[1].empty())
    {
        for (int i = 1; i <= m; i++)
        {
            temp = in[i].top();
            in[i].pop();

            if (out[i].empty())
                out[i].push(make_pair(temp.second, temp.second));
            else
                out[i].push(make_pair(max(out[i].top().first, temp.second), temp.second));
        }
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin >> n >> m >> k;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    ST = 1, EN = 0;
    ll mx = 0;
    for (ll i = 1; i <= n; i++)
    {
        sum = 0;
        for (ll j = 1; j <= m; j++)
        {
            in[j].push({max((!in[j].empty()) ? in[j].top().fi : 0LL, a[i][j]), a[i][j]});
        }
        for (ll j = 1; j <= m; j++)
        {
            sum += max(in[j].top().fi, (!out[j].empty()) ? out[j].top().fi : 0LL);
        }
        EN++;
        if (sum <= k && mx < EN - ST + 1)
        {
            st = ST, en = EN;
            mx = EN - ST + 1;
            for (int j = 1; j <= m; j++)
            {
                ans[j] = max(in[j].top().first, (!out[j].empty()) ? out[j].top().first : 0);
            }
        }
        else
        {
            empty_in();
            while (sum > k && ST <= EN + 1)
            {
                sum = 0, ST++;
                for (ll j = 1; j <= m; j++)
                {
                    out[j].pop();
                    sum += max((out[j].empty()) ? 0LL : out[j].top().fi, (in[j].empty()) ? 0LL : in[j].top().fi);
                }
            }
        }
    }
    for (ll j = 1; j <= m; j++)
        cout << ans[j] << " ";
    cout << "\n";
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 100005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(1e6 + 2);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i <= 1e6 + 1; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j <= 1e6 + 2; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll n, m, k;
v<v<ll>> a(N, v<ll>(7));
v<ll> ans(7);
stack<pair<ll, ll>> in[7], out[7];
ll ST, EN;

void empty_in()
{
    pair<ll, ll> temp;
    while (!in[1].empty())
    {
        for (int i = 1; i <= m; i++)
        {
            temp = in[i].top();
            in[i].pop();

            if (out[i].empty())
                out[i].push(make_pair(temp.second, temp.second));
            else
                out[i].push(make_pair(max(out[i].top().first, temp.second), temp.second));
        }
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin >> n >> m >> k;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    ST = 1, EN = 1;
    ll mx = 0;
    for (ll i = 1; i <= n; i++)
    {
        ll sum = 0;
        for (ll j = 1; j <= m; j++)
        {
            in[j].push(make_pair(max((!in[j].empty()) ? in[j].top().first : 0, a[i][j]), a[i][j]));
        }
        EN++;
        for (ll j = 1; j <= m; j++)
        {
            sum += max(in[j].top().first, (!out[j].empty()) ? out[j].top().first : 0);
        }
        if (sum <= k)
        {
            if (EN - ST + 1 > mx)
            {
                mx = EN - ST + 1;
                for (ll j = 1; j <= m; j++)
                {
                    ans[j] = max(in[j].top().first, (!out[j].empty()) ? out[j].top().first : 0);
                    ;
                }
            }
        }
        else
        {
            while (sum > k and ST <= EN)
            {
                if (out[1].empty())
                    empty_in();

                sum = 0;
                ST++;

                for (int j = 1; j <= m; j++)
                {
                    if (!out[j].empty())
                    {
                        out[j].pop();
                        sum += max((out[j].empty()) ? 0 : out[j].top().first, (in[j].empty()) ? 0 : in[j].top().first);
                    }
                }
            }
        }
    }
    for (ll j = 1; j <= m; j++)
        cout << ans[j] << " ";
    cout << "\n";
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 100005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(1e6 + 2);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i <= 1e6 + 1; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j <= 1e6 + 2; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll n, m, k;
v<v<ll>> a(N, v<ll>(7));
v<ll> ans(7);
stack<pair<ll, ll>> in[7], out[7];
ll st, en, ST, EN, sum;

void empty_in()
{
    for (ll j = 1; j <= m; j++)
    {
        while (!in[j].empty())
        {
            auto temp = in[j].top();
            in[j].pop();
            if (out[j].empty())
                out[j].push({temp.se, temp.se});
            else
                out[j].push({max(out[j].top().fi, temp.se), temp.se});
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin >> n >> m >> k;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    ST = 1, EN = 0;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= m; j++)
        {
            in[j].push({max(!in[j].empty() ? in[j].top().fi : 0, a[i][j]), a[i][j]});
        }
        sum = 0;
        for (ll j = 1; j <= m; j++)
        {
            sum += max(in[j].top().fi, !out[j].empty() ? out[j].top().fi : 0);
        }
        EN++;
        if (sum <= k)
        {
            st = ST, en = EN;
        }
        else
        {
            empty_in();
            // cout << out[2].top().fi << " ";
            while (sum > k && ST <= EN)
            {
                sum = 0, ST++;
                for (ll j = 1; j <= m; j++)
                {
                    if (!out[j].empty())
                    {
                        out[j].pop();
                        sum += max((out[j].empty()) ? 0 : out[j].top().fi, (in[j].empty()) ? 0 : in[j].top().fi);
                    }
                }
            }
        }
    }
    // cout << st << " " << en << "\n";
    for (ll i = st; i <= en; i++)
    {
        for (ll j = 1; j <= m; j++)
        {
            ans[j] = max(ans[j], a[i][j]);
        }
    }
    for (ll j = 1; j <= m; j++)
        cout << ans[j] << " ";
    cout << "\n";
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 100005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(1e6 + 2);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i <= 1e6 + 1; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j <= 1e6 + 2; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll n, m, k;
v<v<ll>> a(N, v<ll>(7));
v<ll> ans(7);
stack<pair<ll, ll>> in[7], out[7];
ll st, en, ST, EN, sum;

void empty_in()
{
    pair<ll, ll> temp;
    while (!in[1].empty())
    {
        for (int i = 1; i <= m; i++)
        {
            temp = in[i].top();
            in[i].pop();

            if (out[i].empty())
                out[i].push(make_pair(temp.second, temp.second));
            else
                out[i].push(make_pair(max(out[i].top().first, temp.second), temp.second));
        }
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin >> n >> m >> k;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    ST = 1, EN = 0;
    ll mx = 0;
    for (ll i = 1; i <= n; i++)
    {
        sum = 0;
        for (ll j = 1; j <= m; j++)
        {
            in[j].push({max((!in[j].empty()) ? in[j].top().fi : 0LL, a[i][j]), a[i][j]});
        }
        for (ll j = 1; j <= m; j++)
        {
            sum += max(in[j].top().fi, (!out[j].empty()) ? out[j].top().fi : 0LL);
        }
        EN++;
        if (sum <= k && mx < EN - ST + 1)
        {
            st = ST, en = EN;
            mx = EN - ST + 1;
        }
        else
        {
            empty_in();
            while (sum > k && ST <= EN)
            {
                sum = 0, ST++;
                for (ll j = 1; j <= m; j++)
                {
                    out[j].pop();
                    sum += max((out[j].empty()) ? 0LL : out[j].top().fi, (in[j].empty()) ? 0LL : in[j].top().fi);
                }
            }
        }
    }
    for (ll i = st; i <= en; i++)
    {
        for (ll j = 1; j <= m; j++)
        {
            ans[j] = max(ans[j], a[i][j]);
        }
    }
    for (ll j = 1; j <= m; j++)
        cout << ans[j] << " ";
    cout << "\n";
}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int arr[100001][6];
int n, m, k;
unordered_map<int, int> counti[6];
set<int>maxi[6];
int ans[6];

bool IsDestroy(int l) {
	if (l > n) {return false;}

	//unordered_map<int, int>count[m + 1];
	for (int i = 1; i <= m; i++)counti[i].clear();
	for(int i=1;i<=m;i++)maxi[i].clear();

	for (int i = 1; i <= l; i++) {

		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			ans[j] = *itr;
		}
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {
			for (int j = 1; j <= m; j++) {
				auto itr = maxi[j].end();
				itr--;
				ans[j] = *itr;
			}
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans = -1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

int_fast32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}
	if (k == 0) {cout << "0"; return 0;}
	int ans1 = binaryserch();
	if (ans1 == -1) {
		for (int i = 1; i <= m; i++)cout << 0 << " ";
		return 0;
	}
	for (int i = 1; i <= m; i++) {
		cout << ans[i] << " ";
	}

}


#include<bits/stdc++.h>
using namespace std;
int arr[100001][6];
int n, m, k;
int count[6];
bool IsDestroy(int l) {
	if (l > n) {return false;}

	set<int>maxi[m + 1];
	unordered_map<int, int>count[m + 1];

	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			count[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			count[j][arr[be][j]]--;
			if (count[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			count[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

void print(int l) {
	set<int>maxi[m + 1];
	unordered_map<int, int>count[m + 1];

	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			count[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			cout << *itr << " ";
		}
		return ;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			count[j][arr[be][j]]--;
			if (count[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			count[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}
		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {

			for (int j = 1; j <= m; j++) {
				auto itr = maxi[j].end();
				itr--;
				cout << *itr << " ";
			}

			return ;
		}

	}
	return;

}

int main() {
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}
	int ans = binaryserch();
	print(ans);

}


#include<bits/stdc++.h>
#define pp pair<int,int>

using namespace std;
#define endl "\n"

int arr[100001][6];
int n, m, k;
//fuck this shit replace them with pq i hate set :(

/*unordered_map<int, int> counti[6];
set<int>maxi[6];*/

int ans[6];

bool IsDestroy(int l) {
	priority_queue<pair<int, int> >maxi[6];
	if (l > n) {return false;}

	for (int i = 1; i <= l; i++) {

		for (int j = 1; j <= m; j++) {
			maxi[j].push({arr[i][j], i});

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		pp val = maxi[j].top();

		req_shots += val.first;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {

			ans[j] = maxi[j].top().first;
		}
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {

		//for adding
		for (int j = 1; j <= m; j++) {
			maxi[j].push({arr[i][j], i});
		}

		//for checking
		long long int req_shots = 0;

		for (int j = 1; j <= m; j++) {
			while (maxi[j].top().second <= be) {
				maxi[j].pop();
			}
			req_shots += maxi[j].top().first;
		}
		if (req_shots <= k) {
			for (int j = 1; j <= m; j++) {
				ans[j] = maxi[j].top().first;
			}
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans = -1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

int_fast32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}
	if (k == 0) {cout << "0"; return 0;}
	int ans1 = binaryserch();
	if (ans1 == -1) {
		for (int i = 1; i <= m; i++)cout << 0 << " ";
		return 0;
	}
	for (int i = 1; i <= m; i++) {
		cout << ans[i] << " ";
	}

}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int arr[100001][6];
int n, m, k;
unordered_map<int,int> counti[6];
set<int>maxi[6];
bool IsDestroy(int l) {
	if (l > n) {return false;}

	//unordered_map<int, int>count[m + 1];
   for(int i=1;i<=m;i++){counti[i].clear();maxi[i].clear();};

	for (int i = 1; i <= l; i++) {

		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans=-1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

void print(int l) {
	//set<int>maxi[m + 1];
	for(int i=1;i<=m;i++){counti[i].clear();maxi[i].clear();}

	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			int a=*itr;
			//cout << *itr << " ";
			printf("%d ",&a );
		}
		return ;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}
		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {

			for (int j = 1; j <= m; j++) {
				auto itr = maxi[j].end();
				itr--;
				//cout << *itr << " ";
				int a=*itr;
				printf("%d ",&a);
			}

			return ;
		}

	}
	return;

}

signed main() {
	//ios_base::sync_with_stdio(false);cin.tie(NULL);

	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			 scanf("%d", &arr[i][j]);
		}
	}
	if(k==0){cout<<"0";return 0;}
	int ans = binaryserch();
	if(ans==-1){
		for(int i=1;i<=m;i++)cout<<0<<" ";
	return 0;
	}
	print(ans);

}


#include<bits/stdc++.h>
#define pp pair<int,int>

using namespace std;
#define endl "\n"

int arr[100001][6];
int n, m, k;
//fuck this shit replace them with pq i hate set :(

/*unordered_map<int, int> counti[6];
set<int>maxi[6];*/

priority_queue<pair<int, int> >maxi[6];
int ans[6];

bool IsDestroy(int l) {
	if (l > n) {return false;}

	for (int i = 1; i <= l; i++) {

		for (int j = 1; j <= m; j++) {
			maxi[j].push({arr[i][j], i});

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		pp val = maxi[j].top();

		req_shots += val.first;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {

			ans[j] = maxi[j].top().first;
		}
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {

			while (maxi[j].top().second <= be) {
				maxi[j].pop();}
		}
		//for adding
		for (int j = 1; j <= m; j++) {
			maxi[j].push({arr[i][j], i});		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			req_shots += maxi[j].top().first;		}
		if (req_shots <= k) {
			for (int j = 1; j <= m; j++) {
				ans[j] = maxi[j].top().first;
			}
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans = -1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

int_fast32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}
	if (k == 0) {cout << "0"; return 0;}
	int ans1 = binaryserch();
	if (ans1 == -1) {
		for (int i = 1; i <= m; i++)cout << 0 << " ";
		return 0;
	}
	for (int i = 1; i <= m; i++) {
		cout << ans[i] << " ";
	}

}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int arr[100001][6];
int n, m, k;
unordered_map<int,int> counti[6];
set<int>maxi[6];
bool IsDestroy(int l) {
	if (l > n) {return false;}

	//unordered_map<int, int>count[m + 1];
   for(int i=1;i<=m;i++){counti[i].clear();maxi[i].clear();};

	for (int i = 1; i <= l; i++) {

		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans=-1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

void print(int l) {
	//set<int>maxi[m + 1];
	for(int i=1;i<=m;i++){counti[i].clear();maxi[i].clear();}

	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			cout << *itr << " ";
		}
		return ;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}
		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {

			for (int j = 1; j <= m; j++) {
				auto itr = maxi[j].end();
				itr--;
				cout << *itr << " ";
			}

			return ;
		}

	}
	return;

}

int_fast32_t main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);

	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}
	if(k==0){cout<<"0";return 0;}
	int ans = binaryserch();
	if(ans==-1){
		for(int i=1;i<=m;i++)cout<<0<<" ";
	return 0;
	}
	print(ans);

}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int arr[100001][6];
int n, m, k;
unordered_map<int,int> counti[6];
set<int>maxi[6];
bool IsDestroy(int l) {
	if (l > n) {return false;}

	//unordered_map<int, int>count[m + 1];
   for(int i=1;i<=m;i++){counti[i].clear();maxi[i].clear();};

	for (int i = 1; i <= l; i++) {

		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans=-1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

void print(int l) {
	//set<int>maxi[m + 1];
	for(int i=1;i<=m;i++){counti[i].clear();maxi[i].clear();}

	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			//cout << *itr << " ";
			printf("%d ",&*itr );
		}
		return ;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}
		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {

			for (int j = 1; j <= m; j++) {
				auto itr = maxi[j].end();
				itr--;
				cout << *itr << " ";
			}

			return ;
		}

	}
	return;

}

int_fast32_t main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);

	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			 scanf("%d", &arr[i][j]);
		}
	}
	if(k==0){cout<<"0";return 0;}
	int ans = binaryserch();
	if(ans==-1){
		for(int i=1;i<=m;i++)cout<<0<<" ";
	return 0;
	}
	print(ans);

}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int arr[100001][6];
int n, m, k;
unordered_map<int,int> counti[6];
set<int>maxi[6];
bool IsDestroy(int l) {
	if (l > n) {return false;}

	//unordered_map<int, int>count[m + 1];
   for(int i=1;i<=m;i++){counti[i].clear();maxi[i].clear();};

	for (int i = 1; i <= l; i++) {

		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans=-1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

void print(int l) {
	//set<int>maxi[m + 1];
	for(int i=1;i<=m;i++){counti[i].clear();maxi[i].clear();}

	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			cout << *itr << " ";
		}
		return ;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}
		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {

			for (int j = 1; j <= m; j++) {
				auto itr = maxi[j].end();
				itr--;
				printf("%d ",*itr);

			}

			return ;
		}

	}
	return;

}

int_fast32_t main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);

	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			scanf("%d",&arr[i][j]);
		}
	}
	if(k==0){cout<<"0";return 0;}
	int ans = binaryserch();
	if(ans==-1){
		for(int i=1;i<=m;i++)cout<<0<<" ";
	return 0;
	}
	print(ans);

}


#include<bits/stdc++.h>
using namespace std;
int arr[100001][6];
int n, m, k;
int count[6];
bool IsDestroy(int l) {
	if (l > n) {return false;}

	set<int>maxi[m + 1];
	unordered_map<int, int>count[m + 1];

	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			count[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			count[j][arr[be][j]]--;
			if (count[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			count[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans=-1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

void print(int l) {
	set<int>maxi[m + 1];
	unordered_map<int, int>count[m + 1];

	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			count[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			cout << *itr << " ";
		}
		return ;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			count[j][arr[be][j]]--;
			if (count[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			count[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}
		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {

			for (int j = 1; j <= m; j++) {
				auto itr = maxi[j].end();
				itr--;
				cout << *itr << " ";
			}

			return ;
		}

	}
	return;

}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}
	if(k==0){cout<<"0";return 0;}
	int ans = binaryserch();
	if(ans==-1){
		for(int i=1;i<=m;i++)cout<<0<<" ";
	return 0;
	}
	print(ans);

}


#include<bits/stdc++.h>
using namespace std;
int arr[100001][6];
int n, m, k;
int count[6];
bool IsDestroy(int l) {
	if (l > n) {return false;}

	set<int>maxi[m + 1];
	unordered_map<int, int>count[m + 1];

	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			count[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			count[j][arr[be][j]]--;
			if (count[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			count[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

void print(int l) {
	set<int>maxi[m + 1];
	unordered_map<int, int>count[m + 1];

	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			count[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			cout << *itr << " ";
		}
		return ;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			count[j][arr[be][j]]--;
			if (count[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			count[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}
		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {

			for (int j = 1; j <= m; j++) {
				auto itr = maxi[j].end();
				itr--;
				cout << *itr << " ";
			}

			return ;
		}

	}
	return;

}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}
	if(k==0){cout<<"0";return 0;}
	int ans = binaryserch();
	print(ans);

}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int arr[100001][6];
int n, m, k;
//unordered_map<int, int> counti[6];

//set<int>maxi[6];
int ans[6];

bool IsDestroy(int l) {
	if (l > n) {return false;}
  priority_queue<pair<int, int> >pq[6];
	//unordered_map<int, int>count[m + 1];
	//for (int i = 1; i <= m; i++)counti[i].clear();
	//for (int i = 1; i <= m; i++)maxi[i].clear();

	for (int i = 1; i <= l; i++) {

		for (int j = 1; j <= m; j++) {
			pq[j].push({arr[i][j], i});
			//maxi[j].insert(arr[i][j]);
			//counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		//auto itr = maxi[j].end();
		//itr--;
		//req_shots += *itr;
		req_shots += pq[j].top().first;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {
			//auto itr = maxi[j].end();
			//itr--;
			//ans[j] = *itr;
			ans[j] = pq[j].top().first;
		}
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			//counti[j][arr[be][j]]--;
			//if (counti[j][arr[be][j]] == 0) {
			//maxi[j].erase(arr[be][j]);
			while (pq[j].top().second < i) {
				pq[j].pop();
			}
		}

		//for adding
		for (int j = 1; j <= m; j++) {
			//counti[j][arr[i][j]]++;
			//maxi[j].insert(arr[i][j]);
			pq[j].push({arr[i][j], i});
		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			//auto itr = maxi[j].end();
			//itr--;
			//req_shots += *itr;
			req_shots += pq[j].top().first;
		}
		if (req_shots <= k) {
			for (int j = 1; j <= m; j++) {
				//auto itr = maxi[j].end();
				//itr--;
				//ans[j] = *itr;
				ans[j] = pq[j].top().first;
			}
			return true;
		}
	}

	return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans = -1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

int_fast32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}
	if (k == 0) {cout << "0"; return 0;}
	int ans1 = binaryserch();
	if (ans1 == -1) {
		for (int i = 1; i <= m; i++)cout << 0 << " ";
		return 0;
	}
	for (int i = 1; i <= m; i++) {
		cout << ans[i] << " ";
	}

}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int arr[100001][6];
int n, m, k;
unordered_map<int, int> counti[6];
priority_queue<pair<int, int> >pq[6];
set<int>maxi[6];
int ans[6];

bool IsDestroy(int l) {
	if (l > n) {return false;}

	//unordered_map<int, int>count[m + 1];
	for (int i = 1; i <= m; i++)counti[i].clear();
	for (int i = 1; i <= m; i++)maxi[i].clear();

	for (int i = 1; i <= l; i++) {

		for (int j = 1; j <= m; j++) {
			pq[j].push({arr[i][j], i});
			//maxi[j].insert(arr[i][j]);
			//counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		//auto itr = maxi[j].end();
		//itr--;
		//req_shots += *itr;
		req_shots += pq[j].top().first;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {
			//auto itr = maxi[j].end();
			//itr--;
			//ans[j] = *itr;
			ans[j] = pq[j].top().first;
		}
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			//counti[j][arr[be][j]]--;
			//if (counti[j][arr[be][j]] == 0) {
			//maxi[j].erase(arr[be][j]);
			while (pq[j].top().second < i) {
				pq[j].pop();
			}
		}

		//for adding
		for (int j = 1; j <= m; j++) {
			//counti[j][arr[i][j]]++;
			//maxi[j].insert(arr[i][j]);
			pq[j].push({arr[i][j], i});
		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			//auto itr = maxi[j].end();
			//itr--;
			//req_shots += *itr;
			req_shots += pq[j].top().first;
		}
		if (req_shots <= k) {
			for (int j = 1; j <= m; j++) {
				//auto itr = maxi[j].end();
				//itr--;
				//ans[j] = *itr;
				ans[j] = pq[j].top().first;
			}
			return true;
		}
	}

	return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans = -1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

int_fast32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}
	if (k == 0) {cout << "0"; return 0;}
	int ans1 = binaryserch();
	if (ans1 == -1) {
		for (int i = 1; i <= m; i++)cout << 0 << " ";
		return 0;
	}
	for (int i = 1; i <= m; i++) {
		cout << ans[i] << " ";
	}

}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int arr[100001][6];
int n, m, k;
unordered_map<int,int> counti[6];
set<int>maxi[6];
bool IsDestroy(int l) {
	if (l > n) {return false;}

	//unordered_map<int, int>count[m + 1];
   for(int i=1;i<=m;i++){counti[i].clear();maxi[i].clear();};

	for (int i = 1; i <= l; i++) {

		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans=-1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

void print(int l) {
	//set<int>maxi[m + 1];
	for(int i=1;i<=m;i++){counti[i].clear();maxi[i].clear();}

	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			int a=*itr;
			//cout << *itr << " ";
			printf("%d ",&a );
		}
		return ;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}
		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {

			for (int j = 1; j <= m; j++) {
				auto itr = maxi[j].end();
				itr--;
				cout << *itr << " ";
			}

			return ;
		}

	}
	return;

}

int_fast32_t main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);

	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			 scanf("%d", &arr[i][j]);
		}
	}
	if(k==0){cout<<"0";return 0;}
	int ans = binaryserch();
	if(ans==-1){
		for(int i=1;i<=m;i++)cout<<0<<" ";
	return 0;
	}
	print(ans);

}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int arr[100001][6];
int n, m, k;
unordered_map<int,int> counti[6];

bool IsDestroy(int l) {
	if (l > n) {return false;}

	set<int>maxi[m + 1];
	//unordered_map<int, int>count[m + 1];
   for(int i=1;i<=m;i++)counti[i].clear();

	for (int i = 1; i <= l; i++) {

		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}

		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans=-1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

void print(int l) {
	set<int>maxi[m + 1];
	for(int i=1;i<=m;i++)counti[i].clear();

	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= m; j++) {
			maxi[j].insert(arr[i][j]);
			counti[j][arr[i][j]]++;

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		auto itr = maxi[j].end();
		itr--;
		req_shots += *itr;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			cout << *itr << " ";
		}
		return ;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {
		//for removing
		for (int j = 1; j <= m; j++) {
			counti[j][arr[be][j]]--;
			if (counti[j][arr[be][j]] == 0) {
				maxi[j].erase(arr[be][j]);
			}

		}
		//for adding
		for (int j = 1; j <= m; j++) {
			counti[j][arr[i][j]]++;
			maxi[j].insert(arr[i][j]);
		}
		//for checking
		long long int req_shots = 0;
		for (int j = 1; j <= m; j++) {
			auto itr = maxi[j].end();
			itr--;
			req_shots += *itr;
		}
		if (req_shots <= k) {

			for (int j = 1; j <= m; j++) {
				auto itr = maxi[j].end();
				itr--;
				cout << *itr << " ";
			}

			return ;
		}

	}
	return;

}

int_fast32_t main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);

	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}
	if(k==0){cout<<"0";return 0;}
	int ans = binaryserch();
	if(ans==-1){
		for(int i=1;i<=m;i++)cout<<0<<" ";
	return 0;
	}
	print(ans);

}


#include<bits/stdc++.h>
#define pp pair<int,int>

using namespace std;
#define endl "\n"

int arr[100001][6];
int n, m, k;
//fuck this shit replace them with pq i hate set :(

/*unordered_map<int, int> counti[6];
set<int>maxi[6];*/

priority_queue<pair<int, int> >maxi[6];
int ans[6];

bool IsDestroy(int l) {
	if (l > n) {return false;}

	for (int i = 1; i <= l; i++) {

		for (int j = 1; j <= m; j++) {
			maxi[j].push({arr[i][j], i});

		}

	}
	long long int req_shots = 0;
	for (int j = 1; j <= m; j++) {
		pp val = maxi[j].top();

		req_shots += val.first;
	}
	if (req_shots <= k) {
		for (int j = 1; j <= m; j++) {

			ans[j] = maxi[j].top().first;
		}
		return true;
	}
	int be = 1;
	int en = l;
	for (int i = en + 1; i <= n; i++, be++) {

		//for adding
		for (int j = 1; j <= m; j++) {
			maxi[j].push({arr[i][j], i});
		}

		//for checking
		long long int req_shots = 0;

		for (int j = 1; j <= m; j++) {
			while (maxi[j].top().second <= be) {
				maxi[j].pop();
			}
			req_shots += maxi[j].top().first;
		}
		if (req_shots <= k) {
			for (int j = 1; j <= m; j++) {
				ans[j] = maxi[j].top().first;
			}
			return true;
		}

	} return false;

}
int binaryserch() {
	int be = 1;
	int en = n;
	int ans = -1;
	while (be <= en) {
		int mid = be + (en - be) / 2;
		if (IsDestroy(mid)) {
			be = mid + 1;
			ans = mid;
		} else {
			en = mid - 1;

		}
	}
	return ans;
}

int_fast32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}
	if (k == 0) {cout << "0"; return 0;}
	int ans1 = binaryserch();
	if (ans1 == -1) {
		for (int i = 1; i <= m; i++)cout << 0 << " ";
		return 0;
	}
	for (int i = 1; i <= m; i++) {
		cout << ans[i] << " ";
	}

}


//RITIK RAI
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int  long long int
#define uint unsigned long long int
#define ld long double
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define preci(x, y) fixed << setprecision(y) << x

#define vint vector<int>
#define sz(a) (int)a.size()
#define pb push_back
#define vmin *min_element
#define vmax *max_element
#define max_pq priority_queue<ll, vector<ll>>
#define min_pq priority_queue<ll, vector<ll>, greater<ll>>
#define mint map<int,int>
#define pint pair<int,int>
#define mp make_pair
#define F first
#define S second

#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bin binary_search
#define revsort(v) sort(all(v), greater<ll>())

#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(i,a,b) for(int i=a;i>b;i--)

#define fbo find_by_order
#define ook order_of_key
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Set;

void ritikio();

#define PI 3.1415926535897932384626 // atan(1.0)*4.0;
const int inff = LLONG_MAX;
const int minff = LLONG_MIN;
const int inf = 1e18;
const int pmod = 998244353;
const int mod = 1e9 + 7;
const int maxm = 2e6 + 3;
const int maxN = 1e5 + 3;

#define print1(arr,a,b) for(int iji=a;iji<b;iji++) cout<<arr[iji]<<" "; cout<<endl
#define print(arr,a,b)  for(int iji=a;iji<b;i++) cout<<arr[iji]<<endl
#define print2d(dp,r,c) for(int iji=0;iji<r;iji++){for(int jij=0;jij<c;jij++) cout<<dp[iji][jij]<<" "; cout<<endl;}

void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<vint> v(n + 1, vint(m)), v2(n + 1, vint(m));
    vint v1;
    v1.pb(0);
    f(i, 1, n + 1)
    {
        int r = 0;
        f(j, 0, m)
        {
            int x;
            cin >> x;
            v[i][j] = max(x, v[i - 1][j]);
            v2[i][j] = x;
            r += v[i][j];
        }
        v1.pb(r);
    }
    //print1(v1,0,n+1);
    vint ans = {0, 0, 0};
    f(i, 1, n + 1)
    {
        int len = (lb(all(v1), v1[i] - k) - v1.begin() + 1);
        if(i - len > ans[0])
            ans[0] = i - len, ans[1] = len, ans[2] = i;
    }
    //print1(ans,0,3);
    f(j, 0, m)
    {
        int mx = 0;
        f(i, ans[1], ans[2]) mx = max(mx, v2[i][j]);
        cout << mx << " ";
    }
}

signed main()
{
    ritikio();

    // precompute();

    int T = 1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
}

void ritikio()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input999.txt", "r", stdin);
    freopen("output999.txt", "w", stdout);
#endif
}


//RITIK RAI
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int  long long int
#define uint unsigned long long int
#define ld long double
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define preci(x, y) fixed << setprecision(y) << x

#define vint vector<int>
#define sz(a) (int)a.size()
#define pb push_back
#define vmin *min_element
#define vmax *max_element
#define max_pq priority_queue<ll, vector<ll>>
#define min_pq priority_queue<ll, vector<ll>, greater<ll>>
#define mint map<int,int>
#define pint pair<int,int>
#define mp make_pair
#define F first
#define S second

#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bin binary_search
#define revsort(v) sort(all(v), greater<ll>())

#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(i,a,b) for(int i=a;i>b;i--)

#define fbo find_by_order
#define ook order_of_key
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Set;

void ritikio();

#define PI 3.1415926535897932384626 // atan(1.0)*4.0;
const int inff = LLONG_MAX;
const int minff = LLONG_MIN;
const int inf = 1e18;
const int pmod = 998244353;
const int mod = 1e9 + 7;
const int maxm = 2e6 + 3;
const int maxN = 1e5 + 3;

void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<vint> v(n + 1, vint(m));
    f(i, 0, n + 1) f(j, 0, m)
    {
        int x = inf;
        if(i != n) cin >> x;
        v[i][j] = x;
    }

    set<pint> st[m];
    f(j, 0, m) st[j].insert({0, inf});

    int s = 0, e = -1;
    vint ans(m + 1);
    while(s < n)
    {
        int r = 0;
        f(j, 0, m)
            r += max((*prev(st[j].end())).F, v[e + 1][j]);
        if(r <= k)
        {
            e++;
            f(j, 0, m)
                st[j].insert({v[e][j], e});
        }
        else
        {
            s++;
            f(j, 0, m)
            {
                while((*prev(st[j].end())).S < s)
                    st[j].erase(prev(st[j].end()));
            }
        }
        //cout<<r<<"...."<<s<<" "<<e<<endl;
        if(e - s + 1 > ans[m])
        {
            ans[m] = e - s + 1;
            f(j, 0, m)
                ans[j] = (*prev(st[j].end())).F;
        }
        if(e < s) e = s - 1;
    }
    f(j, 0, m) cout << ans[j] << " ";
}

signed main()
{
    ritikio();

    // precompute();

    int T = 1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
}

void ritikio()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input999.txt", "r", stdin);
    freopen("output999.txt", "w", stdout);
#endif
}


//RITIK RAI
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int  long long int
#define uint unsigned long long int
#define ld long double
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define preci(x, y) fixed << setprecision(y) << x

#define vint vector<int>
#define sz(a) (int)a.size()
#define pb push_back
#define vmin *min_element
#define vmax *max_element
#define max_pq priority_queue<ll, vector<ll>>
#define min_pq priority_queue<ll, vector<ll>, greater<ll>>
#define mint map<int,int>
#define pint pair<int,int>
#define mp make_pair
#define F first
#define S second

#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bin binary_search
#define revsort(v) sort(all(v), greater<ll>())

#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(i,a,b) for(int i=a;i>b;i--)

#define fbo find_by_order
#define ook order_of_key
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Set;

void ritikio();

#define PI 3.1415926535897932384626 // atan(1.0)*4.0;
const int inff = LLONG_MAX;
const int minff = LLONG_MIN;
const int inf = 1e18;
const int pmod = 998244353;
const int mod = 1e9 + 7;
const int maxm = 2e6 + 3;
const int maxN = 1e5 + 3;

void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<vint> v(n + 1, vint(m));
    f(i, 0, n + 1) f(j, 0, m)
    {
        int x = inf;
        if(i != n) cin >> x;
        v[i][j] = x;
    }

    set<pint> st[m];
    f(j, 0, m) st[j].insert({0, inf});

    int s = 0, e = -1;
    vint ans(m + 1);
    while(s < n)
    {
        int r = 0;
        f(j, 0, m)
        {
            auto it = prev(st[j].end());
            r += max((*it).F, v[e + 1][j]);
        }
        if(r <= k)
        {
            e++;
            f(j, 0, m) st[j].insert({v[e][j], e});
        }
        else
        {
            s++;
            f(j, 0, m)
            {
                while((*prev(st[j].end())).S < s)
                    st[j].erase(prev(st[j].end()));
            }
        }
        //cout<<r<<"...."<<s<<" "<<e<<endl;
        if(e - s + 1 > ans[m])
        {
            ans[m] = e - s + 1;
            f(j, 0, m) ans[j] = (*prev(st[j].end())).F;
        }
        if(e < s) e = s - 1;
    }
    f(j, 0, m) cout << ans[j] << " ";
}

signed main()
{
    ritikio();

    // precompute();

    int T = 1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
}

void ritikio()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input999.txt", "r", stdin);
    freopen("output999.txt", "w", stdout);
#endif
}


//RITIK RAI
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int  long long int
#define uint unsigned long long int
#define ld long double
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define preci(x, y) fixed << setprecision(y) << x

#define vint vector<int>
#define sz(a) (int)a.size()
#define pb push_back
#define vmin *min_element
#define vmax *max_element
#define max_pq priority_queue<ll, vector<ll>>
#define min_pq priority_queue<ll, vector<ll>, greater<ll>>
#define mint map<int,int>
#define pint pair<int,int>
#define mp make_pair
#define F first
#define S second

#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bin binary_search
#define revsort(v) sort(all(v), greater<ll>())

#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(i,a,b) for(int i=a;i>b;i--)

#define fbo find_by_order
#define ook order_of_key
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Set;

void ritikio();

#define PI 3.1415926535897932384626 // atan(1.0)*4.0;
const int inff = LLONG_MAX;
const int minff = LLONG_MIN;
const int inf = 1e18;
const int pmod = 998244353;
const int mod = 1e9 + 7;
const int maxm = 2e6 + 3;
const int maxN = 1e5 + 3;

void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<vint> v(n + 1, vint(m));
    f(i, 0, n + 1) f(j, 0, m)
    {
        int x = inf;
        if(i != n) cin >> x;
        v[i][j] = x;
    }

    set<pint> st[m];
    f(j, 0, m) st[j].insert({0, inf});

    int s = 0, e = -1;
    vint ans(m + 1);
    while(s < n)
    {
        int r = 0;
        f(j, 0, m)
            r += max((*prev(st[j].end())).F, v[e + 1][j]);
        if(r <= k)
        {
            e++;
            f(j, 0, m)
                st[j].insert({v[e][j], e});
        }
        else
        {
            s++;
            f(j, 0, m)
            {
                while((*prev(st[j].end())).S < s)
                    st[j].erase(prev(st[j].end()));
            }
        }
        if(e - s + 1 > ans[m])
        {
            ans[m] = e - s + 1;
            f(j, 0, m)
                ans[j] = (*prev(st[j].end())).F;
        }
    }
    f(j, 0, m) cout << ans[j] << " ";
}

signed main()
{
    ritikio();

    // precompute();

    int T = 1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
}

void ritikio()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input999.txt", "r", stdin);
    freopen("output999.txt", "w", stdout);
#endif
}


//RITIK RAI
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int  long long int
#define uint unsigned long long int
#define ld long double
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define preci(x, y) fixed << setprecision(y) << x

#define vint vector<int>
#define sz(a) (int)a.size()
#define pb push_back
#define vmin *min_element
#define vmax *max_element
#define max_pq priority_queue<ll, vector<ll>>
#define min_pq priority_queue<ll, vector<ll>, greater<ll>>
#define mint map<int,int>
#define pint pair<int,int>
#define mp make_pair
#define F first
#define S second

#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bin binary_search
#define revsort(v) sort(all(v), greater<ll>())

#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(i,a,b) for(int i=a;i>b;i--)

#define fbo find_by_order
#define ook order_of_key
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Set;

void ritikio();

#define PI 3.1415926535897932384626 // atan(1.0)*4.0;
const int inff = LLONG_MAX;
const int minff = LLONG_MIN;
const int inf = 1e18;
const int pmod = 998244353;
const int mod = 1e9 + 7;
const int maxm = 2e6 + 3;
const int maxN = 1e5 + 3;

void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<vint> v(n + 1, vint(m));
    f(i, 0, n + 1) f(j, 0, m)
    {
        int x = inf;
        if(i != n) cin >> x;
        v[i][j] = x;
    }

    set<pint> st[m];
    f(j, 0, m) st[j].insert({0, inf});

    int s = 0, e = -1;
    vint ans(m + 1);
    while(s < n)
    {
        int r = 0;
        f(j, 0, m)
            r += max((*prev(st[j].end())).F, v[e + 1][j]);
        if(r <= k)
        {
            e++;
            f(j, 0, m)
                st[j].insert({v[e][j], e});
        }
        else
        {
            s++;
            f(j, 0, m)
            {
                while((*prev(st[j].end())).S < s)
                    st[j].erase(prev(st[j].end()));
            }
        }
        if(e - s + 1 > ans[m])
        {
            ans[m] = e - s + 1;
            f(j, 0, m)
                ans[j] = (*prev(st[j].end())).F;
        }
        if(e < s) e = s - 1;
    }
    f(j, 0, m) cout << ans[j] << " ";
}

signed main()
{
    ritikio();

    // precompute();

    int T = 1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
}

void ritikio()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input999.txt", "r", stdin);
    freopen("output999.txt", "w", stdout);
#endif
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

priority_queue<ll> q[6], qans[6];
queue<ll> p;
vector<ll> vec[6];

int main() {
	ll n,m,k; cin>>n>>m>>k;
	for(ll i = 0; i < n; i++){
		for(ll j = 0; j < m; j++){
			ll x; cin>>x;
			vec[j].push_back(x);
		}
	}
	ll l = 0, r = -1, maxi = 0, maxl = -1, maxr = -1;
	p.push(0);
	for(ll ind = 0; ind < n; ind++){
		ll sum = 0;
		for(ll i = 0; i < m; i++){
			q[i].push(vec[i][ind]);
			sum += q[i].top();
			//cout<<q[i].top()<<" ";
		}
		//cout<<"\n";
		//cout<<sum<<" ";
		if(sum <= k){
			r = min(n-1, r+1);
		}else{
			while(sum > k){
				for(ll i = 0; i < m; i++){
					if(q[i].top() == vec[i][l]){sum -= q[i].top(); q[i].pop();}
				}
				l = min(n-1, l+1);
			}
			r = min(n-1, r+1);
		}
		//cout<<l<<" "<<r<<"\n";
		if(r - l + 1 > maxi){
			maxl = l; maxr = r; maxi = r - l + 1;
		}
		 //for(int i = 0; i < m; i++){
		 //	cout<<q[i].top()<<" ";
		 //}
		 //cout<<"\n";
	}
	if(maxl == -1 && maxr == -1){
		for(int i = 0; i < m; i++){
			cout<<0<<" ";
		}
		return 0;
	}
	for(int i = 0; i < m; i++){
		for(int j = maxl; j <= maxr; j++){
			qans[i].push(vec[i][j]);
		}
		cout<<qans[i].top()<<" ";
	}
	return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

priority_queue<ll> q[6], qans[6];
queue<ll> p;
vector<ll> vec[6];

int main() {
	ll n,m,k; cin>>n>>m>>k;
	for(ll i = 0; i < n; i++){
		for(ll j = 0; j < m; j++){
			ll x; cin>>x;
			vec[j].push_back(x);
		}
	}
	ll l = 0, r = -1, maxi = 0, maxl = -1, maxr = -1;
	p.push(0);
	for(ll ind = 0; ind < n; ind++){
		ll sum = 0;
		for(ll i = 0; i < m; i++){
			q[i].push(vec[i][ind]);
			sum += q[i].top();
			//cout<<q[i].top()<<" ";
		}
		//cout<<"\n";
		if(sum <= k){
			r = min(n-1, r+1);
		}else{
			while(sum > k){
				for(ll i = 0; i < m; i++){
					if(q[i].top() == vec[i][l]){sum -= q[i].top(); q[i].pop();}
				}
				l = min(n-1, l+1);
			}
		}
		if(r - l + 1 > maxi){
			maxl = l; maxr = r; maxi = r - l + 1;
		}
		 //cout<<sum<<" "<<l<<" "<<r<<"\n";
	}
	if(maxl == -1 && maxr == -1){
		for(int i = 0; i < m; i++){
			cout<<0<<" ";
		}
		return 0;
	}
	for(int i = 0; i < m; i++){
		for(int j = maxl; j <= maxr; j++){
			qans[i].push(vec[i][j]);
		}
		cout<<qans[i].top()<<" ";
	}
	return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

priority_queue<ll> q[6], qans[6];
queue<ll> p;
vector<ll> vec[6];

int main() {
	ll n,m,k; cin>>n>>m>>k;
	for(ll i = 0; i < n; i++){
		for(ll j = 0; j < m; j++){
			ll x; cin>>x;
			vec[j].push_back(x);
		}
	}
	ll l = 0, r = -1, maxi = 0, maxl = -1, maxr = -1;
	p.push(0);
	for(ll ind = 0; ind < n; ind++){
		ll sum = 0;
		for(ll i = 0; i < m; i++){
			q[i].push(vec[i][ind]);
			sum += q[i].top();
			//cout<<q[i].top()<<" ";
		}
		//cout<<"\n";
		if(sum <= k){
			r = min(n-1, r+1);
		}else{
			while(sum > k){
				for(ll i = 0; i < m; i++){
					if(q[i].top() == vec[i][l]){sum -= q[i].top(); q[i].pop();}
				}
				l = min(n-1, l+1);
			}
		}
		if(r - l + 1 > maxi){
			maxl = l; maxr = r; maxi = r - l + 1;
		}
		 //cout<<sum<<" "<<l<<" "<<r<<"\n";
	}
	for(int i = 0; i < m; i++){
		for(int j = maxl; j <= maxr; j++){
			qans[i].push(vec[i][j]);
		}
		cout<<qans[i].top()<<" ";
	}
	return 0;
}


#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

vector<ll> vec[6];

int main() {
	ll n,m,k; cin>>n>>m>>k;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			ll x; cin>>x;
			vec[j].push_back(x);
		}
	}
	int ans = -1;
	for(int i = 0; i < m; i++){sort(vec[i].begin(), vec[i].end());}
	// for(int i = 0; i < m; i++){
	// 	for(int j = 0; j < n; j++){
	// 		cout<<vec[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	for(int i = n-1; i >= 0; i--){
		int cnt = 0;
		for(int j = 0; j < m; j++){
			cnt += vec[j][i];
		}
		if(cnt <= k){
			ans = i; break;
		}
	}
	if(ans == -1){
		for(int i = 0; i < m; i++){
			cout<<0<<' ';
		}
	}else{
		for(int i = 0; i < m; i++){
			cout<<vec[i][ans]<<" ";
		}
	}
	return 0;
}