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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll fibo[10];
ll dp[102][10];

ll func_fibo(ll n){
    if(n <= 0) return 1;
    else{
        return fibo[n];
    }
}
int main()
{
    cout << fixed << setprecision(15);
    ll H, W, K;
    cin >> H >> W >> K;

    fibo[1] = 2;
    fibo[2] = 3;
    for(ll i=3; i<=10; i++){
        fibo[i] = fibo[i-1] + fibo[i-2];
    }
    // cout << func_fibo(8) << endl;

    Fill(dp, 0);

    dp[0][1] = 1;

    for(ll i=1; i<=H; i++){
        for(ll j=1; j<=W; j++){
            dp[i][j] += (dp[i-1][j]*func_fibo(j-2)*func_fibo(W-j-1)) % MOD;
            if(j>1){
                dp[i][j] += (dp[i-1][j-1]*func_fibo(j-3)*func_fibo(W-j-1)) % MOD;
            }
            if(j< W){
                dp[i][j] += (dp[i-1][j+1]*func_fibo(j-2)*func_fibo(W-j-2)) % MOD;
            }
            dp[i][j] = dp[i][j] % MOD;
        }
    }

    cout << dp[H][K] << endl;
    return 0;
}

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////

void solve() {
	int H, W, K;
	cin >> H >> W >> K;
	/*
	縦棒がW本ある。W-1個のあるなしで全探索。って
	*/

	//左付きで棒があるかないか
	vector<vector<bool>> BF;
	vector<int> BF_num;
	for (int s = 0; s < (1 << (W-1)); ++s) {
		int ter = s;
		vector<bool> res(W - 1);
		int cnt = 0;
		for (int i = 0; i < W-1; ++i) {
			if (ter & 1) {
				res[i] = true;
				cnt++;
			}
			else {
				res[i] = false;
			}
			ter /= 2;
		}
		bool flag = true;
		for (int i = 0; i < W - 1 - 1; ++i) {
			if (res[i] == true && res[i + 1] == true) {
				flag = false;
				break;
			}
		}
		if (flag == true) {
			BF.push_back(res);
			BF_num.push_back(cnt);
		}
	}

	/*
	H+1 * W * (K+1)個必要
	*/
	//高さと位置のみ
	vector<vector<LL>> dp(H + 1,vector<LL>(W, 0));
	dp[0][0] = 1;
	int BF_len = BF.size();
	for (int h = 0; h < H; ++h) {//上から順に
		//dp[h]->dp[h+1]
		for (int s = 0; s < BF_len; ++s) {//全ての横棒で
			vector<bool> B = BF[s];

			for (int w = 0; w < W; ++w) {
				//dp[h][k]
				if (w+1 <W && B[w] == true) {//右へ
					dp[h + 1][w + 1] += dp[h][w];
					dp[h + 1][w + 1] %= MOD;
				}
				else if (w - 1 >= 0 && B[w - 1] == true) {//左
					dp[h + 1][w - 1] += dp[h][w];
					dp[h + 1][w - 1] %= MOD;
				}
				else{//真下へ
					dp[h + 1][w] += dp[h][w];
					dp[h + 1][w] %= MOD;
				}
			}
		}
	}
	//[H][K-1]
	LL ans = dp[H][K-1];

	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別

	solve();
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;

int main()
{
	int h,w;cin>>h>>w;
	int a,b;cin>>a>>b;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if((j<a && i<b)||(j>=a && i>=b))cout<<0;
			else cout<<1;
		}
		cout<<"\n";
	}
	return 0;
}

// includes
#include "bits/stdc++.h"
using namespace std;
// macros
#define ll long long
#define MOD  1000000007 // 998244353 //100000000  //
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define sz(x) ((ll)(x).size())
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popc __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
// constants
const ll N = 1e5+5, M = 1e6+5, A = 1e7+5, inf = 1e9; string alph("abcdefghijklmnopqrstuvwxyz");
const long long linf = 1LL << 60;
const double er = 1e-10, pi = 3.141592653589793238463;
const ll lx[4] = {0, 1, -1, 0};
const ll ly[4] = {1, 0, 0, -1};
const ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
const ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;

string s;

void solve(){
    ll n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<vector<int>> v(n, vector<int>(m, 0));
    rep(i, n){
        for(ll j = m-x; j < m; j++) v[i][j] ^= 1;
    }
    rep(j, m){
        for(ll i = n-y; i < n; i++) v[i][j] ^= 1;
    }
    rep(i, n) {rep(j, m) cout << v[i][j]; cout << endl;}
}

