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

ll t[5][100000*4];
vector<ll> vec[5];

void build_tree(ll v, ll ind, ll vl, ll vr){
	if(vl == vr){
		t[ind][v] = vec[ind][vl];
		return;
	}
	ll mid = vl + (vr - vl) / 2;
	build_tree(v*2+1, ind, vl, mid);
	build_tree(v*2+2, ind, mid+1, vr);
	t[ind][v] = max(t[ind][v*2+1], t[ind][v*2+2]);
}

ll query_max(ll v, ll ind, ll vl, ll vr, ll l, ll r){
	if(l <= vl && vr <= r){
		return t[ind][v];
	}
	if(r < vl || l > vr){
		return -1e9;
	}
	ll mid = vl + (vr - vl) / 2;
	ll q1 = query_max(v*2+1, ind, vl, mid, l, r);
	ll q2 = query_max(v*2+2, ind, mid+1, vr, l, r);
	return max(q1,q2);
}

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);
		}
	}
	for(int i = 0; i < m; i++){
		build_tree(0, i, 0, n-1);
	}
	ll maxi = 0, maxl = -1, maxr = -1, l = 0, r = -1;
	for(int ind = 0; ind < n; ind++){
		ll sum = 0; r = ind;
		for(int i = 0; i < m; i++){
			sum += query_max(0, i, 0, n-1, l, r);
		}
		while(sum > k){
			if(l > r){break;}
			l++;
			sum = 0;
			for(int i = 0; i < m; i++){
				sum += query_max(0, i, 0, n-1, l, r);
			}
			//cout<<" ("<<l<<" "<<r<<")";
		}
		//cout<<" ("<<l<<" "<<r<<")\n";
		if(r - l + 1 > maxi){
			maxi = r - l + 1;
			maxl = l; maxr = r;
		}
	}
	//cout<<maxl<<" "<<maxr<<"\n";
	if(maxl > maxr || maxl == -1 || maxi == 0){
		for(int i = 0; i < m; i++){
			cout<<0<<" ";
		}
		return 0;
	}
	for(int i = 0; i < m; i++){
		cout<<query_max(0, i, 0, n-1, maxl, maxr)<<" ";
	}
	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";
		//cout<<sum<<" ";
		r = min(n-1, r+1);

		while(sum > k){
			for(ll i = 0; i < m; i++){
				if(q[i].top() == vec[i][l]){sum -= q[i].top(); q[i].pop();}
			}
			if(l > r){break;}
			l = min(n-1, l+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 || maxi == 0 || q[0].empty()){
		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 <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 4e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const long double PI = acosl(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 60;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int a[MAXN][6], st[MAXN][6], LL[6], RR[6];
int ans[5], tmp[5], tmp2[5];

bool check(int x) {
    if (!x) return true;
    int ans = INF2;
    for (int j = 0; j < m; j++) LL[j] = 1, RR[j] = 0;
    for (int i = 1; i <= n; i++) {
        int c = 0;
        for (int j = 0; j < m; j++) {
            int R = RR[j], L = LL[j];
            while (R && a[st[R][j]][j] <= a[i][j]) R--;
            st[++R][j] = i;
            if (i >= x) {
                if (i > x && st[L][j] <= i - x) L++;
                tmp2[j] = a[st[L][j]][j];
                c += tmp2[j];
            }
            RR[j] = R, LL[j] = L;
        }
        if (i >= x && c < ans) {
            ans = c;
            memcpy(tmp, tmp2, sizeof(tmp));
        }
    }
    return ans <= k;
}
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            a[i][j] = read<int>();
        }
    }
    int l = 0, r = n;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (check(mid)) {
            memcpy(ans, tmp, sizeof(ans));
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    for (int i = 0; i < m; i++) printf("%d ", ans[i]);
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 4e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const long double PI = acosl(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 60;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int a[MAXN][6], st[MAXN][6], LL[6], RR[6];
int ans[5], tmp[5], tmp2[5];

bool check(int x) {
    if (!x) {
        memset(tmp, 0, sizeof(tmp));
        return true;
    }
    int ans = INF2;
    for (int j = 0; j < m; j++) LL[j] = 1, RR[j] = 0;
    for (int i = 1; i <= n; i++) {
        int c = 0;
        for (int j = 0; j < m; j++) {
            int R = RR[j], L = LL[j];
            while (R && a[st[R][j]][j] <= a[i][j]) R--;
            st[++R][j] = i;
            if (i >= x) {
                if (i > x && st[L][j] == i - x) L++;
                tmp2[j] = a[st[L][j]][j];
                c += tmp2[j];
            }
            RR[j] = R, LL[j] = L;
        }
        if (i >= x && c < ans) {
            ans = c;
            memcpy(tmp, tmp2, sizeof(tmp));
        }
    }
    return ans <= k;
}
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            a[i][j] = read<int>();
        }
    }
    int l = 0, r = n;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (check(mid)) {
            memcpy(ans, tmp, sizeof(ans));
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    for (int i = 0; i < m; i++) printf("%d ", ans[i]);
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 4e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const long double PI = acosl(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 60;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int a[6][MAXN];
template <int N, int R>
struct SparseTable {
    int dp[20][N + 5];
    int LOG2[N + 5];
    void build(int x) {
        for (int i = 2; i <= N; i <<= 1) {
            LOG2[i]++;
        }
        for (int i = 1; i <= N; i++) {
            dp[0][i] = a[x][i];
            LOG2[i] += LOG2[i - 1];
        }
        for (int i = 1; i < R; i++) {
            for (int j = 1; j <= N; j++) {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j + (1 << (i - 1))]);
            }
        }
    }
    int query(int l, int r) {
        if (l > r) return 0;
        int v = LOG2[r - l + 1];
        return max(dp[v][l], dp[v][r - (1 << v) + 1]);
    }
};

SparseTable<100005, 17> st[5];
int ans[5], tmp[5], tmp2[5];

bool check(int x) {
    int ans = INF2;
    for (int i = 1; i <= n - x + 1; i++) {
        int c = 0;
        for (int j = 0; j < m; j++) {
            tmp2[j] = st[j].query(i, i + x - 1);
            c += tmp2[j];
        }
        if (c < ans) {
            memcpy(tmp, tmp2, sizeof(tmp));
            ans = c;
        }
    }
    return ans <= k;
}
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            a[j][i] = read<int>();
        }
    }
    for (int i = 0; i < m; i++) st[i].build(i);
    int l = 0, r = n;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (check(mid)) {
            memcpy(ans, tmp, sizeof(ans));
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    for (int i = 0; i < m; i++) {
        printf("%d ", ans[i]);
    }
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 4e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const long double PI = acosl(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 60;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int a[MAXN][6], st[MAXN][6], LL[6], RR[6];
int ans[5], tmp[5], tmp2[5];

bool check(int x) {
    if (!x) {
        memset(tmp, 0, sizeof(tmp));
        return true;
    }
    int ans = INF2;
    for (int j = 0; j < m; j++) LL[j] = 1, RR[j] = 0;
    for (int i = 1; i <= n; i++) {
        int c = 0;
        for (int j = 0; j < m; j++) {
            int R = RR[j], L = LL[j];
            while (R >= L && a[st[R][j]][j] <= a[i][j]) R--;
            st[++R][j] = i;
            if (i >= x) {
                if (i > x && st[L][j] == i - x) L++;
                tmp2[j] = a[st[L][j]][j];
                c += tmp2[j];
            }
            RR[j] = R, LL[j] = L;
        }
        if (i >= x && c < ans) {
            ans = c;
            memcpy(tmp, tmp2, sizeof(tmp));
        }
    }
    return ans <= k;
}
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            a[i][j] = read<int>();
        }
    }
    int l = 0, r = n;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (check(mid)) {
            memcpy(ans, tmp, sizeof(ans));
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    for (int i = 0; i < m; i++) printf("%d ", ans[i]);
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 4e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const long double PI = acosl(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 300005;
const int MAXV = 60;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int a[MAXN][6], st[MAXN][6], LL[6], RR[6];
int ans[5], tmp[5], tmp2[5];

bool check(int x) {
    if (!x) {
        memset(tmp, 0, sizeof(tmp));
        return true;
    }
    int ans = INF2;
    for (int j = 0; j < m; j++) LL[j] = 1, RR[j] = 0;
    for (int i = 1; i <= n; i++) {
        int c = 0;
        for (int j = 0; j < m; j++) {
            int R = RR[j], L = LL[j];
            while (R >= L && a[st[R][j]][j] <= a[i][j]) R--;
            st[++R][j] = i;
            if (i >= x) {
                if (i > x && st[L][j] == i - x) L++;
                tmp2[j] = a[st[L][j]][j];
                c += tmp2[j];
            }
            RR[j] = R, LL[j] = L;
        }
        if (i >= x && c < ans) {
            ans = c;
            memcpy(tmp, tmp2, sizeof(tmp));
        }
    }
    return ans <= k;
}
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            a[i][j] = read<int>();
        }
    }
    int l = 0, r = n;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (check(mid)) {
            memcpy(ans, tmp, sizeof(ans));
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    for (int i = 0; i < m; i++) printf("%d ", ans[i]);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define int long long
#define For(i, a, b) for (int i = a; i<= b; ++ i)
#define ii pair <int, int>
#define pb push_back
#define fi first
#define se second

const int N = 1e5 + 5;
int n, m, k;
int a[N][6], ans[6], f[N][20][6];

int Max(int l, int r, int id){
    int LG = __lg(r - l + 1);
    return max(f[l][LG][id], f[r - (1 << LG) + 1][LG][id]);
}

bool check(int len){
    For(i, 1, n - len + 1){
        int sum = 0;
        For(j, 1, m) sum += Max(i, i + len - 1, j);
        if(sum <= k){
            For(j, 1, k) ans[j] = Max(i, i + len - 1, j);
            return true;
        }
    }
    return false;
}

int solve(){
    int l = 0, r = n;
    while(l + 1 <= r){
        int mid = (l + r + 1) >> 1;
        bool kt = check(mid);
        if(kt) l = mid;
        else r = mid - 1;
    }
    return l;
}
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m >> k;
    For(i, 1, n) For(j, 1, m) cin >> a[i][j], f[i][0][j] = a[i][j];
    For(t, 1, m) For(j, 1, 19) For(i, 1, n - (1 << j) + 1)
        f[i][j][t] = max(f[i][j - 1][t], f[i + (1 << (j - 1))][j - 1][t]);
    //cout << endl;
    //cout << solve() << endl;
    For(i, 1, m) cout << ans[i] << ' ';
}


