1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
#include <bits/stdc++.h>

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
#include <climits>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <cassert>

#define ALL(v) v.begin(), v.end()
#define REP(i, a, b) for (int i = a; i < b; i++)
#define REPD(i, a, b) for (int i = a; i > b; i--)
#define REPLL(i, a, b) for (ll i = a; i < b; i++)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define FORD(i, a, b) for (int i = a; i >= b; i--)
#define FORLL(i, a, b) for (ll i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef long double ld;

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef pair<ld, ld> pld;

#define remax(a, b) a = max(a, b)
#define remin(a, b) a = min(a, b)

#define popcount __builtin_popcount
#define pb push_back
#define mp make_pair
#define st first
#define y first
#define nd second
#define x second

#define eps 1e-9
#define pi acos(-1.0)

#ifdef LOCAL
#define ASSERT(x) assert(x)
#else
#define cerr if(0)cout
#define ASSERT(x) ;
#endif

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class T> ostream &operator<<(ostream& os, set<T> V) {
  os << "{"; for (auto vv : V) os << vv << ","; return os << "}";
}

const int inf = 1e9 + 1;

const int N = 2004;

int z, n, k;
int need[N][N];

int get(int i, int j) {
	if(i == 0 && j == 0) return 1;
	if(i == 1 && j == 0) return 2;
	if(i == 1 && j == 1) return 2;
	if(i >= 0 && j >= 0 && j <= i) {
		if(need[i][j]) return need[i][j];
		need[i][j] = get(i-1, j-1) + get(i-1, j) - get(i-2, j-1) + 1; 
		return need[i][j];
	}
	return 0;
}

int main() {
  ios_base::sync_with_stdio(0);

  cin >> n >> k;
  int res = inf;
  REP(i, 0, n) {
  	FOR(j, 0, i) {
  		int t; cin >> t;
  		if(get(i, j) <= k) {
  			remin(res, t);
  		}
  	}
  }
  cout << res << endl;
  return 0;
}