int main(int argc, char const* argv[])
{
    ll t = 1; //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    string str;
    int ret=0;
    vector<pair<char,int> > v;
    cin >> str;

    int cnt=1;
    char tmp=str[0];
    for(int i=1;i<str.size();++i){
        if(str[i] == tmp){
            cnt++;
        }else{
            v.push_back(make_pair(tmp,cnt));
            cnt=1;
            tmp = str[i];
        }
    }
    v.push_back(make_pair(tmp,cnt));
    for(int i=0;v.size() >=3 && i<v.size()-2;++i){
        if(v[i].first == 'J' &&
           v[i+1].first == 'O' &&
           v[i+2].first == 'I'){
            if(v[i].second >= v[i+1].second &&
               v[i+2].second >= v[i+1].second){
                ret = max(ret, min(v[i].second, min(v[i+1].second,v[i+2].second)));
            }
        }
    }
    cout << ret << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<pair<int, int>> graph[100001];
int ans[100001];
signed main() {
    //Ввод графа и вершины start.
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		--a, --b;
		graph[a].push_back({b, c});
		graph[b].push_back({a, c});
	}
	int Q, K;
	cin >> Q >> K;
    for (int i = 0; i < n; i++) {
        ans[i] = LONG_MAX;
    }
    int start = K - 1;
    ans[start] = 0;

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;

    q.push({0, start});

    while (!q.empty()) {
        pair<int, int> c = q.top();
        q.pop();

        int dst = c.first, v = c.second;

        if (ans[v] < dst) {
            continue;
        }

        for (pair<int, int> e: graph[v]) {
            int u = e.first, len_vu = e.second;

            int n_dst = dst + len_vu;
            if (n_dst < ans[u]) {
                ans[u] = n_dst;
                q.push({n_dst, u});
            }
        }
    }
    for (int i = 1; i <= Q; i++) {
    	int u, v;
    	cin >> u >> v;
    	u--; v--;
    	cout << ans[u] + ans[v] << '\n';
    }
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N, M, Q, sum[510][510], lr[510][510];

int main(int argc, char **argv)
{
	cin >> N >> M >> Q;
	REP(i, M)
	{
		ll l, r; cin >> l >> r;
		--l, --r;
		++lr[l][r];
	}

	REP(i, N)REP(j, N)
	{
		sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + lr[i][j];
	}

	REP(_, Q)
	{
		ll l, r; cin >> l >> r;
		--l, --r;
		std::cout << sum[r+1][r+1] - sum[r+1][l] - sum[l][r+1] + sum[l][l] << std::endl;
	}
}


#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)

int main()
{
  string str;
  //  string roman[] = {"I", "V", "X", "L", "C", "D", "M"};
  map<char, int> roman;
  roman['I'] = 1;
  roman['V'] = 5;
  roman['X'] = 10;
  roman['L'] = 50;
  roman['C'] = 100;
  roman['D'] = 500;
  roman['M'] = 1000;

  while(cin>>str){
    int nums[str.size()];
    REP(i,str.size())
      nums[i] = roman[str[i]];

    int dec=0;
    int begin=0;
    int i=0;
    while(i<str.size()-1){
      if(nums[i] < nums[i+1]){
	for(int j=begin; j<=i; j++){
	  dec += nums[j];
	  nums[j] = 0;
	}
	begin = i+2;
      }
      if(nums[i] > nums[i+1]){
	begin = i+1;
      }
      i++;
    }

    int res=0;
    REP(i,str.size()) res += nums[i];

    cout << res-dec << endl;
  }

  return 0;
}

#include <iostream>
using namespace std;

int main()
{
	char rome[110];
  int	num, ara, nu;
	while(cin >> rome){
		num = ara = nu = 0;
		for(int i = 0; rome[i] != '\0'; i++){
			if (rome[i] == 'I') num = 1;
			else if (rome[i] == 'V') num = 5;
			else if (rome[i] == 'X') num = 10;
			else if (rome[i] == 'L') num = 50;
			else if (rome[i] == 'C') num = 100;
			else if (rome[i] == 'D') num = 500;
			else if (rome[i] == 'M') num = 1000;

			if (nu < num)	ara += num - nu - nu;
			else ara += num;
			nu = num;
		}
		cout << ara << endl;
	}
	return (0);
}


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

int main() {
  int a, b, c, d;
  string reply;

  cin >> a >> b >> c >> d;

  a += b;
  c += d;

  if (a > c) {
    reply = "Left";
  } else if (a == c) {
    reply = "Balanced";
  } else {
    reply = "Right";
  }
  cout << reply << endl;
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int a, b; cin >> a >> b;
    string s; cin >> s;

    int cnt1 = 0, cnt2=0;
    int h_cnt=0;

    rep(i, s.size()){
       if(s[i]=='-'){
           h_cnt++;
           if(h_cnt==1)swap(cnt1, cnt2);
           continue;

       }
       else{
           cnt1++;
       }
    }
    if(h_cnt==0||h_cnt>1){
        out("No");
        return 0;
    }

    if(a==cnt2&&b==cnt1){
        out("Yes");
    }
    else out("No");
}


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

int main() {
    int a,b,i,n;
    cin>>a>>b;

    n=((a*2)-1)/2;
    for(i=0;i<n;i++)
    {
        a--;
        cout<<b-a<<" ";
    }
    cout<<b<<" ";
    a=0;
    for(i=n+1;i<2*n+1;i++)
    {
        a++;
        cout<<b+a<<" ";
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int k,x;
	cin>>k>>x;
	FOR(i,x-k+1,x+k){
		printf("%d ",i);
	}

	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
#include<functional>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

template<typename T>
void sort_u(T& v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(),v.end()), v.end());
}

template<typename T, typename DT=T>
struct monoid_factory {
  using value_type = T;
  using operator_type = DT;
  using oa_type = std::function<void(operator_type&,operator_type)>;
  using va_type = std::function<void(value_type&,operator_type)>;
  using vo_type = std::function<value_type(value_type,operator_type)>;
  using vv_type = std::function<value_type(value_type,value_type)>;
  value_type ve;
  operator_type oe;
  oa_type op_assign;
  va_type v_assign;
  vo_type v_op;
  vv_type v_v;
  monoid_factory(value_type in_ve, operator_type in_oe, oa_type&& in_oa,
    va_type&& in_va, vo_type&& in_vo, vv_type in_vv): ve(in_ve), oe(in_oe),
    op_assign(in_oa), v_assign(in_va), v_op(in_vo), v_v(in_vv) {}
};

// lazy_seg_tree
template<typename MonoidFactory>
struct lazy_seg_tree {
  using T  = typename MonoidFactory::value_type;
  using OT = typename MonoidFactory::operator_type;
  std::vector<T> data_;
  std::vector<OT> lazy_;
  int NN;
  MonoidFactory mf;

  lazy_seg_tree(int N, MonoidFactory const& in_m): mf(in_m)  {
    NN=1;
    while(NN<N+2) NN<<=1;
    data_.assign(NN*2-1, mf.ve);
    lazy_.assign(NN*2-1, mf.oe);
  }

  void eval(int k) {
    if(lazy_[k] == mf.oe) return;
    if(k*2+1 < NN*2-1) {
      mf.op_assign(lazy_[2*k+1], lazy_[k]);
      mf.op_assign(lazy_[2*k+2], lazy_[k]);
    }
    mf.v_assign(data_[k], lazy_[k]);
    lazy_[k] = mf.oe;
  }

  T update(int a, int b, OT x, int k, int l, int r) {
    if(b <= l || r <= a) {
      eval(k);
      return data_[k];
    }
    if(a <= l && r <= b) {
      mf.op_assign(lazy_[k], x);
      return mf.v_op(data_[k], lazy_[k]);
    }
    eval(k);
    int m = (l+r)/2;
    T vl = update(a, b, x, k*2+1, l, m);
    T vr = update(a, b, x, k*2+2, m, r);
    return data_[k] = mf.v_v(vl, vr);
  }

  T query(int a, int b, int k, int l, int r) {
    if(b <= l || r <= a) return mf.ve;
    eval(k);
    if(a <= l && r <= b) return data_[k];
    int m = (l+r)/2;
    T vl = mf.ve, vr = mf.ve;
    if(!(m <= a || b <= l)) vl = query(a, b, k*2+1, l, m);
    if(!(r <= a || b <= m)) vr = query(a, b, k*2+2, m, r);
    return mf.v_v(vl, vr);
  }

  void update(int a, int b, OT x){ update(a, b, x, 0, 0, NN); }
  T query(int a, int b){ return query(a, b, 0, 0, NN); }
};

struct C {
  int l, r, v;
  C(int S, int T, int X): l(std::max(0,S-X)), r(std::max(0, T-X)), v(X) {}
};

int const INF = 1e9+5;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, Q; std::cin >> N >> Q;
  std::vector<int> xs(1, 0);
  std::vector<C> cond;
  for(int i = 0; i < N; ++i) {
    int S, T, X; std::cin >> S >> T >> X;
    if(X >= T) continue;
    cond.emplace_back(S, T, X);
    xs.push_back(cond.back().l);
    xs.push_back(cond.back().r);
  }
  sort_u(xs);
  for(auto& c: cond) {
    c.l = std::lower_bound(xs.begin(), xs.end(), c.l) - xs.begin();
    c.r = std::lower_bound(xs.begin(), xs.end(), c.r) - xs.begin();
  }

  auto ch_min = [](int& o1, int o2)->void { if(o1 > o2) o1 = o2; };
  auto op_min = [](int x, int y)->int { return std::min(x, y); };
  monoid_factory<int> mf(INF, INF, ch_min, ch_min, op_min, op_min);
  lazy_seg_tree<monoid_factory<int>> lst(xs.size(), mf);
  for(auto& c: cond) lst.update(c.l, c.r, c.v);
  for(int i = 0; i < Q; ++i) {
    int D; std::cin >> D;
    int d = std::upper_bound(xs.begin(), xs.end(), D) - xs.begin();
    int ans = lst.query(d-1, d);
    if(ans == INF) ans = -1;
    std::cout << ans << "\n";
  }
  return 0;
}

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define all(v) (v).begin(),(v).end()
using ll = long long;
constexpr ll INF = 1e18;

vector<ll> solver(ll N, ll Q, vector<ll> a, vector<ll> t, vector<ll> u, vector<ll> v) {
    fenwick_tree<ll> fw(N);
    vector<ll> ans;
    for (int i = 0; i < N; i++) {
        fw.add(i, a[i]);
    }
    for (int i = 0; i < Q; i++) {
        if (t[i] == 0) {
            fw.add(u[i], v[i]);
        } else {
            ans.push_back(fw.sum(u[i], v[i]));
        }
    }
    return ans;
}

int main(void) {
    ll N, Q;
    cin >> N >> Q;
    vector<ll> a(N);
    vector<ll> t(Q), u(Q), v(Q);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < Q; i++) {
        cin >> t[i] >> u[i] >> v[i];
    }
    for (auto&& x : solver(N, Q, a, t, u, v)) {
        cout << x << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<double, P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)10000000000000000