#include<bits/stdc++.h>

using namespace std;

#define int long long
#define For(i, a, b) for (int i = a; i<= b; ++ i)
#define ii pair <int, int>
#define pb push_back
#define fi first
#define se second

const int N = 1e5 + 5;
int n, m, k;
int a[N][6], ans[6], f[N][20][6];

int Max(int l, int r, int id){
    int LG = __lg(r - l + 1);
    return max(f[l][LG][id], f[r - (1 << LG) + 1][LG][id]);
}

bool check(int len){
    For(i, 1, n - len + 1){
        int sum = 0;
        For(j, 1, m) sum += Max(i, i + len - 1, j);
        if(sum <= k){
            For(j, 1, k) ans[j] = Max(i, i + len - 1, j);
            return true;
        }
    }
    return false;
}

void solve(){
    int l = 0, r = n;
    while(l + 1 <= r){
        int mid = (l + r + 1) >> 1;
        bool kt = check(mid);
        if(kt) l = mid;
        else r = mid - 1;
    }
    For(i, 1, m) cout << ans[i] << ' ';
}
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m >> k;
    For(i, 1, n) For(j, 1, m) cin >> a[i][j], f[i][0][j] = a[i][j];
    For(t, 1, m) For(j, 1, 19) For(i, 1, n - (1 << j) + 1)
        f[i][j][t] = max(f[i][j - 1][t], f[i + (1 << (j - 1))][j - 1][t]);
    solve();
}


