//#pragma GCC optimize ("O3","unroll-loops")
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cassert>

#include<cmath>
#include<functional>
#include<algorithm>
#include<numeric>

#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<tuple>

#define TEST {IS_TEST=true;}
#define fi first
#define se second
#define pb(x) emplace_back(x)
#define pf(x) emplace_front(x)
#define emp(x) emplace(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll = int_fast64_t;
using v_b = vector <bool>; using v_ll = vector <ll>; using str = string; using v_str = vector <string>; using p_ll = pair < ll,ll >;
using vv_b = vector < v_b >; using vv_ll = vector < v_ll >; using vp_ll = vector < p_ll >;
using vvv_ll = vector < vv_ll >; using vvp_ll = vector < vp_ll >;
using ld = long double; using v_ld = vector <ld>; using vv_ld = vector<v_ld>;

bool IS_TEST=false;
ll ll_min64=1LL<<63;
ll ll_max64=~ll_min64;
ll ll_min32=1LL<<31;
ll ll_max32=~ll_min32;

/*displaying functions for debug*/
template<class T> void show2(const T &x){cerr << x;}
template<class T1,class T2> void show2(const pair<T1,T2> &x){
  cerr << "{" << show2(x.first) << "," << show2(x.second) << "}";
}
template<class T> void show(const T &x){
  if (!IS_TEST) return; show2(x); cerr << "\n";
}
template<class T> void v_show(const T &v, ll n=-1){
  if (!IS_TEST) return; auto itr=v.begin(); ll m=n;
  while(itr!=v.end() && m!=0 ){ show2(*itr); cerr << " "; itr++; m--;}
  cerr << "\n";
}
template<class T> void vv_show(const T &v, ll n=-1){
  if (!IS_TEST) return;
  cerr << "--------------------------------\n";
  auto itr=v.begin(); ll m=n;
  while(itr!=v.end() && m!=0 ){ v_show(*itr,n); itr++; m--;}
  cerr << "--------------------------------\n";
}

ll max(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y){return x<y?x:y;}
template<class T> bool chmax(T& x,const T& y){ if (x>=y) return false; x=y; return true;}
template<class T> bool chmin(T& x,const T& y){ if (x<=y) return false; x=y; return true;}
template<class T> void quit(T x){cout << x << endl; exit(0);}

ll roundup(ll x,ll y){return (x-1)/y+1;}
ll remain(ll x,ll y){ ll z=x%y; return z>=0?z:z+y; }

v_ll idx_vector(ll n){
  v_ll ret(n,0);
  for(ll i=0;i<n;i++) ret[i]=i;
  return ret;
}

//setprecision(12)
//sort(##.begin(),##.end(),[&](auto &x, auto &y){if (x<y) return true;});
//ll ok=0,ng=0; while(abs(ok-ng)>1){ll mid=(ok+ng)/2; ( func(mid) ?ok:ng)=mid;}

// struct dat{
//     dat(){}
//     bool operator < (const dat& rhs)const {return false; }
// };
string el = "\n";
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll A,B;
  cin >> A>> B;
  if (A>=B){
    ll sum = 0;
    for(ll i=0;i<A;i++){
      cout << (i+1) << " ";
      sum+=(i+1);
    }
    for(ll i=0;i<B-1;i++){
      cout << (-i-1) << " ";
      sum-=(i+1);
    }
    cout << (-sum) << "\n";
  }else{
    ll sum = 0;
    for(ll i=0;i<A-1;i++){
      cout << (i+1) << " ";
      sum+=(i+1);
    }
    for(ll i=0;i<B;i++){
      cout << (-i-1) << " ";
      sum-=(i+1);
    }
    cout << (-sum) << "\n";
  }
}



#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using ll = long long;
using ui = unsigned int;
using ul = unsigned long long;
using ld = long double;
using v1i = vector<int>;
using v1ll = vector<ll>;
using v2i = vector<vector<int>>;
using v2ll = vector<vector<ll>>;
using v3i = vector<vector<vector<int>>>;
using v3ll = vector<vector<vector<ll>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr ll MOD = 1000000007;
constexpr ll MOD2 = 998244353;

int main(){
    int n, k, m, ng = -1, ok = 1000000000; cin >> n >> k;
    m = k * k / 2;
    v2i v(n, v1i(n));
    v2i dp(n+1, v1i(n+1, 0));
    rep(i, n) rep(j, n) cin >> v[i][j];
    while(ok-ng > 1) {
        rep(i, n+1) dp[i].resize(n+1, 0);
        int c = (ng + ok) / 2;
        rep(i, n) {
            rep(j, n) {
                dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1] - dp[i][j];
                if(v[i][j] > c) ++dp[i+1][j+1];
            }
        }
        bool b = 0;
        rep(i, n-k+1) rep(j, n-k+1) if(dp[k+i][k+j] + dp[i][j] - dp[k+i][j] - dp[i][k+j] <= m) b = 1;
        if(b) ok = c;
        else ng = c;
    }
    cout << ok << "\n";
    return 0;
}