int main() {
  ll N,Q;
  cin>>N>>Q;
  priority_queue<event>pq;
  set<ll>st;
  //eventはP(P(a,b),c)で書き、
  //aに時刻をもち,b=0→工事開始,1→終了,2→歩行者とする
  rep(i,N){
    double s,t;
    ll x;
    cin>>s>>t>>x;
    s=(double)x-s+0.5;
    t=(double)x-t+0.5;
    pq.push(event(s,P(0ll,x)));
    pq.push(event(t,P(1ll,x)));
  }
  rep(i,Q){
    double g;
    cin>>g;
    pq.push(event(-1*g,P(2ll,0ll)));
  }
  while(!pq.empty()){
    auto t=pq.top();
    pq.pop();
    if(t.second.first==0){
      st.insert(t.second.second);
    }
    if(t.second.first==1){
      st.erase(t.second.second);
    }
    if(t.second.first==2){
      if(st.empty()){cout<<-1<<endl;}
      else{
        cout<<*begin(st)<<endl;
      }
    }
  }
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"

typedef tree<
   pair<int,int>,
   null_type,
   less< pair<int,int> >,
   rb_tree_tag,
   tree_order_statistics_node_update
>ordered_set;

int32_t main(){
	int n,q;
	cin>>n>>q;
	array<int,3> a[n];
	for(int i=0;i<n;i++)
		cin>>a[i][1]>>a[i][2]>>a[i][0];
	sort(a,a+n);

	set<pair<int,int>>s;
	for(int i=0;i<q;i++){
		int x;
		cin>>x;
		s.insert({x,i});
	}

	int ans[q];
	memset(ans,-1,sizeof ans);
	for(int i=0;i<n;i++){
		int t1 = a[i][1] - a[i][0];
		int t2 = a[i][2] - a[i][0];

		auto l = s.lower_bound({t1,0ll});
		auto r = s.lower_bound({t2,0ll});
		/*cout<<l->ff<<" "<<l->ss<<endl;
		cout<<r->ff<<" "<<r->ss<<endl;
		cout<<t2<<" "<<t1<<endl<<endl;
		*/vector<pi>v;
		for(auto it=l;it!=r;it++){
			pi x = *it;
			//cout<<x.ff<<" "<<x.ss<<endl;
			ans[x.ss] = a[i][0];
			v.push_back(x);
		}

		//print(v);
		for(auto &p :v)
			s.erase(p);
	}

	for(int i=0;i<q;i++)
		cout<<ans[i]<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  string s; cin >> s;
  int q; cin >> q;
  rep(_, q) {
    int k; cin >> k;
    ll d = 0, m = 0, cnt = 0, ans = 0;
    rep(i, n) {
      if(i >= k) {
        if(s[i-k] == 'D') {
          d--;
          cnt -= m;
        } else if(s[i-k] == 'M') {
          m--;
        }
      }
      if(s[i] == 'D') {
        d++;
      } else if(s[i] == 'M') {
        m++;
        cnt += d;
      } else if(s[i] == 'C') {
        ans += cnt;
      }
    }
    cout << ans << endk;
  }
  return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#include <stack>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int H,W;
vector<string> S;

int same[2020][2020];
int diff[2020][2020];

void preprocess(){
    rep(i,H) rep(j,W){
        if(j==0) continue;
        if(S[i][j]==S[i][j-1]) same[i][j]=1;
        if(i>0&&S[i][j]==S[i][j-1]) same[i][j]+=same[i-1][j];
    }
    rep(i,H) rep(j,W){
        if(j==0) continue;
        if(S[i][j]!=S[i][j-1]) diff[i][j]=1;
        if(i>0&&S[i][j]!=S[i][j-1]) diff[i][j]+=diff[i-1][j];
    }
}

int calc(vector<int> &P){
    stack<pair<int,int>> st;
    int res=0;
    rep(j,W){
        if(j==0) continue;
        int pos=j;
        while(st.size()&&st.top().first>=P[j]){
            auto f=st.top();
            st.pop();
            pos=f.second;
            chmax(res,f.first*(j-pos+1));
        }
        st.push(mkp(P[j],pos));
    }
    while(st.size()){
        auto f=st.top();
        st.pop();
        chmax(res,f.first*(W+1-f.second));
    }

    return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin>>H>>W;
  S.resize(H);
  rep(i,H) cin>>S[i];

  preprocess();

  int ans=max(H,W);
  rep(i,H){
      if(i==0) continue;
      {
          vector<int> P(W,0);
          vector<int> rev(W,0);
          rep(j,W) if(S[i][j]=='.') rev[j]=1;
          rep(j,W){
              if(j==0) continue;
              if(rev[j]==rev[j-1]) P[j]=same[i][j];
              else P[j]=diff[i][j];
          }
          chmax(ans,calc(P));
      }

      {
          vector<int> P(W,0);
          vector<int> rev(W,0);
          rep(j,W) if(S[i][j]!='.') rev[j]=1;
          rep(j,W){
              if(j==0) continue;
              if(rev[j]==rev[j-1]) P[j]=same[i][j];
              else P[j]=diff[i][j];
          }
          chmax(ans,calc(P));
      }
  }

  cout<<ans<<endl;

  return 0;
}

//    Have a nice day
//    ∠( ᐛ 」∠)

#include<bits/stdc++.h>

#define mp make_pair
#define pb push_back
#define x first
#define y second

using namespace std;

typedef long long LL;
typedef pair<int,int> pii;

template <typename T> inline T read()
{
	T sum=0, fl=1; char ch=getchar();
	for(; !isdigit(ch); ch=getchar()) if(ch=='-') fl=-1;
	for(; isdigit(ch); ch=getchar()) sum=(sum<<3)+(sum<<1)+ch-'0';
	return sum*fl;
}

const int maxn=2000+5;
int n, m, ans;
char s[maxn][maxn];
int l[maxn], r[maxn], h[maxn], c[maxn][maxn];

void Solve()
{
	n=read<int>(), m=read<int>(); ans=max(n, m);
	for(int i=1; i<=n; ++i) scanf("%s", s[i]+1);
	--n, --m;
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
			if(((s[i][j]=='#')+(s[i+1][j]=='#')+(s[i][j+1]=='#')+(s[i+1][j+1]=='#'))&1);
			else c[i][j]=1;

	for(int i=1; i<=m; ++i) l[i]=r[i]=maxn;
	for(int i=1; i<=n; ++i)
	{
		for(int j=1, p=0; j<=m; ++j)
		{
			if(c[i][j]) ++p; else p=0;
			l[j]=min(l[j], p);
		}
		for(int j=m, p=0; j>=1; --j)
		{
			if(c[i][j]) ++p; else p=0;
			r[j]=min(r[j], p);
		}
		for(int j=1; j<=m; ++j)
		{
			if(c[i][j]) ++h[j], ans=max(ans, (l[j]+r[j])*(h[j]+1));
			else l[j]=r[j]=maxn, h[j]=0;
		}
	}
	printf("%d\n", ans);
}

int main()
{

   // freopen("081d.in","r",stdin);
    //freopen("081d.out","w",stdout);

    Solve();

    return 0;
}


#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  string x, y, z;
  cin >> x >> y >> z;
  cout << z+" "+x+" "+y << endl;
}

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {

   int a,b,c;
   cin >> a >> b >> c;
   swap(a, b);
   swap(a, c);
    cout << a << " " << b << " " << c;
    return 0;
}


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

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  cout<<180*(n-2);
}

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

typedef long long LL;

int n;

void into(){
  scanf("%d",&n);
}

void work(){
}

void outo(){
  printf("%d\n",(n-2)*180);
}

int main(){
  into();
  work();
  outo();
  return 0;
}


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

int main() {
  int N,L;
  cin >> N >> L;
  vector<int>A(N);
  vector<int>B(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    A.at(i) = L + i;
    sum += A.at(i);
    B.at(i) = abs(A.at(i));
  }
  sort(B.begin(), B.end());

  for (int i = 0; i < N; i++) {
    if (B.at(0) == abs(A.at(i))){
      sum -= A.at(i);
    }
  }

  cout << sum << endl;
}


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

string s;

void dfs(int i, int end, const string& lTemp, const string& rTemp, vector<P> &x)
{
    if (i == end)
    {
        x.push_back(make_pair(lTemp, rTemp));
        return;
    }

    dfs(i + 1, end, lTemp + s[i], rTemp, x);
    dfs(i + 1, end, lTemp, s[i] + rTemp, x);
}

int main(void)
{
    int n;
    cin >> n;
    cin >> s;
    reverse(s.begin() + n, s.end());

    vector<P> vl;
    vector<P> vr;
    dfs(0, n, "", "", vl);
    dfs(n, 2 * n, "", "", vr);
    sort(vl.begin(), vl.end());
    sort(vr.begin(), vr.end());

    long long score = 0;
    auto ir_lower = vr.begin();
    for (auto il = vl.begin(); il < vl.end(); ++il)
    {
        ir_lower = lower_bound(ir_lower, vr.end(), *il);
        auto ir_upper = upper_bound(ir_lower, vr.end(), *il);

        score += ir_upper - ir_lower;
    }

    cout << score << endl;
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N+2, 0);
    for(int i=1;i<=N;i++){
        cin >> A[i];
    }
    int sum = 0;
    for(int i=0;i<N+1;i++){
        sum += abs(A[i+1] - A[i]);
    }
    for(int i=1;i<N+1;i++){
        auto res = sum;
        res -= abs(A[i+1] - A[i]);
        res -= abs(A[i] - A[i-1]);
        res += abs(A[i+1] - A[i-1]);
        cout << res << endl;
    }

    return 0;
}


#include<bits/stdc++.h>

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) FOR(i,0,a)
#define RREP(i,a) RFOR(i,a,0)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<int> VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::pair<int,int> PII;

//Common
typedef long long Weight;
const Weight WEIGHT_INF = std::numeric_limits<Weight>::max()/4;

struct Edge {
    int src, dst;
    Weight weight;
};
bool operator<(const Edge& a, const Edge& b) {
    return (a.weight < b.weight);
};
bool operator>(const Edge& a, const Edge& b) {
    return (a.weight > b.weight);
};
typedef std::vector<Edge> Edges;
typedef std::vector<Edges> Graph;

//Wardhall-Floyd
std::vector< std::vector<Weight> > g;
std::vector< std::vector<int> > trace;
void warshallFloyd() {
    int n = g.size();
    trace.resize(n, std::vector<int>(n, -1));
    REP(k, n) REP(i, n) REP(j, n) {
        if(g[i][k] == WEIGHT_INF || g[k][j] == WEIGHT_INF){
            continue;
        }
        if(g[i][j] > g[i][k] + g[k][j]){
            g[i][j] = g[i][k] + g[k][j];
            trace[i][j] = k;
        }
    }
}

int main(void){
    int V, E;
    std::cin >> V >> E;
    g.resize(V, std::vector<Weight>(V, WEIGHT_INF));
    REP(i, V) g[i][i] = 0;

    int s, d;
    Weight w;
    REP(i, E) {
        std::cin >> s >> d >> w;
        g[s][d] = w;
    }

    warshallFloyd();

    bool f = false;
    REP(i, V){
        if(g[i][i] < 0){
            f = true;
        }
    }
    if(f){
        std::cout << "NEGATIVE CYCLE" << std::endl;
    } else {
        REP(i, V) {
            REP(j, V) {
                if(j > 0) std::cout << " ";
                if(g[i][j] == WEIGHT_INF){
                    std::cout << "INF";
                } else {
                    std::cout << g[i][j];
                }
            }
            std::cout << std::endl;
        }
    }
}

#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

template <class T>
using gp_queue=priority_queue<T, deque<T>, less<T>>;

using Weight=long long;
static const Weight INF=1LL<<57;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

vector<vector<Weight>> shortest_distance(Graph &g) {
    /* Johnson */
    size_t V=g.size();
    vector<Weight> h(V);
    for (size_t k=0; k<V; ++k)
        for (size_t i=0; i<V; ++i)
            for (const Edge &e: g[i])
                if (h[e.dst] > h[e.src] + e.weight) {
                    h[e.dst] = h[e.src] + e.weight;
                    if (k == V-1)
                        return vector<vector<Weight>>();
                }

    for (size_t i=0; i<V; ++i)
        for (Edge &e: g[i])
            e.weight += h[e.src] - h[e.dst];

    vector<vector<Weight>> d(V, vector<Weight>(V, INF));
    vector<vector<size_t>> prev(V, vector<size_t>(V, -1));
    for (size_t s=0; s<V; ++s) {
        gp_queue<Edge> q; q.push(Edge(s, s, 0));
        d[s][s] = 0;
        while (!q.empty()) {
            Edge e=q.top(); q.pop();
            if (~prev[s][e.dst]) continue;

            prev[s][e.dst] = e.src;
            for (const Edge &f: g[e.dst]) {
                if (d[s][f.dst] > e.weight + f.weight) {
                    d[s][f.dst] = e.weight + f.weight;
                    q.push(Edge(f.src, f.dst, e.weight+f.weight));
                }
            }
        }
        for (size_t u=0; u<V; ++u)
            if (d[s][u] < INF)
                d[s][u] += h[u] - h[s];
    }

    for (size_t v=0; v<V; ++v)
        for (Edge &e: g[v])
            e.weight += h[e.dst] - h[e.src];

    return d;
}