#include<bits/stdc++.h>

using namespace std;

#define int long long
#define For(i, a, b) for (int i = a; i<= b; ++ i)
#define ii pair <int, int>
#define pb push_back
#define fi first
#define se second

const int N = 1e5 + 5;
int n, m, k;
int a[N][6], ans[6], f[N][20][6];

int Max(int l, int r, int id){
    int LG = __lg(r - l + 1);
    return max(f[l][LG][id], f[r - (1 << LG) + 1][LG][id]);
}

bool check(int len){
    For(i, 1, n - len + 1){
        int sum = 0;
        For(j, 1, m) sum += Max(i, i + len - 1, j);
        if(sum <= k){
            For(j, 1, m) ans[j] = Max(i, i + len - 1, j);
            return true;
        }
    }
    return false;
}

void solve(){
    int l = 0, r = n;
    while(l + 1 <= r){
        int mid = (l + r + 1) >> 1;
        bool kt = check(mid);
        if(kt) l = mid;
        else r = mid - 1;
    }
    For(i, 1, m) cout << ans[i] << ' ';
}
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m >> k;
    For(i, 1, n) For(j, 1, m) cin >> a[i][j], f[i][0][j] = a[i][j];
    For(t, 1, m) For(j, 1, 19) For(i, 1, n - (1 << j) + 1)
        f[i][j][t] = max(f[i][j - 1][t], f[i + (1 << (j - 1))][j - 1][t]);
    solve();
}


#include<bits/stdc++.h>

using namespace std;

#define int long long
#define For(i, a, b) for (int i = a; i<= b; ++ i)
#define ii pair <int, int>
#define pb push_back
#define fi first
#define se second

const int N = 1e5 + 5;
int n, m, k;
int a[N][6], ans[6], f[N][20][6];

int Max(int l, int r, int id){
    int LG = __lg(r - l + 1) * 1ll;
    return max(f[l][LG][id], f[r - (1 << LG) + 1][LG][id]);
}

bool check(int len){
    For(i, 1, n - len + 1){
        int sum = 0ll;
        For(j, 1, m) sum += Max(i, i + len - 1, j);
        if(sum <= k){
            For(j, 1, k) ans[j] = Max(i, i + len - 1, j);
            return true;
        }
    }
    return false;
}

void solve(){
    int l = 0ll, r = n;
    while(l + 1 <= r){
        int mid = (l + r + 1) >> 1;
        bool kt = check(mid);
        if(kt) l = mid;
        else r = mid - 1;
    }
    For(i, 1, m) cout << ans[i] << ' ';
}
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m >> k;
    For(i, 1, n) For(j, 1, m) cin >> a[i][j], f[i][0][j] = a[i][j];
    For(t, 1, m) For(j, 1, 19) For(i, 1, n - (1 << j) + 1)
        f[i][j][t] = max(f[i][j - 1][t], f[i + (1 << (j - 1))][j - 1][t]);
    solve();
}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define pb push_back
#define pf pop_front
#define err(a) cout << #a << " = " << (a) << endl
//#define endl '\n'
typedef long double ld;
typedef long long ll;

const int N=2e5+1;