int main() {
    size_t V, E;
    scanf("%zu %zu", &V, &E);

    Graph g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t;
        Weight d;
        scanf("%zu %zu %lld", &s, &t, &d);

        connect(g, s, t, d);
    }

    vector<vector<Weight>> d=shortest_distance(g);
    if (d.empty())
        return !printf("NEGATIVE CYCLE\n");

    for (vector<Weight> w: d)
        for (size_t i=0; i<V; ++i)
            if (w[i] < INF) {
                printf("%lld%c", w[i], i<V-1? ' ':'\n');
            } else {
                printf("INF%c", i<V-1? ' ':'\n');
            }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, v[100000];
P a[100001], b[100001];

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) cin >> v[i];
	REP(i, 100001) a[i] = b[i] = P{0, i};
	REP(i, n/2) ++a[v[i*2]].F;
	REP(i, n/2) ++b[v[i*2+1]].F;
	sort(a, a+100001); reverse(a, a+100001);
	sort(b, b+100001); reverse(b, b+100001);
	if (a[0].S == b[0].S) cout << min(n - a[0].F - b[1].F, n - b[0].F - a[1].F) << endl;
	else cout << (n - a[0].F - b[0].F) << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll  long long
#define ld long double
#define f first
#define s second
#define matrix vector<vector<char>>
#define zero(n,m) matrix(n , vector<char>(m,'0'))
#define one(n,m) matrix(n , vector<ll>(m,1))
#define pii pair<int,int>
#define point complex<ld>
#define angle(a) (atan2((a).imag() , (a).real() ))
#define pi acos(-1)
#define X real()
#define Y imag()
const int N = 2e5+5;

ll n , a[N] , b[N] , seg[4*N] , lazy[4*N];
ll st[N] , en[N] , st2[N] , en2[N];
set<ll> stt;

void probagate(int node , int st , int en)
{
    if (lazy[node] != 0)
    {
        seg[node] += lazy[node];
        if (st != en)
        {
            lazy[2*node] += lazy[node];
            lazy[2*node+1] += lazy[node];
        }
        lazy[node] = 0;
    }
}

void update(int node , int st , int en , int l , int r , int val)
{
    probagate(node , st , en);

    if (st > en || st > r || en < l)
        return;

    if (st >= l && en <= r)
    {
        lazy[node] += val;
        return probagate(node , st , en);
    }

    int mid = (st+en)/2;
    update(2*node,st,mid,l,r,val);
    update(2*node+1,mid+1,en,l,r,val);
    seg[node] = max(seg[2*node] , seg[2*node+1]);
}

ll query(int node , int st , int en , int l , int r)
{
    if (st > en || st > r || en < l) return 0;

    probagate(node , st , en);

    if (st >= l && en <= r)
    {
        return seg[node];
    }

    int mid = (st+en)/2;

    return max(query(2*node , st , mid , l , r) , query(2*node+1 , mid+1 , en , l , r));
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
        if (!st[a[i]]) st[a[i]] = i;
        en[a[i]] = i;
    }

    for(int i=1; i<=n; i++)
    {
        cin >> b[i];
        if (!st2[b[i]]) st2[b[i]] = i;
        en2[b[i]] = i;
        stt.insert(b[i]);
    }

    for(ll i=1; i<=n; i++)
    {
        ll l = st[b[i]] , r = en[b[i]];
        if (l > i)
        {
            update(1,0,n-1,0,l-i-1,1);
        }
        l = max(en[b[i]]+1,i) , r = n;
        if (l<=r)
        {
            ll l2 = l-i , r2 = r-i;
            if (l2 <= r2)
            {
                update(1,0,n-1,l2,r2,1);
            }
        }

        //from one to st[b[i]]-1
        l = 1 , r = min(st[b[i]]-1 , i-1);
        if (l<=r)
        {
            ll l2 = n-i+l , r2 = n-i+r;
            if (l2 <= r2)
            {
                update(1,0,n-1,l2,r2,1);
            }
        }

        if (i > en[b[i]])
        {
            l = en[b[i]]+1 , r = i-1;
            if (l<=r)
            {
                ll l2 = n-i+l , r2 = n-i+r;
                if (l2 <= r2)
                {
                    update(1,0,n-1,l2,r2,1);
                }
            }
        }
    }

    for(int i=0; i<n; i++)
    {
        if (query(1,0,n-1,i,i) == n)
        {
            cout << "Yes\n";
            for(int j=1; j<=n; j++)
            {
                int newIdx = j + i;
                if (newIdx > n) newIdx -= n;
                a[newIdx] = b[j];
            }
            for(int j=1; j<=n; j++)
                cout << a[j] << ' ';
            cout << '\n';
            return 0;
        }
    }
    cout << "No\n";

    return 0;
}


#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

string S[2009];
int H,W,ans;
int hig[2009];

bool ck(int i,int j){
    return (1^(S[i][j]==S[i][j-1])^(S[i-1][j]==S[i-1][j-1]));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin>>H>>W;
    rep(i,H) cin>>S[i];

    ans=max(H,W);
    FOR(i,1,H){
        stack<pii> stc;
        stc.push({0,0});
        FOR(j,1,W){
            if(ck(i,j)) hig[j]++;
            else hig[j]=0;
            int h=stc.top().first;
            int w=stc.top().second;
            int ww=0;
            while(h>hig[j]){
                ww+=w;
                chmax(ans,(h+1)*(ww+1));
                stc.pop();
                h=stc.top().first;
                w=stc.top().second;
            }
            if(h<hig[j]){
                stc.push({hig[j],1+ww});
            }else{
                stc.top().second+=1+ww;
            }
        }
        int ww=0;
        while(!stc.empty()){
            int h=stc.top().first;
            int w=stc.top().second;
            ww+=w;
            chmax(ans,(h+1)*(ww+1));
            stc.pop();
        }
    }
    cout1(ans)
}

#include<bits/stdc++.h>
#define ll int
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace :: std;

const ll maxn=2010;

char jad[maxn][maxn];
ll ava[maxn];
ll l[maxn];
ll r[maxn];

ll finds(ll n){
	stack<ll> stk;
	for(ll i=0;i<n;i++){
		while(!stk.empty() && ava[stk.top()]>=ava[i]){
			stk.pop();
		}
		if(stk.empty()){
			l[i]=-1;
		}else{
			l[i]=stk.top();
		}
		stk.push(i);
	}
	while(!stk.empty()){
		stk.pop();
	}
	for(ll i=n-1;i>=0;i--){
		while(!stk.empty() && ava[stk.top()]>=ava[i]){
			stk.pop();
		}
		if(stk.empty()){
			r[i]=n;
		}else{
			r[i]=stk.top();
		}
		stk.push(i);
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ans=max(ans,(ava[i]+1)*(r[i]-l[i]));
	}
	return ans;
}
bool good(ll i,ll j){
	int t=0;
	if(jad[i][j]=='#'){
		t^=1;
	}
	if(jad[i+1][j]=='#'){
		t^=1;
	}
	if(jad[i][j+1]=='#'){
		t^=1;
	}
	if(jad[i+1][j+1]=='#'){
		t^=1;
	}
	if(t&1){
		return 0;
	}
	return 1;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll w,h;
	cin>>w>>h;
	for(ll i=0;i<w;i++){
		for(ll j=0;j<h;j++){
			cin>>jad[i][j];
		}
	}
	ll ans=w;
	for(ll i=0;i<w-1;i++){
		for(ll j=0;j<h-1;j++){
			if(good(i,j)){
				ava[j]++;
			}else{
				ava[j]=0;
			}
		}
		ans=max(ans,finds(h-1));
	}

	cout<<ans;

}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
set<int> s;
s.insert(a);
  s.insert(b);
  s.insert(c);
  if(s.size()==2){cout<<"Yes";}
  else cout<<"No";

  return 0;
}

#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  vi a(3);
  map<int,int> mp;
  rep(i,3) {
    cin>>a[i];
    mp[a[i]]++;
  }
  bool ja=true;
  for(auto x:mp){
    if(x.second==2)ja=false;
  }
  if(ja) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

uint8_t can[30][200005];
int p2;
int a[200005], b[200005];
int n;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    gi(n);
	p2 = 1; rep(i, n-1) p2 = 2*p2%MOD;
	rep(i, n) gi(a[i]);
	rep(i, n) gi(b[i]);
	rep(l, 30) {
		int bv = 0;
		rep(i, n) bv = (bv*2+(bool)(b[i]&(1<<l)))%MOD;
		rep(x, 2) {
			int av = 0;
			rep(i, n) av = (av*2+(x^(bool)(a[i]&(1<<l))))%MOD;
			rep(k, n) {
				if(av == bv) can[l][k]=(x+1);
				av = (av+MOD-p2*(x^(bool)(a[k]&(1<<l))))%MOD;
				av = (av*2+(x^(bool)(a[k]&(1<<l))))%MOD;
			}
		}
	}
	rep(k, n) {
		int x = 0;
		rep(l, 30) {
			if(!can[l][k]) { x = -1; break; }
			x |= ((can[l][k]-1)<<l);
		}
		if(x != -1) print(k), pc(' '), print(x), pc('\n');
	}
}

#include <string>
#include <vector>
using namespace std;

vector<int> border(vector<int> S)
{
    int n = (int)S.size();
    vector<int> B(n+1);

    B[0] = -1;
    int j = -1;
    for (int i=1; i<=n; i++)
    {
        while (j>=0 && S[i-1]!=S[j])
            j = B[j];
        j++;
        B[i] = j;
    }

    return B;
}

//  B = border(P)
vector<int> search(vector<int> T, vector<int> P, vector<int> B)
{
    int n = (int)T.size();
    int m = (int)P.size();

    vector<int> A;
    int j = 0;
    for (int i=0; i+m<=n;)
    {
        if (j<m && T[i+j]==P[j])
        {
            j++;
            if (j==m)
                A.push_back(i);
        }
        else
        {
            i += j-B[j];
            if (j>0)
                j = B[j];
        }
    }
    return A;
}

#include <iostream>

int main()
{
    int N;
    cin>>N;
    vector<int> a(N), b(N);
    for (int &t: a)
        cin>>t;
    for (int &t: b)
        cin>>t;

    vector<int> ax(N), bx(N);
    for (int i=0; i<N; i++)
    {
        ax[i] = a[i]^a[(i+1)%N];
        bx[i] = b[i]^b[(i+1)%N];
    }
    for (int i=0; i<N-1; i++)
        ax.push_back(ax[i]);

    vector<int> K = search(ax, bx, border(bx));
    for (int k: K)
        cout<<k<<" "<<(a[k]^b[0])<<endl;
}