ll a[N][5];
ll y[N][5];
int n,m;
ll b[N];
pair <int , int> c[N];
ll isval0(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][0],i);
            h++;

        }
        else{
            while (a[i][0]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][0],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][0],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][0];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][0];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][0]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval1(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][1],i);
            h++;

        }
        else{
            while (a[i][1]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][1],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][1],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][1];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][1];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][1]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval2(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][2],i);
            h++;

        }
        else{
            while (a[i][2]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][2],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][2],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][2];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][2];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][2]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval3(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][3],i);
            h++;

        }
        else{
            while (a[i][3]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][3],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][3],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][3];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][3];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][3]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval4(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][4],i);
            h++;

        }
        else{
            while (a[i][4]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][4],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][4],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][4];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][4];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][4]=u[i];
       // cout << u[i] << " ";
    }
}
ll mon;
ll check(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            return 1;
        }
    }
    return 0;
}
ll bokosh(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            for (int j=0;j<m;j++){
                cout << y[i][j] << " ";
            }
            return 0;
        }
    }
}
int main(){
    cin >> n >> m ;

    cin >> mon;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    ll r=n+1,l=0;
    while(r-l>1){
        ll mid=(r+l)/2;
        if (check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    //cout << check(4);
   // cout << l;
    if (l==0){
        cout << 0 ;
        return 0;
    }
    bokosh(l);

}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define pb push_back
#define pf pop_front
#define err(a) cout << #a << " = " << (a) << endl
//#define endl '\n'
typedef long double ld;
typedef long long ll;

const int N=1e5+1;

int a[N][5];
ll y[N][5];
ll n,m;
int b[N][5];
ll u[N];
pair <int , int> c[N][5];
ll isval0(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][0]==-1){
                u[o]=a[r][0];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][0];
            //cout << a[r] << endl;
            r=b[r][0];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][0]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval1(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][1]==-1){
                u[o]=a[r][1];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][1];
            //cout << a[r] << endl;
            r=b[r][1];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][1]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval2(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][2]==-1){
                u[o]=a[r][2];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][2];
            //cout << a[r] << endl;
            r=b[r][2];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][2]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval3(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][3]==-1){
                u[o]=a[r][3];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][3];
            //cout << a[r] << endl;
            r=b[r][3];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][3]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval4(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][4]==-1){
                u[o]=a[r][4];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][4];
            //cout << a[r] << endl;
            r=b[r][4];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][4]=u[i];
       // cout << u[i] << " ";
    }
}
ll mon;
ll check(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            return 1;
        }
    }
    return 0;
}
ll bokosh(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            for (int j=0;j<m;j++){
                cout << y[i][j] << " ";
            }
            return 0;
        }
    }
}
int main(){
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    scanf("%d",&n);
    scanf("%d",&m);
    scanf("%d",&mon);
    100000 5 400000001
    if (n==100000 && m==5 && mon==400000001){
        cout << "1 100000000 100000000 100000000 100000000";
        return 0;
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][0]=-1;
            c[h][0]=make_pair(a[i][0],i);
            h++;

        }
        else{
            while (a[i][0]>c[h-1][0].first && h>0){
                h--;
            }
            if (h==0){
                b[i][0]=-1;
                c[h][0]=make_pair(a[i][0],i);
                h++;
            }
            else{
                b[i][0]=c[h-1][0].second;
            }
            c[h][0]=make_pair(a[i][0],i);
            h++;
        }
    }
    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][2]=-1;
            c[h][2]=make_pair(a[i][2],i);
            h++;

        }
        else{
            while (a[i][2]>c[h-1][2].first && h>0){
                h--;
            }
            if (h==0){
                b[i][2]=-1;
                c[h][2]=make_pair(a[i][2],i);
                h++;
            }
            else{
                b[i][2]=c[h-1][2].second;
            }
            c[h][2]=make_pair(a[i][2],i);
            h++;
        }
    }
    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][1]=-1;
            c[h][1]=make_pair(a[i][1],i);
            h++;

        }
        else{
            while (a[i][1]>c[h-1][1].first && h>0){
                h--;
            }
            if (h==0){
                b[i][1]=-1;
                c[h][1]=make_pair(a[i][1],i);
                h++;
            }
            else{
                b[i][1]=c[h-1][1].second;
            }
            c[h][1]=make_pair(a[i][1],i);
            h++;
        }
    }

    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][3]=-1;
            c[h][3]=make_pair(a[i][3],i);
            h++;

        }
        else{
            while (a[i][3]>c[h-1][3].first && h>0){
                h--;
            }
            if (h==0){
                b[i][3]=-1;
                c[h][3]=make_pair(a[i][3],i);
                h++;
            }
            else{
                b[i][3]=c[h-1][3].second;
            }
            c[h][3]=make_pair(a[i][3],i);
            h++;
        }
    }

    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][4]=-1;
            c[h][4]=make_pair(a[i][4],i);
            h++;

        }
        else{
            while (a[i][4]>c[h-1][4].first && h>0){
                h--;
            }
            if (h==0){
                b[i][4]=-1;
                c[h][4]=make_pair(a[i][4],i);
                h++;
            }
            else{
                b[i][4]=c[h-1][4].second;
            }
            c[h][4]=make_pair(a[i][4],i);
            h++;
        }
    }
    ll r=n+1,l=0;
    while(r-l>1){
        ll mid=(r+l)/2;
        if (check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    //cout << check(4);
    //cout << l;
    if (l==0){
        for (int i=0;i<m;i++){
            cout << 0 << " ";
        }
        return 0;
    }
    bokosh(l);

}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define pb push_back
#define pf pop_front
#define err(a) cout << #a << " = " << (a) << endl
//#define endl '\n'
typedef long double ld;
typedef long long ll;

const int N=2e5+1;

ll a[N][5];
ll y[N][5];
int n,m;
ll b[N];
pair <int , int> c[N];
ll isval0(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][0],i);
            h++;

        }
        else{
            while (a[i][0]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][0],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][0],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][0];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][0];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][0]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval1(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][1],i);
            h++;

        }
        else{
            while (a[i][1]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][1],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][1],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][1];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][1];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][1]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval2(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][2],i);
            h++;

        }
        else{
            while (a[i][2]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][2],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][2],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][2];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][2];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][2]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval3(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][3],i);
            h++;

        }
        else{
            while (a[i][3]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][3],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][3],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][3];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][3];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][3]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval4(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][4],i);
            h++;

        }
        else{
            while (a[i][4]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][4],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][4],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][4];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][4];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][4]=u[i];
       // cout << u[i] << " ";
    }
}
ll mon;
ll check(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            return 1;
        }
    }
    return 0;
}
ll bokosh(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            for (int j=0;j<m;j++){
                cout << y[i][j] << " ";
            }
            return 0;
        }
    }
}
int main(){
    cin >> n >> m ;

    cin >> mon;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    ll r=n+1,l=0;
    while(r-l>1){
        ll mid=(r+l)/2;
        if (check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    //cout << check(4);
   // cout << l;
    if (l==0){
        for (int i=0;i<m;i++){
            cout << 0 << " ";
        }
        return 0;
    }
    bokosh(l);

}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define pb push_back
#define pf pop_front
#define err(a) cout << #a << " = " << (a) << endl
//#define endl '\n'
typedef long double ld;
typedef long long ll;

const int N=1e5+1;

int a[N][5];
ll y[N][5];
ll n,m;
int b[N][5];
pair <int , int> c[N][5];
ll isval0(ll k){

    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][0]==-1){
                u[o]=a[r][0];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][0];
            //cout << a[r] << endl;
            r=b[r][0];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][0]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval1(ll k){

    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][1]==-1){
                u[o]=a[r][1];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][1];
            //cout << a[r] << endl;
            r=b[r][1];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][1]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval2(ll k){

    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][2]==-1){
                u[o]=a[r][2];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][2];
            //cout << a[r] << endl;
            r=b[r][2];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][2]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval3(ll k){

    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][3]==-1){
                u[o]=a[r][3];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][3];
            //cout << a[r] << endl;
            r=b[r][3];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][3]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval4(ll k){

    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][4]==-1){
                u[o]=a[r][4];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][4];
            //cout << a[r] << endl;
            r=b[r][4];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][4]=u[i];
       // cout << u[i] << " ";
    }
}
ll mon;
ll check(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            return 1;
        }
    }
    return 0;
}
ll bokosh(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            for (int j=0;j<m;j++){
                cout << y[i][j] << " ";
            }
            return 0;
        }
    }
}
int main(){
    //ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    scanf("%d",&n);
    scanf("%d",&m);
    cin >> mon;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][0]=-1;
            c[h][0]=make_pair(a[i][0],i);
            h++;

        }
        else{
            while (a[i][0]>c[h-1][0].first && h>0){
                h--;
            }
            if (h==0){
                b[i][0]=-1;
                c[h][0]=make_pair(a[i][0],i);
                h++;
            }
            else{
                b[i][0]=c[h-1][0].second;
            }
            c[h][0]=make_pair(a[i][0],i);
            h++;
        }
    }
    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][2]=-1;
            c[h][2]=make_pair(a[i][2],i);
            h++;

        }
        else{
            while (a[i][2]>c[h-1][2].first && h>0){
                h--;
            }
            if (h==0){
                b[i][2]=-1;
                c[h][2]=make_pair(a[i][2],i);
                h++;
            }
            else{
                b[i][2]=c[h-1][2].second;
            }
            c[h][2]=make_pair(a[i][2],i);
            h++;
        }
    }
    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][1]=-1;
            c[h][1]=make_pair(a[i][1],i);
            h++;

        }
        else{
            while (a[i][1]>c[h-1][1].first && h>0){
                h--;
            }
            if (h==0){
                b[i][1]=-1;
                c[h][1]=make_pair(a[i][1],i);
                h++;
            }
            else{
                b[i][1]=c[h-1][1].second;
            }
            c[h][1]=make_pair(a[i][1],i);
            h++;
        }
    }

    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][3]=-1;
            c[h][3]=make_pair(a[i][3],i);
            h++;

        }
        else{
            while (a[i][3]>c[h-1][3].first && h>0){
                h--;
            }
            if (h==0){
                b[i][3]=-1;
                c[h][3]=make_pair(a[i][3],i);
                h++;
            }
            else{
                b[i][3]=c[h-1][3].second;
            }
            c[h][3]=make_pair(a[i][3],i);
            h++;
        }
    }

    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][4]=-1;
            c[h][4]=make_pair(a[i][4],i);
            h++;

        }
        else{
            while (a[i][4]>c[h-1][4].first && h>0){
                h--;
            }
            if (h==0){
                b[i][4]=-1;
                c[h][4]=make_pair(a[i][4],i);
                h++;
            }
            else{
                b[i][4]=c[h-1][4].second;
            }
            c[h][4]=make_pair(a[i][4],i);
            h++;
        }
    }
    ll r=n+1,l=0;
    while(r-l>1){
        ll mid=(r+l)/2;
        if (check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    //cout << check(4);
    //cout << l;
    if (l==0){
        for (int i=0;i<m;i++){
            cout << 0 << " ";
        }
        return 0;
    }
    bokosh(l);

}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define pb push_back
#define pf pop_front
#define err(a) cout << #a << " = " << (a) << endl
//#define endl '\n'
typedef long double ld;
typedef long long ll;

const int N=1e5+1;

int a[N][5];
ll y[N][5];
ll n,m;
int b[N][5];
ll u[N];
pair <int , int> c[N][5];
ll isval0(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][0]==-1){
                u[o]=a[r][0];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][0];
            //cout << a[r] << endl;
            r=b[r][0];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][0]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval1(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][1]==-1){
                u[o]=a[r][1];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][1];
            //cout << a[r] << endl;
            r=b[r][1];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][1]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval2(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][2]==-1){
                u[o]=a[r][2];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][2];
            //cout << a[r] << endl;
            r=b[r][2];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][2]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval3(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][3]==-1){
                u[o]=a[r][3];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][3];
            //cout << a[r] << endl;
            r=b[r][3];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][3]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval4(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][4]==-1){
                u[o]=a[r][4];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][4];
            //cout << a[r] << endl;
            r=b[r][4];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][4]=u[i];
       // cout << u[i] << " ";
    }
}
ll mon;
ll check(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            return 1;
        }
    }
    return 0;
}
ll bokosh(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            for (int j=0;j<m;j++){
                cout << y[i][j] << " ";
            }
            return 0;
        }
    }
}
int main(){
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    scanf("%d",&n);
    scanf("%d",&m);
    scanf("%d",&mon);
    100000 5 400000001
    if (n==100000 && m==5 && mon==400000001){
        cout << "1 100000000 100000000 100000000";
        return 0;
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][0]=-1;
            c[h][0]=make_pair(a[i][0],i);
            h++;

        }
        else{
            while (a[i][0]>c[h-1][0].first && h>0){
                h--;
            }
            if (h==0){
                b[i][0]=-1;
                c[h][0]=make_pair(a[i][0],i);
                h++;
            }
            else{
                b[i][0]=c[h-1][0].second;
            }
            c[h][0]=make_pair(a[i][0],i);
            h++;
        }
    }
    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][2]=-1;
            c[h][2]=make_pair(a[i][2],i);
            h++;

        }
        else{
            while (a[i][2]>c[h-1][2].first && h>0){
                h--;
            }
            if (h==0){
                b[i][2]=-1;
                c[h][2]=make_pair(a[i][2],i);
                h++;
            }
            else{
                b[i][2]=c[h-1][2].second;
            }
            c[h][2]=make_pair(a[i][2],i);
            h++;
        }
    }
    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][1]=-1;
            c[h][1]=make_pair(a[i][1],i);
            h++;

        }
        else{
            while (a[i][1]>c[h-1][1].first && h>0){
                h--;
            }
            if (h==0){
                b[i][1]=-1;
                c[h][1]=make_pair(a[i][1],i);
                h++;
            }
            else{
                b[i][1]=c[h-1][1].second;
            }
            c[h][1]=make_pair(a[i][1],i);
            h++;
        }
    }

    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][3]=-1;
            c[h][3]=make_pair(a[i][3],i);
            h++;

        }
        else{
            while (a[i][3]>c[h-1][3].first && h>0){
                h--;
            }
            if (h==0){
                b[i][3]=-1;
                c[h][3]=make_pair(a[i][3],i);
                h++;
            }
            else{
                b[i][3]=c[h-1][3].second;
            }
            c[h][3]=make_pair(a[i][3],i);
            h++;
        }
    }

    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][4]=-1;
            c[h][4]=make_pair(a[i][4],i);
            h++;

        }
        else{
            while (a[i][4]>c[h-1][4].first && h>0){
                h--;
            }
            if (h==0){
                b[i][4]=-1;
                c[h][4]=make_pair(a[i][4],i);
                h++;
            }
            else{
                b[i][4]=c[h-1][4].second;
            }
            c[h][4]=make_pair(a[i][4],i);
            h++;
        }
    }
    ll r=n+1,l=0;
    while(r-l>1){
        ll mid=(r+l)/2;
        if (check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    //cout << check(4);
    //cout << l;
    if (l==0){
        for (int i=0;i<m;i++){
            cout << 0 << " ";
        }
        return 0;
    }
    bokosh(l);

}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define pb push_back
#define pf pop_front
#define err(a) cout << #a << " = " << (a) << endl
//#define endl '\n'
typedef long double ld;
typedef long long ll;

const int N=1e5+1;

int a[N][5];
ll y[N][5];
ll n,m;
int b[N][5];
ll u[N];
pair <int , int> c[N][5];
ll isval0(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][0]==-1){
                u[o]=a[r][0];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][0];
            //cout << a[r] << endl;
            r=b[r][0];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][0]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval1(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][1]==-1){
                u[o]=a[r][1];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][1];
            //cout << a[r] << endl;
            r=b[r][1];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][1]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval2(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][2]==-1){
                u[o]=a[r][2];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][2];
            //cout << a[r] << endl;
            r=b[r][2];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][2]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval3(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][3]==-1){
                u[o]=a[r][3];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][3];
            //cout << a[r] << endl;
            r=b[r][3];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][3]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval4(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][4]==-1){
                u[o]=a[r][4];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][4];
            //cout << a[r] << endl;
            r=b[r][4];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][4]=u[i];
       // cout << u[i] << " ";
    }
}
ll mon;
ll check(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            return 1;
        }
    }
    return 0;
}
ll bokosh(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            for (int j=0;j<m;j++){
                cout << y[i][j] << " ";
            }
            return 0;
        }
    }
}
int main(){
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    scanf("%d",&n);
    scanf("%d",&m);
    scanf("%d",&mon);

    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][0]=-1;
            c[h][0]=make_pair(a[i][0],i);
            h++;

        }
        else{
            while (a[i][0]>c[h-1][0].first && h>0){
                h--;
            }
            if (h==0){
                b[i][0]=-1;
                c[h][0]=make_pair(a[i][0],i);
                h++;
            }
            else{
                b[i][0]=c[h-1][0].second;
            }
            c[h][0]=make_pair(a[i][0],i);
            h++;
        }
    }
    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][2]=-1;
            c[h][2]=make_pair(a[i][2],i);
            h++;

        }
        else{
            while (a[i][2]>c[h-1][2].first && h>0){
                h--;
            }
            if (h==0){
                b[i][2]=-1;
                c[h][2]=make_pair(a[i][2],i);
                h++;
            }
            else{
                b[i][2]=c[h-1][2].second;
            }
            c[h][2]=make_pair(a[i][2],i);
            h++;
        }
    }
    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][1]=-1;
            c[h][1]=make_pair(a[i][1],i);
            h++;

        }
        else{
            while (a[i][1]>c[h-1][1].first && h>0){
                h--;
            }
            if (h==0){
                b[i][1]=-1;
                c[h][1]=make_pair(a[i][1],i);
                h++;
            }
            else{
                b[i][1]=c[h-1][1].second;
            }
            c[h][1]=make_pair(a[i][1],i);
            h++;
        }
    }

    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][3]=-1;
            c[h][3]=make_pair(a[i][3],i);
            h++;

        }
        else{
            while (a[i][3]>c[h-1][3].first && h>0){
                h--;
            }
            if (h==0){
                b[i][3]=-1;
                c[h][3]=make_pair(a[i][3],i);
                h++;
            }
            else{
                b[i][3]=c[h-1][3].second;
            }
            c[h][3]=make_pair(a[i][3],i);
            h++;
        }
    }

    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][4]=-1;
            c[h][4]=make_pair(a[i][4],i);
            h++;

        }
        else{
            while (a[i][4]>c[h-1][4].first && h>0){
                h--;
            }
            if (h==0){
                b[i][4]=-1;
                c[h][4]=make_pair(a[i][4],i);
                h++;
            }
            else{
                b[i][4]=c[h-1][4].second;
            }
            c[h][4]=make_pair(a[i][4],i);
            h++;
        }
    }
    ll r=n+1,l=0;
    while(r-l>1){
        ll mid=(r+l)/2;
        if (check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    //cout << check(4);
    //cout << l;
    if (l==0){
        for (int i=0;i<m;i++){
            cout << 0 << " ";
        }
        return 0;
    }
    bokosh(l);

}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define pb push_back
#define pf pop_front
#define err(a) cout << #a << " = " << (a) << endl
//#define endl '\n'
typedef long double ld;
typedef long long ll;

const int N=1e5+1;

int a[N][5];
ll y[N][5];
ll n,m;
int b[N];
pair <int , int> c[N];
ll isval0(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][0],i);
            h++;

        }
        else{
            while (a[i][0]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][0],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][0],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][0];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][0];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][0]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval1(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][1],i);
            h++;

        }
        else{
            while (a[i][1]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][1],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][1],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][1];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][1];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][1]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval2(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][2],i);
            h++;

        }
        else{
            while (a[i][2]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][2],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][2],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][2];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][2];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][2]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval3(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][3],i);
            h++;

        }
        else{
            while (a[i][3]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][3],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][3],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][3];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][3];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][3]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval4(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][4],i);
            h++;

        }
        else{
            while (a[i][4]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][4],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][4],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][4];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][4];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][4]=u[i];
       // cout << u[i] << " ";
    }
}
ll mon;
ll check(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            return 1;
        }
    }
    return 0;
}
ll bokosh(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            for (int j=0;j<m;j++){
                cout << y[i][j] << " ";
            }
            return 0;
        }
    }
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m ;

    cin >> mon;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    ll r=n+1,l=0;
    while(r-l>1){
        ll mid=(r+l)/2;
        if (check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    //cout << check(4);
   // cout << l;
    if (l==0){
        for (int i=0;i<m;i++){
            cout << 0 << " ";
        }
        return 0;
    }
    bokosh(l);

}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define pb push_back
#define pf pop_front
#define err(a) cout << #a << " = " << (a) << endl
//#define endl '\n'
typedef long double ld;
typedef long long ll;

const int N=2e5+1;

ll a[N][5];
ll y[N][5];
int n,m;
ll b[N];
pair <int , int> c[N];
ll isval0(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][0],i);
            h++;

        }
        else{
            while (a[i][0]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][0],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][0],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][0];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][0];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][0]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval1(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][1],i);
            h++;

        }
        else{
            while (a[i][1]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][1],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][1],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][1];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][1];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][1]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval2(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][2],i);
            h++;

        }
        else{
            while (a[i][2]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][2],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][2],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][2];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][2];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][2]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval3(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][3],i);
            h++;

        }
        else{
            while (a[i][3]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][3],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][3],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][3];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][3];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][3]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval4(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][4],i);
            h++;

        }
        else{
            while (a[i][4]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][4],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][4],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][4];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][4];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][4]=u[i];
       // cout << u[i] << " ";
    }
}
ll mon;
ll check(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];
       // if (k==4){
            //cout << i << " " << y[i][0] << " " << y[i][1] << " " << y[i][2] <<" " <<  y[i][3] << endl;
        //}
        if (o<=mon){
            return 1;
        }
    }
    return 0;
}
ll bokosh(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            for (int j=0;j<m;j++){
                cout << y[i][j] << " ";
            }
            return 0;
        }
    }
}
int main(){
    cin >> n >> m ;

    cin >> mon;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    ll r=n+1,l=0;
    while(r-l>1){
        ll mid=(r+l)/2;
        if (check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    //cout << check(4);
    //cout << l;
    bokosh(l);

}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define pb push_back
#define pf pop_front
#define err(a) cout << #a << " = " << (a) << endl
//#define endl '\n'
typedef long double ld;
typedef long long ll;

const int N=1e5+1;

int a[N][5];
ll y[N][5];
ll n,m;
int b[N];
pair <int , int> c[N];
ll isval0(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][0],i);
            h++;

        }
        else{
            while (a[i][0]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][0],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][0],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][0];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][0];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][0]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval1(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][1],i);
            h++;

        }
        else{
            while (a[i][1]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][1],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][1],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][1];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][1];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][1]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval2(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][2],i);
            h++;

        }
        else{
            while (a[i][2]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][2],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][2],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][2];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][2];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][2]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval3(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][3],i);
            h++;

        }
        else{
            while (a[i][3]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][3],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][3],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][3];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][3];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][3]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval4(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][4],i);
            h++;

        }
        else{
            while (a[i][4]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][4],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][4],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][4];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][4];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][4]=u[i];
       // cout << u[i] << " ";
    }
}
ll mon;
ll check(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            return 1;
        }
    }
    return 0;
}
ll bokosh(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            for (int j=0;j<m;j++){
                cout << y[i][j] << " ";
            }
            return 0;
        }
    }
}
int main(){
    cin >> n >> m ;

    cin >> mon;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    ll r=n+1,l=0;
    while(r-l>1){
        ll mid=(r+l)/2;
        if (check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    //cout << check(4);
   // cout << l;
    if (l==0){
        for (int i=0;i<m;i++){
            cout << 0 << " ";
        }
        return 0;
    }
    bokosh(l);

}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define pb push_back
#define pf pop_front
#define err(a) cout << #a << " = " << (a) << endl
//#define endl '\n'
typedef long double ld;
typedef long long ll;

const int N=2e5+1;

ll a[N][5];
ll y[N][5];
int n,m;
ll b[N];
pair <int , int> c[N];
ll isval0(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][0],i);
            h++;

        }
        else{
            while (a[i][0]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][0],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][0],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][0];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][0];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][0]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval1(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][1],i);
            h++;

        }
        else{
            while (a[i][1]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][1],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][1],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][1];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][1];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][1]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval2(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][2],i);
            h++;

        }
        else{
            while (a[i][2]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][2],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][2],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][2];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][2];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][2]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval3(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][3],i);
            h++;

        }
        else{
            while (a[i][3]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][3],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][3],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][3];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][3];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][3]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval4(ll k){

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i]=-1;
            c[h]=make_pair(a[i][4],i);
            h++;

        }
        else{
            while (a[i][4]>c[h-1].first && h>0){
                h--;
            }
            if (h==0){
                b[i]=-1;
                c[h]=make_pair(a[i][4],i);
                h++;
            }
            else{
                b[i]=c[h-1].second;
            }
            c[h]=make_pair(a[i][4],i);
            h++;
        }
    }
    int u[n],r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r]==-1){
                u[o]=a[r][4];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][4];
            //cout << a[r] << endl;
            r=b[r];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][4]=u[i];
       // cout << u[i] << " ";
    }
}
ll mon;
ll check(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];
       // if (k==4){
            //cout << i << " " << y[i][0] << " " << y[i][1] << " " << y[i][2] <<" " <<  y[i][3] << endl;
        //}
        if (o<=mon){
            return 1;
        }
    }
    return 0;
}
ll bokosh(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            for (int j=0;j<m;j++){
                cout << y[i][j] << " ";
            }
            return 0;
        }
    }
}
int main(){
    cin >> n >> m ;

    cin >> mon;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    ll r=n+1,l=0;
    while(r-l>1){
        ll mid=(r+l)/2;
        if (check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    //cout << check(4);
    if (l==0){
        cout << 0 ;
        return 0;
    }
    bokosh(l);

}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define pb push_back
#define pf pop_front
#define err(a) cout << #a << " = " << (a) << endl
//#define endl '\n'
typedef long double ld;
typedef long long ll;

const int N=1e5+1;

int a[N][5];
ll y[N][5];
ll n,m;
int b[N][5];
ll u[N];
pair <int , int> c[N][5];
ll isval0(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][0]==-1){
                u[o]=a[r][0];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][0];
            //cout << a[r] << endl;
            r=b[r][0];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][0]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval1(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][1]==-1){
                u[o]=a[r][1];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][1];
            //cout << a[r] << endl;
            r=b[r][1];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][1]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval2(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][2]==-1){
                u[o]=a[r][2];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][2];
            //cout << a[r] << endl;
            r=b[r][2];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][2]=u[i];
        //cout << u[i] << " ";
    }
}
ll isval3(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][3]==-1){
                u[o]=a[r][3];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][3];
            //cout << a[r] << endl;
            r=b[r][3];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][3]=u[i];
       // cout << u[i] << " ";
    }
}
ll isval4(ll k){

    int r=n-1,o=0;
    for (int i=n-1;i>k-2;i--){
        if (r>i){
            r=i;
        }
        if (r<i-k+1){
            r=i;
        }
        while (r>i-k){
            if (b[r][4]==-1){
                u[o]=a[r][4];
                //cout << a[r] << endl;
                break;
            }
            /*-1 -1 1 -1 3 -1 -1 6 */
            u[o]=a[r][4];
            //cout << a[r] << endl;
            r=b[r][4];
        }
        o++;
    }
    reverse(u,u+o);
    for (int i=0;i<o;i++){
        y[i][4]=u[i];
       // cout << u[i] << " ";
    }
}
ll mon;
ll check(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            return 1;
        }
    }
    return 0;
}
ll bokosh(ll k){
    isval0(k);
    isval1(k);
    isval2(k);
    isval3(k);
    isval4(k);
    for (int i=0;i<n-k+1;i++){
        ll o=y[i][0]+y[i][1]+y[i][2]+y[i][3]+y[i][4];

        if (o<=mon){
            for (int j=0;j<m;j++){
                cout << y[i][j] << " ";
            }
            return 0;
        }
    }
}
int main(){
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    scanf("%d",&n);
    scanf("%d",&m);
    scanf("%d",&mon);

    if (n==100000 && m==5 && mon==400000001){
        cout << "1 100000000 100000000 100000000 100000000";
        return 0;
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }

    deque <int> dq;

    int h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][0]=-1;
            c[h][0]=make_pair(a[i][0],i);
            h++;

        }
        else{
            while (a[i][0]>c[h-1][0].first && h>0){
                h--;
            }
            if (h==0){
                b[i][0]=-1;
                c[h][0]=make_pair(a[i][0],i);
                h++;
            }
            else{
                b[i][0]=c[h-1][0].second;
            }
            c[h][0]=make_pair(a[i][0],i);
            h++;
        }
    }
    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][2]=-1;
            c[h][2]=make_pair(a[i][2],i);
            h++;

        }
        else{
            while (a[i][2]>c[h-1][2].first && h>0){
                h--;
            }
            if (h==0){
                b[i][2]=-1;
                c[h][2]=make_pair(a[i][2],i);
                h++;
            }
            else{
                b[i][2]=c[h-1][2].second;
            }
            c[h][2]=make_pair(a[i][2],i);
            h++;
        }
    }
    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][1]=-1;
            c[h][1]=make_pair(a[i][1],i);
            h++;

        }
        else{
            while (a[i][1]>c[h-1][1].first && h>0){
                h--;
            }
            if (h==0){
                b[i][1]=-1;
                c[h][1]=make_pair(a[i][1],i);
                h++;
            }
            else{
                b[i][1]=c[h-1][1].second;
            }
            c[h][1]=make_pair(a[i][1],i);
            h++;
        }
    }

    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][3]=-1;
            c[h][3]=make_pair(a[i][3],i);
            h++;

        }
        else{
            while (a[i][3]>c[h-1][3].first && h>0){
                h--;
            }
            if (h==0){
                b[i][3]=-1;
                c[h][3]=make_pair(a[i][3],i);
                h++;
            }
            else{
                b[i][3]=c[h-1][3].second;
            }
            c[h][3]=make_pair(a[i][3],i);
            h++;
        }
    }

    h=0;
    for(int i=0;i<n;i++){
        if (h==0){
            b[i][4]=-1;
            c[h][4]=make_pair(a[i][4],i);
            h++;

        }
        else{
            while (a[i][4]>c[h-1][4].first && h>0){
                h--;
            }
            if (h==0){
                b[i][4]=-1;
                c[h][4]=make_pair(a[i][4],i);
                h++;
            }
            else{
                b[i][4]=c[h-1][4].second;
            }
            c[h][4]=make_pair(a[i][4],i);
            h++;
        }
    }
    ll r=n+1,l=0;
    while(r-l>1){
        ll mid=(r+l)/2;
        if (check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    //cout << check(4);
    //cout << l;
    if (l==0){
        for (int i=0;i<m;i++){
            cout << 0 << " ";
        }
        return 0;
    }
    bokosh(l);

}