#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    string s;
    cin >> s;
    int n = s.size();

    forn(i, 0, n) {
        if (i+1 < n && s[i] == s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
        if (i+2 < n && s[i] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1\n";
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
 char str[3];
 int rain=1,sun=0;
 cin>>str;
 int len = strlen(str);
 for(int i = 0;i<len;i++)
 {
     if(str[i]=='R' && str[i+1]=='R')
     {
         rain++;
     }
     if(str[i]=='S')
     {
         sun++;
     }

 }
 if(rain>1)
 {
 cout<<rain<<endl;
 }
else if(sun==len)
{
    cout<<0<<endl;
}
else
{
    cout<<rain<<endl;
}
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=998244353;
const double EPS=1e-14;
const bool DEBUG=false;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////
void answer(ll sx, ll sy, ll tx, ll ty){
    for(int i=sy; i<ty; ++i){
        cout<<"U";
    }
    for(int i=sx; i<tx; ++i){
        cout<<"R";
    }
    for(int i=sy; i<ty; ++i){
        cout<<"D";
    }
    for(int i=sx; i<tx; ++i){
        cout<<"L";
    }

    cout<<"L";
    for(int i=sy; i<ty+1; ++i){
        cout<<"U";
    }
    for(int i=sx; i<tx+1; ++i){
        cout<<"R";
    }
    cout<<"D";

    cout<<"R";
    for(int i=sy; i<ty+1; ++i){
        cout<<"D";
    }
    for(int i=sx; i<tx+1; ++i){
        cout<<"L";
    }
    cout<<"U";
    cout<<endl;

    return;
}

/////

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(16);

    ll sx, sy, tx, ty;
    cin>>sx>>sy>>tx>>ty;
    answer(sx, sy, tx, ty);

    return 0;
}

//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class F> class rec_lambda {
  F f;

public:
  rec_lambda(F &&f) : f(std::move(f)) {}
  template <class... Args> auto operator()(Args &&... args) const {
    return f(*this, std::forward<Args>(args)...);
  }
};
template <class F> auto make_rec(F &&f) { return rec_lambda<F>(std::move(f)); }
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize n = scan<usize>();
  const u64 m = scan<u64>();
  const auto add = [&](u64 &l, const u64 r) { l = (l + r) % m; };
  auto dp = md_vec(3 * n + 1 + 3, n + 1 + 1, u64(0));
  dp[0][0] = 1;
  for (const usize i : rep(0, 3 * n + 1)) {
    for (const usize j : rep(0, n + 1)) {
      add(dp[i + 1][j], dp[i][j]);
      add(dp[i + 2][j + 1], dp[i][j] * (i + 1) % m);
      add(dp[i + 3][j + 1], dp[i][j] * (i + 1) % m * (i + 2) % m);
    }
  }
  u64 ans = 0;
  for (const usize i : rep(0, n + 1)) {
    add(ans, dp[3 * n][i]);
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


#include <bits/stdc++.h>

#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;

int x[N];
LL w[N];
int S, n;

int main() {

	scanf("%d%d", &n, &S);
	For(i, 1, n) scanf("%d%lld", &x[i], &w[i]);

	int l = 1, r = n, nxt = 0;
	LL ans = 0;
	while (x[l] < S && x[r] > S) {
		if (w[l] >= w[r]) {
			w[l] += w[r];
			if (nxt != l) ans += x[r] - x[l];
			--r, nxt = l;
		} else {
			w[r] += w[l];
			if (nxt != r) ans += x[r] - x[l];
			++l, nxt = r;
		}
	}

	if (x[l] < S) ans += S - x[l];
	else ans += x[r] - S;
	printf("%lld\n", ans);

	return 0;
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;

int n, S;
int p[MAXN];
int a[MAXN];
int ord[MAXN];
int m[2], sx[2][MAXN], sa[2][MAXN];

void init ();
void input ();
void work ();

int main()
{
	init();
	input();
	work();
}

void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d%d", &n, &S );
	lpi ( i, 1, n ) scanf ( "%d%d", &p[i], &a[i] );
}

void work ()
{
	// main work

	lpi ( i, 1, n ){
		if ( p[i] < S ){
			++m[0];
			sx[0][m[0]] = i, sa[0][m[0]] = a[i];
		}else break;
	}
	lpd ( i, n, 0 ){
		if ( p[i] > S ){
			++m[1];
			sx[1][m[1]] = i, sa[1][m[1]] = a[i];
		}
	}

	if ( !m[0] || !m[1] ){
		cout << ( qmax ( S - p[1], 0 ) + qmax ( p[n] - S, 0 ) ) << endl;
		return;
	}

//	lp ( t, 0, 2 ){
//		cerr << t << " : " << endl;
//		lpi ( i, 1, m[t] ) cerr << sx[t][i] << " " << sa[t][i] << endl;
//	}

	int ns = 0, np[2] = { 1, 1 }, ka = 0;
	LL ca = sa[1][1];
	while ( np[0] <= m[0] && np[1] <= m[1] ){
		if ( sa[ns][np[ns]] > ca || ( sa[ns][np[ns]] == ca && ns == 0 ) ){
			ord[++ka] = sx[ns^1][np[ns^1]++];
			ca += sa[ns][np[ns]];
			ns ^= 1;
		}else{
			ord[++ka] = sx[ns][np[ns]];
			ca += sa[ns][np[ns]++];
		}
	}
	ord[++ka] = sx[ns^1][np[ns^1]];
//	lpi ( i, 1, ka ) cerr << ord[i] << " "; cerr << endl;

	LL ans = 0;
	int cp = S;
	lpd ( i, ka, 0 ){
		ans += qabs ( cp - p[ord[i]] );
		cp = p[ord[i]];
	}

	cout << ans << endl;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 300 + 9;
const ll inf = 1e6 + 7;
typedef pair<ll,ll> LL;

ll t,n,a[N],i,j;
string s;
bool chk(){
    vector<ll> v;
    v.push_back(0);
    for (i = n;i >= 1;i--){
        ll p = a[i];
        for (auto j : v) p = min(p,p^j);
        if (p){
            if (s[i] == '1') return true;
            v.push_back(p);
        }
    }
    return false;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>t;
    while(t--){
        cin>>n;
        for (i = 1;i <= n;i++) cin>>a[i];
        cin>>s; s = " " + s;
        cout<<chk()<<"\n";
    }
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n;
    cin>>n;
    vec<ll> a(n);
    REP(i,n) cin>>a[i];

    ll sum=0;
    REP(i,n) sum^=a[i];
    for(auto &i:a) i&=~sum;//偶数のbitだけかんがえる

    vec<ll> base;
    for(auto &i:a){
        for(auto b:base){
            chmin(i,i^b);
        }
        if(i) base.push_back(i);
    }
    sort(all(base),greater<ll>());

    ll A=0;
    for(auto b:base) chmax(A, A^b);//奇数のみの集合を作る

    ll B=sum^A;
    cout<<A+B<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long INF=1e18;
struct Node
{
	long long h,p,su;
};
Node N[5005];
bool cmp(Node a,Node b)
{
	if(a.su==b.su)
	{
		return a.h<b.h;
	}
	return a.su<b.su;
}
long long dp[5005];
int ans;
int main() {
	int n;
	scanf("%d", &n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld %lld",&N[i].h,&N[i].p);
		N[i].su=N[i].h+N[i].p;
	}
	sort(N,N+n,cmp);
	for(int i=1;i<=n;i++)
	{
		dp[i]=INF;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i;j>=0;j--)
		{
			if(dp[j]!=INF&&dp[j]<=N[i].h)
			{
				dp[j+1]=min(dp[j+1],dp[j]+N[i].p);
			}
		}
	}
	ans=0;
	for(int i=0;i<=n;i++)
	{
		if(dp[i]!=INF)
		{
			ans=max(ans,i);
		}
		else
		{
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
#include <cctype>
#include <cstdio>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll> ;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI  3.1415926535
#define rep(i, k, n) for(ll i = k; i < n; i++)

vector<vector<char>> maze; //迷路を表す文字列
vvll cnt; //何回目の操作後に黒になったか
ll INF = 10000000000;

ll r, c;
ll dy[4] = {0, 1, 0, -1};
ll dx[4] = {1, 0, -1, 0};

void bfs(){
  queue<pll> que;

  //黒の位置をキューに入れる
  rep(i, 0, r){
    rep(j, 0, c){
      if(maze[i][j] == '#'){que.push(pll(i, j)); cnt[i][j] = 0;}
    }
  }

  //キューが空になるまでループ
  while(que.size()){
    //キューの先頭を取り出す
    pll p = que.front();
    que.pop();

    //移動四方向ループ
    rep(i, 0, 4){
      //移動後の点(nx,ny)
      ll ny = p.first + dy[i];
      ll nx = p.second + dx[i];
      //移動可能か、すでに訪れているか判定
      if(ny >= 0 && ny < r && nx >= 0 && nx < c && cnt[ny][nx] == INF && maze[ny][nx] != '#'){
        //移動できるならキューに入れ、その点をpの距離＋１にする
        que.push(pll(ny, nx));
        cnt[ny][nx] = cnt[p.first][p.second] + 1;
      }
    }
  }

  return;
}

int main(){
  cin >> r >> c;

  maze = vector<vector<char>> (r,vector<char>(c));
  cnt = vvll (r,vll(c,INF));
  ll ans = 0;

  rep(i, 0, r){
    rep(j, 0, c){
      cin >> maze[i][j];
    }
  }

  bfs();

  rep(i, 0, r){
    rep(j, 0, c){
      if(cnt[i][j] > ans){ans = cnt[i][j];}
    }
  }
  cout << ans << endl;
}


#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define cerr if(false) cerr
#define show(...) cerr << #__VA_ARGS__ << " = ",debug(__VA_ARGS__);
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T, typename S>
ostream &operator<<(ostream &os,pair<T,S>a){
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, vector<T> v){
    for(auto x:v)os << x << ' ';
    return os;
}
void debug(){cerr << '\n';}
template<typename H, typename... T>
void debug(H a, T... b){
    cerr << a;
    if(sizeof...(b))cerr << ", ";
    debug(b...);
}
vector<int> inv(const vector<int> &perm){
    vector<int> res(perm.size());
    rep(i,perm.size()){
        res[perm[i]] = i;
    }
    return res;
}
vector<int> product(const vector<int> &a, const vector<int> &b){
    vector<int> res(a.size());
    rep(i,a.size()){
        res[i] = a[b[i]];
    }
    return res;
}
vector<int> power(const vector<int> &a, ll p){
    auto res = a;
    auto temp = a;
    p--;
    for(int i = 0; i < 60; i++){
        if(p >> i & 1){
            res = product(res, temp);
        }
        temp = product(temp, temp);
    }
    return res;
}
ll x[100005];
ll dx[100005];
ll a[100005];
vector<int>b;
signed main(){
    int n;
    cin >> n;
    rep(i,n){
        cin >> x[i];
    }
    rep(i,n-1){
        dx[i] = x[i+1] - x[i];
        //        show(dx[i]);
    }
    int m;
    ll k;
    cin >> m >> k;
    rep(i,n-1){
        b.push_back(i);
    }
    rep(i,m){
        cin >> a[i];
        a[i]--;
        swap(b[a[i]-1],b[a[i]]);
    }
    rep(i,n-1){
        //        show(b[i]);
    }
    auto c = power(b,k);
    ll ans = x[0];
    rep(i,n){
        cout << ans << endl;
        if(i!=n-1){
            ans += dx[c[i]];
        }
    }
}

#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

const int N = 1e5 + 5;
ll x[N], p[N], a[N], b[N];
int n;

void go(ll k) {
    if(k == 1) {
        fr(i, 1, n - 1) {
            a[i] = p[i];
        }
        return;
    }
    if(k & 1) {
        go(k - 1);
        fr(i, 1, n - 1) {
            b[i] = a[p[i]];
        }
        fr(i, 1, n - 1) {
            a[i] = b[i];
        }
        return;
    }
    else {
        go(k / 2);
        fr(i, 1, n - 1) {
            b[i] = a[a[i]];
        }
        fr(i, 1, n - 1) {
            a[i] = b[i];
        }
        return;
    }
}

void solve() {
    sc(n);
    fr(i, 1, n) {
        sc(x[i]);
        p[i] = i;
    }
    int m;
    ll k;
    sc(m, k);
    fr(i, 1, m) {
        int pos;
        sc(pos);
        swap(p[pos], p[pos - 1]);
    }
    go(k);
    cout << x[1] << endl;
    ll xx = x[1];
    fr(i, 1, n - 1) {
        xx += x[a[i] + 1] - x[a[i]];
        cout << xx << endl;
    }
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;

int main(){
	char s[105];

	while(scanf("%s",s)!=EOF){
		int len,n[105]={},ans=0;
		len=strlen(s);
		rep(i,0,len){
			if(s[i]=='I') n[i]=1;
			else if(s[i]=='V') n[i]=5;
			else if(s[i]=='X') n[i]=10;
			else if(s[i]=='L') n[i]=50;
			else if(s[i]=='C') n[i]=100;
			else if(s[i]=='D') n[i]=500;
			else if(s[i]=='M') n[i]=1000;
		}
		rep(i,0,len-1){
			if(n[i]<n[i+1]) ans-=n[i];
			else ans+=n[i];
		}
		ans+=n[len-1];
		cout<<ans<<endl;
	}
}

#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int hyou[102];
	for (int i = 0; i < 102; i++) {
		hyou[i] = i*i*i;
	}
	int e;
	while (cin >> e) {
		if (e == 0) {
			break;
		}
		int a, b, c;
		for (int i = 1; ; i++) {
			if (hyou[i] > e) {
				c = i-1;
				break;
			}
		}
		for (int i = 1; ;i++) {
			if (i*i > e-hyou[c]) {
				b = i-1;
				break;
			}
		}
		for (int i = 1; ;i++) {
			if (i > e-hyou[c]-b*b) {
				a = i-1;
				break;
			}
		}
		int MIN = a+b+c;
		for (int i = c-1; i >= 0; i--) {
			for (int j = b+1; ; j++) {
				if (j*j > e-hyou[i]) {
					b = j-1;
					break;
				}
			}
			int q = e-hyou[i]-b*b;
			MIN = min(MIN, b+q+i);
		}
		cout << MIN << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;

int main(){

 int n = 5,k;
 int a[n];

 for(int i=0;i<5;i++)
    cin>>a[i];

    cin>>k;

 for(int i=0;i<n-1;i++)
 {
    for(int j=i+1;j<n;j++)
    {
        if(a[j] - a[i] > k){
        cout<<":("<<endl;
         return 0; }
    }
 }

 cout<<"Yay!"<<endl;

return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a>k) cout << ":(" << "\n";
    else cout << "Yay!" << "\n";

    return 0;
}


#include<iostream>
using namespace std;

int main()
{
	int d;
	while (cin >> d) {
		int sum = 0;
		for (int i = d; i <= 600 - d; i += d) {
			sum += (d*i*i);
		}
		cout << sum << endl;
	}
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

static vector<int> P={2};
template<class T>
T next_prime(T x){
    int size=P.size();

    if(x<P[size-1]){
        int begin=0,end=size;
        while(end-begin>1){
            int c=(begin+end)/2;
            if(x<P[c]){
                end=c;
            }else{
                begin=c;
            }
        }
        return P[begin];
    }

    T res=P[size-1];
    while(true){
        res++;
        bool prime=true;
        for(int i=0;i<size;i++){
            if(P[i]<=sqrt((double)res)){
                if(res%P[i]==0){
                    prime=false;
                    break;
                }
            }else{
                break;
            }
        }

        if(prime){
            P.push_back(res);
            size++;
            if(res>x){
                break;
            }
        }
    }

    return res;
}

template<class T>
bool prime(T x){
    if(x==next_prime(x-1)) return true;
    return false;
}

int N;
vector<int> a;

int main(){
    cin>>N;

    int prev=1;
    while(N!=0){
        int p=next_prime(prev);
        if(p%10==1){
            a.push_back(p);
            N--;
        }
        prev=p;
    }

    repr(e,a) cout<<e<<' ';
    cout<<endl;
}


#include <bits/stdc++.h>

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main() {
    int n,x;cin >>n>>x;
    vector<int>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    sort(all(a));
    ll sum=0;
    int ans=0;
    for (int i = 0; i < n; ++i) {
        sum+=a[i];
        if(sum<=x){
            ans++;
        }
    }
    if(sum<x){
        ans--;
    }
    cout <<ans <<endl;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long  N, K;
vector<long long> x;

long long calcTime(int i, int k){
	if(k <= 1) return 0;

	long long rt = (1L<<61), lt = (1L<<61);

	int Rk = N - i - 1; //x[i]より右にある本数
	int Lk = i;         //x[i]より左にある本数

	//右に行ってから左へ
	for(int j = K - i - 1; j <= Rk; j++){
		if(i + j >= N || j < 0) continue;
		long long t = x[i + j] - x[i]; //右の端までの時間
		t *= 2; //x[i]まで戻ってくる
		t += x[i] - x[i - (K - j - 1)];//左の端まで
		if(t < rt) rt = t;
	}

	//左に行ってから右へ
	for(int j = K- N + i; j <= Lk; j++){
		if(i < j || j < 0) continue;;
		long long t = x[i] - x[i - j]; //左の端までの時間
		t *= 2; //x[i]まで戻ってくる
		t += x[i + (K - j - 1)] - x[i];//右の端まで
		if(t < lt) lt = t;
	}
	return (long long) min(rt, lt);
}

int main(int argc, char* argv[]){
	cin >> N >> K;
	for(int i=1; i<=N; i++){
		long long u;
		cin >> u;
		x.push_back(u);
	}
	//入力はソート済だが念のためソートする
	sort(x.begin(), x.end());

	long long ans = 0;
	if(x[0] >= 0){
		ans = (long long)abs(x[K-1]);
		printf("%lld\n", ans);
		return 0;
	}
	else if(x[N-1] <= 0){
		ans = (long long)abs(x[N-K]);
		printf("%lld\n", ans);
		return 0;
	}
	int a, b;
	for(int i=0; i<N; i++){
		if(x[i] > 0){ break; }
		a = i;
	}
	for(int i=N-1; i>=0; i--){
		if(x[i] < 0){ break; }
		b = i;
	}
	long long ans_a = abs(x[a]) + calcTime(a, K);
	long long ans_b = abs(x[b]) + calcTime(b, K);
	ans = min( ans_a, ans_b);
	printf("%lld\n", ans);
	return 0;
}


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-12;
const double INF = 1e12;

int main(){
	int N,M;
	while(cin>>N>>M){
		int d[501][501];
		REP(i,501)REP(j,501)d[i][j]=1000000;
		if(N==0&&M==0)break;
		REP(i,M){
			int a,b;
			cin>>a>>b;
			a--;b--;
			d[a][b]=1;d[b][a]=1;
		}
		REP(k,N){
			REP(i,N){
				REP(j,N)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
		int res=0;
		FOR(i,1,N)if(d[0][i]<=2)res++;
		cout<<res<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string n;
    cin >> n;
    int len = n.size();
    vector<ll> tmp(2);
    vector<vector<ll>> bill(len, tmp);
    bill[0][0] = n[len-1] - '0';
    bill[0][1] = 10 - (n[len-1] - '0');
    rep2(i, 1, len){
      int x = n[len - 1 - i] - '0';
      bill[i][0] = min(bill[i - 1][0] + x, bill[i-1][1] + x + 1);
      bill[i][1] = min(bill[i-1][0] + 10 - x, bill[i-1][1] + 9 - x);
    }
    cout << min(bill[len-1][0], bill[len-1][1]+1) << endl;
    return 0;
}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
wGraph InputWGraph(ll N,ll M){
    wGraph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        G[a].push_back(make_pair(b,c));
        G[b].push_back(make_pair(a,c));
    }
    return G;
}
wGraph InputDWGraph(ll N, ll M){
    wGraph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        G[a].push_back(make_pair(b,c));
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

void OutputGraph(wGraph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j].first <<"/" << G[i][j].second << ",";
        }
        cout << endl;
    }
}

void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    string N;
    cin >> N;
    ll digit = N.size();
    vector<vector<ll>>memo(2);
    for (int yi = 0; yi < 2; ++yi) {
        memo[yi] = vector<ll>(digit);
        for (int xi = 0; xi < digit; ++xi) {
            memo[yi][xi] = (1ll << 50);
        }
    }
    ll first = N[0] - '0';
    memo[0][0] = min(11 - first,first);
    memo[1][0] = min(11 - first - 1,first + 1);

    for (int i = 1; i < digit; ++i) {
        ll num = N[i] - '0';
        memo[0][i] = min(memo[0][i-1] + num,memo[1][i-1] + (10 - num));
        memo[1][i] = min(memo[0][i-1] + num + 1,memo[1][i-1] + (10 - num - 1));
    }
    cout << (memo[0][digit-1]) << endl;
}


#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100000
#define LL long long
using namespace std;
int n,m,v,p,a[N+5];LL s[N+5];
I bool cmp(CI x,CI y) {return x>y;}//从大到小排序
int main()
{
	RI i;for(scanf("%d%d%d%d",&n,&m,&v,&p),i=1;i<=n;++i) scanf("%d",a+i);
	for(sort(a+1,a+n+1,cmp),i=1;i<=n;++i) s[i]=s[i-1]+a[i];//排序后求前缀和
	for(i=n;i>p;--i) if(a[i]+m>=a[p])//枚举答案，首先要使得加上m后大于等于第p个数
		if(1LL*max(v-p-(n-i),0)*m<=1LL*(a[i]+m)*(i-p)-(s[i-1]-s[p-1])) break;//用1去填平中间的坑
	return printf("%d",i),0;//输出答案（若始终没break则最后i恰好等于p）
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	ll N,M,K,P; cin >> N >> M >> K >> P;
	V<ll> A(N); rep(i,N) cin >> A[i];
	sort(all(A),greater<ll>());

	auto can = [&](int i){
		if(i<P) return true;
		ll t = A[i]+M;
		ll f = 0;
		for(int j=P-1;j<N;j++) if(j != i){
			if(t < A[j]) return false;
			f += min(t-A[j],M);
		}
		return f >= M*(K-P);
	};
	int lb = -1, ub = N;
	while(ub-lb>1){
		int m = (lb+ub)/2;
		if(can(m)) lb = m;
		else ub = m;
	}
	cout << lb+1 << endl;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e9+7;

int main(){
    ll x,y;
    cin >> x >> y;
    if(x<=y){
        if(x<0 && y>0 && abs(y)>=abs(x)){
            cout << 1+y+x << endl;
        }
        else if(x<0 && y>0 && abs(y)<abs(x)){
            cout << 1-y-x << endl;
        }
        else{
            cout << y-x << endl;
        }
    }
    else{
        if(x>0 && y>=0){
            cout << min(1LL+x+y,2LL+x-y) << endl;
        }
        else if(x>0 && y<0 && abs(x)>=abs(y)){
            cout << 1+x+y << endl;
        }
        else if(x>0 && y<0 && abs(x)<abs(y)){
            cout << 1-x-y << endl;
        }
        else if(x==0){
            cout << 1-y << endl;
        }
        else{
            cout << 2+x-y << endl;
        }
    }
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << a - b + 1 << endl;
}


#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  if(s.size() == 2) {
    cout << s << endl;
  }
  else if(s.size() == 3) {
    for(int i = 2; i > -1; i--) {
      cout << s[i];
    }
    cout << endl;
  }
  return 0;
}

#include <iostream>
#include <vector>

int main() {
    std::vector<int> arr;
    int len, num = 0;
    std::cin >> len;
    for(int i = 0; i < len; i++) {
        std::cin >> num;
        arr.push_back(num);
    }
    for(int i = len-1; i >= 0; i--) {
        std::cout << arr[i];
        if(i != 0) std::cout << " ";
    }
    std::cout << std::endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int w,h,sy,sx,gx,gy,n;
int color;
int c,d,x,y;
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
int maps[105][105];
int mem[105][105];
int dfs(int nowx,int nowy);
main(){
  while(1){
    cin>>w>>h;
    if(w==0&&h==0)break;
    cin>>sx>>sy>>gx>>gy;
    cin>>n;
    memset(maps,0,sizeof(maps));
    memset(mem,0,sizeof(maps));
    for(int i=0;i<n;i++){
      cin>>c>>d>>x>>y;
      for(int i=0;i<4;i++){
	if(d==0){
	  maps[y][x+i]=c;
	  maps[y+1][x+i]=c;
	}
	else{
	  maps[y+i][x]=c;
	  maps[y+i][x+1]=c;
	}
      }
    }
    /*
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	cout<<maps[i][j]<<" ";
      }
      cout<<endl;
    }
    */
    color=maps[sy][sx];
    if(dfs(sx,sy)==1){
      cout<<"OK"<<endl;
    }
    else{
      cout<<"NG"<<endl;
    }
  }
}
int dfs(int nowx,int nowy){
  int check=0;
  if(nowx==gx&&nowy==gy){
    return 1;
  }
  else{
    for(int i=0;i<4;i++){
      if(nowx+dx[i]>=1&&nowx+dx[i]<=w&&nowy+dy[i]>=1&&nowy+dy[i]<=h&&maps[nowy+dy[i]][nowx+dx[i]]==color&&mem[nowy+dy[i]][nowx+dx[i]]==0){
	mem[nowy+dy[i]][nowx+dx[i]]=1;
	check=max(dfs(nowx+dx[i],nowy+dy[i]),check);
      }
    }
    return check;
  }
}

#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

struct edge{int to, cost;};
const int MAX_M = 2e5 + 5, INF = 1e5;
int N, M, d[MAX_M * 3];
vector<edge> G[MAX_M * 3];
map<P, int> f;

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> pq;
    fill(d, d+MAX_M*3, INF); d[s] = 0;
    pq.push(P(0, s));

    while(pq.size()){
        P p = pq.top(); pq.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        for(auto e : G[v]){
            if(d[v]+e.cost<d[e.to]){
                d[e.to] = d[v] + e.cost;
                pq.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
    cin >> N >> M;
    f[P(1, 0)] = 0; f[P(N, 0)] = 1;
    int cnt = 2;
    for(int i=0;i<M;i++){
        int p, q, c; cin >> p >> q >> c;

        auto it1 = f.find(P(p, c)), it2 = f.find(P(q, c));
        if(it1 == f.end()) f[P(p, c)] = cnt++;
        if(it2 == f.end()) f[P(q, c)] = cnt++;
        edge e1; e1.to = f[P(q, c)]; e1.cost = 0;
        edge e2; e2.to = f[P(p, c)]; e2.cost = 0;
        G[f[P(p, c)]].push_back(e1); G[f[P(q, c)]].push_back(e2);

        auto it3 = f.find(P(p, 0)), it4 = f.find(P(q, 0));
        if(it3 == f.end()) f[P(p, 0)] = cnt++;
        if(it4 == f.end()) f[P(q, 0)] = cnt++;
        edge e3; e3.to = f[P(p, 0)]; e3.cost = 0;
        edge e4; e4.to = f[P(q, 0)]; e4.cost = 0;
        G[f[P(p, c)]].push_back(e3); G[f[P(q, c)]].push_back(e4);

        edge e5; e5.to = f[P(p, c)]; e5.cost = 1;
        edge e6; e6.to = f[P(q, c)]; e6.cost = 1;
        G[f[P(p, 0)]].push_back(e5); G[f[P(q, 0)]].push_back(e6);
    }

    dijkstra(f[P(1, 0)]);

    if(d[f[P(N, 0)]] == INF) cout << -1 << endl;
    else cout << d[f[P(N, 0)]] << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, bool>>> shougen(n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        for (int j = 0; j < a.at(i); j++) {
            int x;
            bool y;
            cin >> x >> y;
            shougen.at(i).push_back(make_pair(x, y));
        }
    }

    int cnt_max = 0;
    for (int i = 0; i < (1 << n); i++) {
        bitset<15> s(i);
        bool flag = true;
        for (int j = 0; j < n; j++) {
            if (s.test(j)) {
                for (int k = 0; k < a.at(j); k++) {
                    if (s.test(shougen.at(j).at(k).first - 1) !=
                        shougen.at(j).at(k).second) {
                        flag = false;
                        break;
                    }
                }
                if (flag == false) {
                    break;
                }
            }
        }
        if (flag == true) {
            cnt_max = (cnt_max > (int)s.count()) ? cnt_max : (int)s.count();
        }
    }
    cout << cnt_max << endl;
    return 0;
}

//----------------------Shanu Garg here---------------------
//-------------Search on youtube : Shanu Garg---------------
//-Studying at National Institute of Technology Delhi(NITD)-
//---------------------From Delhi, India--------------------

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

#define f(i,n) for(auto i=0;i<n;i++)
#define fr(i,n) for(auto i=n-1;i>=0;i--)
#define fs(i,a,b,c) for(auto i=a;i!=b;i+=c)
#define fl(i,x) for(auto i : x)
#define memset(a,first,last,val) fs(i,first,last,1) a[i]=val
#define nl cout<<"\n";
#define chk(x) cout<<#x<<x<<" ", nl
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vvi vector<vi>
#define pr pair<ll, ll>
#define vii vector<pair<int, int>>
#define vll vector<pr>
#define vl vector<ll>
#define m(a,b) map<a, b>
#define mid(a,b) ((a+b)/2)
#define pb push_back
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;

vl vb;
int N;

class triplet{ll f, s, t;};

vl in(ll n){
    vl ar;
    ll x;
    f(i,n)
    cin>>ar[i];
    return ar;
}
vll in_pr(ll n){
    vll ar;
    ll x,y;
    f(i,n)
    {cin>>x>>y;
    ar[i]={x,y};
    }return ar;
}
void out(vl v, char ch='\0'){
    fl(i,v)
    cout<<i<<ch;
}

void printArray(vector<int> arr, int n)
{
    ll num=0;
    for (int i = 0; i < n; i++)
    num*=10, num+=i;

    if(n==N)
    vb.pb(num);

}

int printfactorialof(int n){
    if(n<=1)
        return 1;

    return n*printfactorialof(n-1);
}

void solve(){
    ll a,b;
    cin>>a>>b;
    if(a+b <= 16){
        if(a<=8 && b<=8)
            cout<<"Yay!",nl
        else
        {
            cout<<":(",nl
        }

    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
   return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

using Edges = std::vector<std::vector<int>>;

void dfs1(int i, const Edges& edges, std::vector<int>& ans, std::vector<bool>& memo) {
    memo[i] = true;
    for(auto v: edges[i]) {
        if(!memo[v]) dfs1(v, edges, ans, memo);
    }
    ans.push_back(i);
}

void dfs2(int i, const Edges& redges, std::vector<int>& ans, int cnt) {
    ans[i] = cnt;
    for(auto v: redges[i]) {
        if(ans[v] < 0) dfs2(v, redges, ans, cnt);
    }
}

int main() {
    int V, E;
    std::cin >> V >> E;
    Edges edges(V);
    Edges redges(V);
    while(E--){
        int s, t;
        std::cin >> s >> t;
        edges[s].push_back(t);
        redges[t].push_back(s);
    }
    std::vector<bool> memo(V, false);
    std::vector<int> topoSorted;
    topoSorted.reserve(V);
    for(int i = 0; i < V; ++i) {
        if(!memo[i])dfs1(i, edges, topoSorted, memo);
    }

    std::vector<int> ans(V, -1);
    int cnt = 0;
    for(auto itr = rbegin(topoSorted); itr != rend(topoSorted); ++itr) {
        if(ans[*itr] < 0) dfs2(*itr, redges, ans, cnt++);
    }

    int Q;
    std::cin >> Q;
    while(Q--) {
        int u, v;
        std::cin >> u >> v;
        std::cout << (ans[u] == ans[v]) << '\n';
    }
    std::cout << std::flush;

    return 0;
}

#include <string.h>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <map>
#include <vector>

using namespace std;

const int MAXV = 10010;

struct Edge {
  int u;
  int v;

  Edge(int u, int v): u(u), v(v) {}
};

int v, e, source = 0, dfs_clock = 0, scc_count = 0;
vector<int> g[MAXV];
int pre[MAXV] = {0};
int low[MAXV] = {0};
map<int, int> scc_v_to_no;
vector<int> scc_no_to_v[MAXV];
stack<int> s;

void DFS(int u) {
  int child_num = 0;
  ++dfs_clock;
  pre[u] = dfs_clock;
  low[u] = dfs_clock;
  s.push(u);
  for (int v: g[u]) {
    if (!pre[v]) {
      DFS(v);
      low[u] = min(low[u], low[v]);
    } else if (scc_v_to_no.find(v) == scc_v_to_no.end()) {
      low[u] = min(low[u], pre[v]);
    }
  }
  if (low[u] == pre[u]) {
    while (1) {
      auto x = s.top();
      s.pop();
      scc_v_to_no.emplace(x, scc_count);
      scc_no_to_v[scc_count].push_back(x);
      if (x == u) {
        ++scc_count;
        break;
      }
    }
  }
}

void SCC() {
  for (int i = 0; i < v ; ++i) {
    if (!pre[i]) {
      DFS(i);
    }
  }
}

int main() {
  scanf("%d %d", &v, &e);
  for (int i = 0; i < e; ++i) {
    int s, t;
    scanf("%d %d", &s, &t);
    g[s].push_back(t);
  }

  SCC();

  int q;
  scanf("%d\n", &q);
  for (size_t i = 0; i < q; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", scc_v_to_no.at(a) == scc_v_to_no.at(b));
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++)
    cin >> A[i];

  bool f = 0;

  int count = 0;
  while(1){
  	for (int i = 0; i < N; i++){
       if(A[i] % 2 == 0){
          A[i] = A[i] / 2;
       }else{
         f= 1;
       }
    }
    if(f == 1)
      break;
    count++;
  }

  cout << count << endl;
}

#include<bits/stdc++.h>

using namespace std;
typedef         long long int   ll;

#define         input           freopen("input.txt","r",stdin)
#define         output          freopen("output.txt","w",stdout)
#define         si(a)           scanf("%d",&a)
#define         sii(a,b)        scanf("%d%d",&a,&b)
#define         siii(a,b,c)     scanf("%d%d%d",&a,&b,&c)
#define         pi(a)           printf("%d",a)
#define         spc             printf(" ")
#define         bl              printf("\n")
#define         here(a)         printf("#### %d ####",a)
#define         pii             pair<int,int>
#define         fr(i,n)         for(int i=0;i<n;i++)
#define         case(num)       printf("Case %d:",num)
#define         inf             1000000050
#define         MAX             10010
#define         MOD             1000000007

vector<int>edge;
vector<vector<int> >triangle;
void npr(vector<int>v, int p){

    if(v.size()==3){
        triangle.push_back(v);
        //for(int i=0;i<v.size();i++) cout<<v[i]<<" ";
        //cout<<endl;
        return;
    }
    if(p>=edge.size()) return;
    npr(v,p+1);
    v.push_back(edge[p]);
    npr(v,p+1);
    v.pop_back();
}

int main(){

    //input;
    //output;

    int n,tmp;
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>tmp;
        edge.push_back(tmp);
    }

    vector<int>v;

    npr(v,0);
    int a,b,c;
    int cnt = 0;

    for(int i=0;i<triangle.size();i++){
        sort(triangle[i].begin(),triangle[i].end());
        a = triangle[i][0];
        b = triangle[i][1];
        c = triangle[i][2];
        if(a!=b && a!=c && b!=c){
            if(a+b>c) cnt++;
        }
    }

    cout<<cnt<<endl;

    return 0;
}
/**
*/


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll K, X;
    cin >> K >> X;
    rep2(i, X - K + 1, X + K) cout << i << endl;
    return 0;
}

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

int main() {
    int a,b,i,n;
    cin>>a>>b;

    n=((a*2)-1)/2;
    for(i=0;i<n;i++)
    {
        a--;
        cout<<b-a<<" ";
    }
    cout<<b<<" ";
    a=0;
    for(i=n+1;i<2*n+1;i++)
    {
        a++;
        cout<<b+a<<" ";
    }
    return 0;
}