#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n, count = 1;
    double total = 0;
    bool same = 1;

    cin >> n;

    double t[n], leng = n;

    for(int i = 0; i < n; i++){
        cin >> t[i];
        total += t[i];
    }

    sort(t, t + n);

    for(int i = 1; i < n; i++){
        if(t[i] == 1){
            i++;
            continue;
        }

        if(t[i - 1] == t[i]){
            count++;
            continue;
        }

        else{
            if(t[i - 1] != 1){
                same = 0;
                break;
            }
        }
    }

    if(n == 1)
        cout << t[0] << endl;

    else if(n == 2)
        cout << max(t[0], t[1]) << endl;

    else{
        if(count == n){
            cout << t[0] * ceil(leng/2) << endl;
        }

        else if(same && (count % 2) && t[n - 1] != 1)
            cout << ceil(total/2) + 1 << endl;

        else
            cout << ceil(total/2) << endl;
    }

    return 0;
}

#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; debug_print(__VA_ARGS__); } while(false)
template<typename T, typename... Ts> void debug_print(const T &t, const Ts &...ts) { cerr << t; ((cerr << ", " << ts), ...); cerr << endl; }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, const T& b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, const T& b) { if (a < b) {a = b; return true; } return false; }
template<typename T, typename... Ts> void print(const T& t, const Ts&... ts) { cout << t; ((cout << ' ' << ts), ...); cout << '\n'; }
template<typename... Ts> void input(Ts&... ts) { (cin >> ... >> ts); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

template<ll MOD = 1000000007>
class ModInt {
    ll n;
    ModInt constexpr inverse() const {
        return ModInt::pow(*this, MOD - 2);
    }

public:
    ModInt() : n(0) {}
    ModInt(ll _n) : n(((_n % MOD) + MOD) % MOD) {}
    ModInt operator+=(const ModInt &m) {
        n += m.n;
        if (n >= MOD) n -= MOD;
        return *this;
    }
    ModInt operator-=(const ModInt &m) {
        n -= m.n;
        if (n < 0) n += MOD;
        return *this;
    }
    ModInt operator*=(const ModInt &m) {
        n *= m.n;
        if (n >= MOD) n %= MOD;
        return *this;
    }
    ModInt operator/=(const ModInt &m) {
        (*this) *= m.inverse();
        return *this;
    }
    friend ModInt operator+(ModInt t, const ModInt &m) {
        return t += m;
    }
    friend ModInt operator-(ModInt t, const ModInt &m) {
        return t -= m;
    }
    friend ModInt operator*(ModInt t, const ModInt &m) {
        return t *= m;
    }
    friend ModInt operator/(ModInt t, const ModInt &m) {
        return t /= m;
    }
    ModInt operator=(const ll l) {
        n = l % MOD;
        if (n < 0) n += MOD;
        return *this;
    }
    friend ostream &operator<<(ostream &out, const ModInt &m) {
        out << m.n;
        return out;
    }
    friend istream &operator>>(istream &in, ModInt &m) {
        ll l;
        in >> l;
        m = l;
        return in;
    }
    static constexpr ModInt pow(const ModInt x, ll p) {
        ModInt<MOD> ans = 1;
        for (ModInt<MOD> m = x; p > 0; p /= 2, m *= m) {
            if (p % 2) ans *= m;
        }
        return ans;
    }
    static constexpr ll mod() {
        return MOD;
    }
};
using mint = ModInt<998244353>;
mint operator"" _m(unsigned long long m) {
    return mint(m);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    input(h, w);
    auto dp = make_v(h, w, '.');
    rep(i, 0, h) {
        rep(j, 0, w) {
            input(dp[i][j]);
        }
    }
    vector<int> r(h + w, 0), b(h + w, 0), q(h + w, 0);
    rep(i, 0, h) {
        rep(j, 0, w) {
            if (dp[i][j] == 'R') {
                r[i + j]++;
            } else if (dp[i][j] == 'B') {
                b[i + j]++;
            } else {
                q[i + j]++;
            }
        }
    }
    mint ans = 1;
    rep(i, 0, h + w) {
        if (r[i] > 0 && b[i] > 0) {
            ans = 0;
        } else if (q[i] > 0 && (r[i] == 0 && b[i] == 0)) {
            ans *= 2;
        }
    }
    print(ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <fstream>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define x first
#define y second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cerr << #x << ": " << x << '\n';
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define FORN(i, n) for (int i = 1; i <= n; ++i)
#define pb push_back
#define trav(a, x) for (auto& a : x)
using vi = vector<int>;
template <typename T>
std::istream& operator >>(std::istream& input, std::vector<T>& data)
{
    for (T& x : data)
        input >> x;
    return input;
}
template <typename T>
std::ostream& operator <<(std::ostream& output, const pair <T, T> & data)
{
    output << "(" << data.x << "," << data.y << ")";
    return output;
}
template <typename T>
std::ostream& operator <<(std::ostream& output, const std::vector<T>& data)
{
    for (const T& x : data)
        output << x << " ";
    return output;
}
ll div_up(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll div_down(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down
ll math_mod(ll a, ll b) { return a - b * div_down(a, b); }
#define tcT template<class T
#define tcTU tcT, class U
tcT> using V = vector<T>;
tcT> void re(V<T>& x) {
    trav(a, x)
        cin >> a;
}
tcT> bool ckmin(T& a, const T& b) {
    return b < a ? a = b, 1 : 0;
} // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
ll gcd(ll a, ll b) {
    while (b) {
        tie(a, b) = mp(b, a % b);
    }
    return a;
}
signed main() {
    #ifdef LOCAL
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    vi a(2 * n);
    cin >> a;
    vi sign(2 * n);
    V <ii> ord;
    FOR (i, 2 * n) {
        ord.app(mp(a[i], i));
    }
    sort(all(ord));
    FOR (i, n) {
        sign[ord[i].y] = -1;
    }
    FOR (i, n) {
        sign[ord[i + n].y] = 1;
    }
    string ans;
    vi S;
    trav (e, sign) {
        if (S.empty() || S.back() == e) {
            ans += '(';
            S.app(e);
        }
        else {
            ans += ')';
            S.pop_back();
        }
    }
    assert(S.empty());
    cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100010];
ll tong[10];
int jud(string s,string t){
    int tt[10]={0},ss[10]={0};
    int i;
    for(i=0;i<5;i++)ss[s[i]-'0']++;
    for(i=0;i<5;i++)tt[t[i]-'0']++;
    ll sums=0,sumt=0;
    for(i=1;i<=9;i++){
        sums+=pow(10,ss[i])*i;
        sumt+=pow(10,tt[i])*i;
    }
    return sums>sumt;
}
int main(){
    ll n,i,j,k,_=1;
  //  cin>>_;
    cin>>k;
    for(i=1;i<=9;i++)tong[i]=k;
    ll cnt=0,all=0;
    string s,t;
    cin>>s>>t;
    for(i=0;i<4;i++){
        tong[s[i]-'0']--;
        tong[t[i]-'0']--;
    }
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            if(!tong[i]||!tong[j]||tong[i]+tong[j]<2)continue;
            ll temp;
            if(i!=j)temp=tong[i]*tong[j];
            else temp=tong[i]*tong[i]-tong[i];
            all+=temp;
            s[4]='0'+i,t[4]='0'+j;
            if(jud(s,t))cnt+=temp;
        }
    }
    printf("%.7f",cnt*1.0/all);

}


#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 998244353
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int h,w;
ll dp[5555][5555];
int k;
char c[5555][5555];
ll inv;
int main()
{
	ios::sync_with_stdio(0);
	inv=quickpower(3,mod-2);
	inv%=mod;
	cin>>h>>w>>k;
	rep(i,h+1)rep(j,w+1)c[i][j]='N';
	rep(i,k)
	{
		int x,y;
		char op;
		cin>>x>>y>>op;
		c[x][y]=op;
	}
	dp[1][1]=1;
	forn(i,1,h)
	{
		forn(j,1,w)
		{
			if(c[i-1][j]=='D'||c[i-1][j]=='X')dp[i][j]+=dp[i-1][j];
			if(c[i-1][j]=='N')dp[i][j]+=dp[i-1][j]*2*inv;
			dp[i][j]%=mod;
			if(c[i][j-1]=='R'||c[i][j-1]=='X')dp[i][j]+=dp[i][j-1];
			if(c[i][j-1]=='N')dp[i][j]+=dp[i][j-1]*2*inv;
			dp[i][j]%=mod;
		}
	}
	cout<<(dp[h][w]*quickpower(3,h*w-k))%mod<<endl;
	return 0;
}


#include<bits/stdc++.h>

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

int main(){
    int m, n;
    cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> used(n);
    set<int> unused;
    for(int i = 0; i <= n; i++){
        unused.insert(i);
    }
    for(int i = 0; i < m; i++){
        used[a[i]]++;
        if(used[a[i]] == 1){
            unused.erase(a[i]);
        }
    }
    int mem = *unused.begin();
    for(int i = m; i < n; i++){
        used[a[i - m]]--;
        if(used[a[i - m]] == 0){
            unused.insert(a[i - m]);
        }
        used[a[i]]++;
        if(used[a[i]] == 1){
            unused.erase(a[i]);
        }
        mem = min(mem, *unused.begin());
    }
    cout << mem << endl;
    return 0;
}

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

#define ll long long
#define ull unsigned ll
#define pi pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vs vector<string>
#define vvi vector<vi>
#define ff first
#define ss second
#define pb push_back
#define vpi vector<pi>
#define vpll vector<pll>
#define umap unordered_map
#define uset unordered_set
#define all(x) x.begin(),x.end()
#define fr(i,j,n) for(int i=j;i<n;++i)
#define rfr(i,j,n) for(int i=j; i>=n;--i)
#define MOD 1000000007
#define INF INT_MAX
#define LINF LONG_LONG_MAX
#define mp make_pair
#define endl "\n"
#define sz  size()
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

void solve(){
    int n,m;
    cin>>n>>m;
    vi arr(n);
    vvi pos(n+1);
    fr(i,0,n+1){
        // cin>>arr[i-1];
        pos[i].pb(-1);
    }
    fr(i,0,n){
        cin>>arr[i];
        pos[arr[i]].pb(i);
    }
    fr(i,0,n+1){
        // cin>>arr[i-1];
        pos[i].pb(n);
    }
    fr(i,0,n+1){
        fr(j,1,pos[i].sz){
            if(pos[i][j]-pos[i][j-1]>m){
                cout<<i<<endl;
                return;
            }
        }
    }

}

void pre() {
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
        // cout<<solve()<<endl;
    }
}

int main() {
	fastIO;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	pre();
	return 0;

}


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

vector<int> v(200, -1);

void print_answer(int x)
{
  int cnt = 0;
  vector<int> t;
  for (int i = 0; i < 20; ++i)
  {
    if (x & (1 << i))
    {
      t.push_back(i + 1);
      cnt++;
    }
  }
  cout << cnt << " ";
  for (int d : t) cout << d << " ";
  cout << endl;
}

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,0,n-1) cin >> a[i];
  rep(i,0,n-1) a[i] %= 200;
  int m = min(n, 20);
  int x = -1, y = -1;
  for (int i = 1; i < (1 << m); ++i)
  {
    int p = 0;
    for (int j = 0; j < m; ++j)
    {
      if (i & (1 << j))
      {
        p = (p + a[j]) % 200;
      }
    }
    if (v[p] == -1)
      v[p] = i;
    else
    {
      x = v[p], y = i;
      break;
    }
  }

  if (x == -1)
    cout << "No" << endl;
  else
  {
    cout << "Yes" << endl;
    print_answer(x);
    print_answer(y);
  }

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cerr<<#x<<"="<<x<<","
#define de(x) cerr<<#x<<"="<<x<<endl
//-------

const int N = 201;
int n, a[N], dp[N][N][4];
pair<int, int> go[N][N][4];

pair<vector<int>, vector<int>> gao() {
	vector<int> B, C;
	per(K, 1, 4) if (dp[n][0][K]) {
		for (int i = n, j = 0, k = K; i > 0; --i) {
			int pk, op; tie(pk, op) = go[i][j][k];
			if (-1 == op) {
				C.emplace_back(i);
				j = (j + a[i]) % 200;
			} else if (1 == op) {
				B.emplace_back(i);
				j = ((j - a[i]) % 200 + 200) % 200;
			}
			k = pk;
		}
		if (K == 3) return {B, C};
		if (B.size() == n || C.size() == n) {
			B.clear(), C.clear();
			return {B, C};
		}
		if (B.empty() || C.empty()) {
			vector<bool> used(n + 1, false);
			for (auto p : B) used[p] = true;
			for (auto p : C) used[p] = true;
			rep(p, 1, n + 1) if (!used[p]) {
				B.emplace_back(p);
				C.emplace_back(p);
				break;
			}
		}
		return {B, C};
	}
	return {B, C};
}

int main() {
	scanf("%d", &n);
	rep(i, 1, n + 1) {
		scanf("%d", a + i);
		a[i] %= 200;
	}

	rep(i, 0, n + 1) rep(j, 0, 200) rep(k, 0, 4)
		dp[i][j][k] = false;

	dp[0][0][0] = true;

	rep(i, 0, n) {
		rep(j, 0, 200) rep(k, 0, 4) if (dp[i][j][k]) {
			dp[i + 1][j][k] = true;
			go[i + 1][j][k] = {k, 0};
		}
		rep(j, 0, 200) rep(k, 0, 4) {
			if (0 == dp[i][j][k])
				continue;
			int ni = i + 1, nj, nk;
			// add Ai
			nj = (j + a[ni]) % 200, nk = k | 2;
			if (0 == dp[ni][nj][nk]) {
				dp[ni][nj][nk] = true;
				go[ni][nj][nk] = {k, 1};
			}
			// minus Ai
			nj = ((j - a[ni]) % 200 + 200) % 200, nk = k | 1;
			if (0 == dp[ni][nj][nk]) {
				dp[ni][nj][nk] = true;
				go[ni][nj][nk] = {k, -1};
			}
		}
	}
	vector<int> B, C;
	tie(B, C) = gao();
	if (B.empty() || C.empty()) {
		puts("No");
	} else {
		sort(B.begin(), B.end());
		sort(C.begin(), C.end());

		puts("Yes");
		printf("%d", B.size());
		for (auto b : B) printf(" %d", b);
		puts("");
		printf("%d", C.size());
		for (auto c : C) printf(" %d", c);
		puts("");

	}

	return 0;
}


#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

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

	int N;
	cin >> N;
	vector<pair<int, string>> V(N);

	rep(i, N) {
		cin >> V[i].second >> V[i].first;
	}

	sort(V.begin(), V.end());

	cout << V[N - 2].second << endl;

	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	ll now = 0, s = 0, mx = 0;
	ll ans = 0;
	rep(i, n) {
		s += a[i];
		mx = max(mx, s);
		ans = max(ans, now + mx);
		now += s;
	}
	cout << ans << endl;
	return 0;
}


/*****************************
*  Author :: Πρασαννα Κ. Ροι  *
*****************************/

/***********************************
* Unus pro omnibus, omnes pro uno  *
***********************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using namespace std::chrono;

#define __AcHiLlEs ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __AnAkLuSmOs freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define int long long
#define span(a) begin(a), end(a)

template<typename t>
using vc = vector<t>;

vc<vc<int>> gph1;
vc<vc<int>> d, dp;
unordered_map<int, int> id;
int cnt(0);

void bfs(int u, int n) {
    queue<int> q;
    vc<int> dist(n + 1, -1);
    dist[u] = 0;
    q.push(u);
    while (!q.empty()){
        int v = q.front();
        q.pop();
        for (auto &i: gph1[v]) if (dist[i] == -1) {
            dist[i] = dist[v] + 1;
            q.push(i);
        }
    }
    for (int i = 1; i <= n; i++) if (id[i])
        d[id[u]][id[i]] = d[id[i]][id[u]] = dist[i];
}

int compute(int u, int vis, int k) {
    int res(1e18);
    if (vis == (1 << k) - 1) return 0;
    if (~dp[u][vis]) return dp[u][vis];

    dp[u][vis] = 0;
    for (int i = 0; i < k; i++) if (!(vis & (1 << i)))
        res = min(res, compute(i + 1, vis | (1 << i), k) + d[u][i + 1]);
    return dp[u][vis] = res;
}

void solve() {
    id.reserve(1 << 20);
    id.max_load_factor(0.25);
    int n, m, x, y;
    cin >> n >> m;
    gph1.assign(n + 1, vc<int>());
    for (int i = 0; i < m; i++) cin >> x >> y, gph1[x].push_back(y), gph1[y].push_back(x);
    int k, cnt(0);
    cin >> k;
    vc<int> a(k);
    d.assign(k + 1, vc<int>(k + 1, -1));
    for (auto &i: a) cin >> i, id[i] = ++cnt;
    if (k == 1) return void(cout << 1 << "\n");
    for (auto &i: a) bfs(i, n);
    for (int i = 1; i <= k; i++)
        for (int j = 1; j <= k; j++) if (d[i][j] == -1) return void(cout << -1 << "\n");
    dp.assign(k + 1, vc<int>(1 << k, -1));
    int res(LLONG_MAX);
    for(int i = 1; i <= k; i++)
        res = min(res, compute(i, 1 << (i - 1), k));
    cout << res + 1 << "\n";
}

signed main() {
    // auto start = high_resolution_clock::now();

    __AcHiLlEs

    int t(1);
    // cin >> t;
    for (int i = 1; i <= t; /*cout << "Case " << i << ": ",*/ solve(), i++);
    // auto stop = high_resolution_clock::now();
    // double duration = duration_cast<microseconds>(stop - start).count();
    // cout << fixed << setprecision(4) << duration / 1000000 << "\n";
    return 0;
}

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

int N,M, dist[1000000];
vector<int> lst[1000000];
vector< tuple<int,int,char> > A;
queue<int> q;
bitset<1000> bs[1000];

int main() {
    scanf("%d %d", &N, &M);
    for (int i = 0; i < M; ++i) {
        int u,v; char c; scanf(" %d %d %c", &u, &v, &c); u--, v--;
        bs[u][v] = bs[v][u] = true;
        for (auto x: A) {
            int a,b; char c1; tie(a,b,c1) = x;
            if (c == c1) {
                lst[u*N+a].push_back(v*N+b);
                lst[v*N+b].push_back(u*N+a);
                lst[a*N+u].push_back(b*N+v);
                lst[b*N+v].push_back(a*N+u);
                lst[u*N+b].push_back(v*N+a);
                lst[v*N+a].push_back(u*N+b);
                lst[b*N+u].push_back(a*N+v);
                lst[a*N+v].push_back(b*N+u);
            }
        }
        A.emplace_back(u,v,c);
    }
    memset(dist,-1,sizeof(dist));
    q.emplace(N-1);
    dist[N-1] = 0;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int v: lst[u]) if (dist[v] == -1) {
            dist[v] = dist[u] + 1;
            q.push(v);
        }
    }
    int ans = 2e9;
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) if (dist[i*N+j] != -1) {
        if (i == j) ans = min(ans, dist[i*N+j] * 2);
        if (bs[i][j]) ans = min(ans, dist[i*N+j] * 2 + 1);
    }
    if (ans == 2e9) ans = -1;
    printf("%d", ans);

    return 0;
}


#include <iostream>
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	int milk_solid=a+b;
	if (milk_solid>=15 && b>=8){
	    cout<<"1";
	}
	else if(milk_solid>=10 && b>=3 ){
	    cout<<"2";
	}
	else if(milk_solid>=3 && b>=0){
	    cout<<"3";
	}
	else{
	    cout<<"4";
	}
	return 0;
}

#include<bits/stdc++.h>
namespace gengar
{
	#pragma GCC optimize("Ofast")
	using namespace std;
	namespace TypeDef
	{
		#define int long long
		#define itn int
		#define uint unsigned long long
		using Int=int64_t;
		using uInt=uint64_t;
		#define ld long double
		#define P pair<int,int>
		#define vt(tp) vector<tp>
		#define vvt(nm,tp,h,w,n) vector<vector<tp>>nm((h),vector<tp>(w,n))
		#define vvp vector<vector<P>>
		#define hmap unordered_map
		#define hset unordered_set
		#define PQ priority_queue
	};
	namespace OthDef
	{
		#define all(x) x.begin(),x.end()
		#define nsort(x) sort(all(x))
		#define rsort(x) nsort(x);reverse(all(x))
		#define unq(v) v.erase(unique(all(v)),v.end())
		#define l_b(c,x) distance(c.begin(),lower_bound(all(c),(x)))
		#define u_b(c,x) distance(c.begin(),upper_bound(all(c),(x)))
		#define fi first
		#define se second
		#define mp make_pair
		#define pb push_back
		#define eb emplace_back
		#define spc ' '
		#define pass
		void CIN(){}
		template<typename Car,typename... Cdr>
		void CIN(Car&&car,Cdr&&...cdr){cin>>car;CIN(forward<Cdr>(cdr)...);}
		template<class T>void drop(T x){cout<<(x)<<endl;exit(0);}
		void dYes(){puts("Yes");exit(0);}
		void dNo(){puts("No");exit(0);}
		#define Bit(n) (1LL<<(n))
		#define Bitall(n,i) for(int bit=0;bit<(1<<(int)(n));bit++)for(int i=0;i<(int)(n);i++)
		#define Bitif(i) if(bit&(1<<i))
	};
	namespace RepDef
	{
		#define _overload3(_1,_2,_3,name,...) name
		#define _rep(i,n) repi(i,0,n)
		#define repi(i,a,b) for(int i=(a),__SIZE##_=(b);i<__SIZE##_;i++)
		#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
		#define rrep(i,n) for(int i=1,__SIZE##_=(n);i<__SIZE##_;i++)
		#define repp(i,n) for(int i=0,__SIZE##_=(n);i<=__SIZE##_;i++)
		#define per(i,n) for(int i=(n)-1;i>=0;i--)
		#define pper(i,n) for(int i=(n)-1;i>=1;i--)
		#define perr(i,n) for(int i=(n);i>=0;i--)
	};
	namespace MathDef
	{
		const int inf=Bit(60);
		const int pi=acos(-1);
		const int mod=1000000007;//998244353
		#define myceil(a,b) ((a)+((b)-1))/(b)
		#define scale(n) cout<<fixed<<setprecision(n)
		int gcd(int a,int b){return b?gcd(b,a%b):a;}
		int lcm(int a,int b){return a/gcd(a,b)*b;}
		int fact(int n){int f=n;pper(i,n){f*=i;f%=mod;}return f;}
		template<class T>int chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
		template<class T>int chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
	};
	namespace AllDef
	{
		using namespace TypeDef;
		using namespace OthDef;
		using namespace RepDef;
		using namespace MathDef;
	};
	using namespace AllDef;
};
using namespace gengar;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b;cin>>a>>b;
	if(a+b>=15&&b>=8)drop(1);
	else if(a+b>=10&&b>=3)drop(2);
	else if(a+b>=3)drop(3);
	else drop(4);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
  cerr << "[";
  for (auto e : aux) cerr << e << ' ';
  cerr << "]";
  return cerr;
}

const int maxN = 211;

int n;
int a[maxN], b[maxN];
bool used[maxN], sol[maxN];

void result(bool yes) {
  cout << (yes ? "Yes" : "No");
  exit(0);
}

bool canTile(int l, int r) {
  int full = r - l;
  int half = full / 2;

  for (int i = l; i < r; i++) used[i] = false;
  for (int i = 0; i < n; i++) {
    int posX = a[i];
    int posY = b[i];

    bool outX = (posX < l || posX >= r);
    bool outY = (posY < l || posY >= r);

    if (outX && outY) continue;
    if (outX ^ outY) {
      // one in one out
      if (posX != -1 && posY != -1) return false;

      if (posX != -1) {
        if (posX >= l + half) return false;
        if (used[posX] || used[posX + half]) return false;
        used[posX] = true;
        used[posX + half] = true;
      }

      if (posY != -1) {
        if (posY < l + half) return false;
        if (used[posY] || used[posY - half]) return false;
        used[posY] = true;
        used[posY - half] = true;
      }

    } else {
      // both in
      if (posX >= l + half || posY < l + half) return false;
      if (posY - posX != half) return false;
      if (used[posX] || used[posY]) return false;
      used[posX] = used[posY] = true;
    }
  }

  return true;
}

int main()
{
  //freopen("test.in", "r", stdin);

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] != -1 && b[i] != -1 && a[i] >= b[i])
      result(false);
  }

  sol[0] = true;
  for (int i = 0; i < 2 * n; i++) {
    if (!sol[i]) continue;

    for (int j = i + 2; j <= 2 * n; j += 2) {
      if (sol[j]) continue;
      sol[j] |= canTile(i + 1, j + 1);
    }
  }

  result(sol[2 * n]);

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
const int MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<pair<pair<ll,ll>, int>> py(N), px(N);
  for (int i = 0; i < N; i++) {
    int x, y;
    cin>>x>>y;
    py[i] = {{y, x}, i};
    px[i] = {{x, y}, i};
  }
  set<int> st;
  sort(py.begin(), py.end());
  sort(px.begin(), px.end());
  vector<pair<int,int>> kouho;
  if (st.find(py[0].second) == st.end()) {
    st.insert(py[0].second);
    kouho.push_back({py[0].first.second, py[0].first.first});
  }
  if (st.find(py[1].second) == st.end()) {
    st.insert(py[1].second);
    kouho.push_back({py[1].first.second, py[1].first.first});
  }
  if (st.find(py[N - 1].second) == st.end()) {
    st.insert(py[N - 1].second);
    kouho.push_back({py[N - 1].first.second, py[N - 1].first.first});
  }
  if (st.find(py[N - 2].second) == st.end()) {
    st.insert(py[N - 2].second);
    kouho.push_back({py[N - 2].first.second, py[N - 2].first.first});
  }
  if (st.find(px[0].second) == st.end()) {
    st.insert(px[0].second);
    kouho.push_back(px[0].first);
  }
  if (st.find(px[1].second) == st.end()) {
    st.insert(px[1].second);
    kouho.push_back(px[1].first);
  }
  if (st.find(px[N - 1].second) == st.end()) {
    st.insert(px[N - 1].second);
    kouho.push_back(px[N - 1].first);
  }
  if (st.find(px[N - 2].second) == st.end()) {
    st.insert(px[N - 2].second);
    kouho.push_back(px[N - 2].first);
  }
  vector<ll> ans;
  for (int i = 0; i < (int)kouho.size(); i++) {
    for (int j = i + 1; j < (int)kouho.size(); j++) {
      ans.push_back(max(abs(kouho[i].first - kouho[j].first), abs(kouho[i].second - kouho[j].second)));
    }
  }
  sort(ans.rbegin(), ans.rend());
  // for (int i = 0; i < (int)ans.size(); i++)  cout << ans[i] << " ";
  // cout << endl;
  cout << ans[1] << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define DONTSYNC ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL) //dont use stdio with iostream functions //input and output are out of order now!
#define TEST unsigned long long T; cin>>T; while(T--)  //loop over each testcase
#define endl "\n"
#define fori(a,start,end) for(int a=start;a<end;a++)
#define forl(a,start,end) for(long long a=start;a<end;a++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef long long     ll;
typedef long double   ld;
typedef pair<int,int> pii;
typedef pair<ll,ll>   pll;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vii;
typedef vector<pll>   vll;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
const double PI = acos(-1);

void solve(){
    /* code */
    int n; cin>>n;
    vll x(n),y(n);
    fori(i,0,n){
        cin>>x[i].fi>>y[i].fi;
        x[i].se=i; y[i].se=i;
    }
    sort(all(x)); sort(all(y));
    // vl res({abs(x[n-1]-x[0]),abs(x[n-2]-x[0]),abs(x[n-1]-x[1]),abs(y[n-1]-y[0]),abs(y[n-2]-y[0]),abs(y[n-1]-y[1])});
    vector<pair<ll,pll>> res;
    res.push_back({abs(x[n-1].fi-x[0].fi),{x[n-1].se,x[0].se}});
    res.push_back({abs(x[n-2].fi-x[0].fi),{x[n-2].se,x[0].se}});
    res.push_back({abs(x[n-1].fi-x[1].fi),{x[n-1].se,x[1].se}});
    res.push_back({abs(y[n-1].fi-y[0].fi),{y[n-1].se,y[0].se}});
    res.push_back({abs(y[n-2].fi-y[0].fi),{y[n-2].se,y[0].se}});
    res.push_back({abs(y[n-1].fi-y[1].fi),{y[n-1].se,y[1].se}});
    sort(all(res)); set<pll> ss;
    if(res[5].se.fi<res[5].se.se) ss.insert({res[5].se.fi,res[5].se.se});
    else ss.insert({res[5].se.se,res[5].se.fi});
    for(int i=5;~i;i--){
        auto [val,p]=res[i];
        if(p.fi>p.se) swap(p.fi,p.se);
        if(ss.find(p)!=ss.end()){
            continue;
        }else{
            cout<<val<<endl;
            return;
        }
    }
}

int main()
{
    DONTSYNC;
    // TEST
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define inf 1000000001
typedef long l;
typedef long long ll;
const ll INF = 1e18L + 5;
# define MOD 1000000007
# define PI 3.14
#define vi vector<int>
#define vl vector<l>
#define vll vector<ll>
#define pb push_back
#define pob pop_back
#define f first
#define s second
#define ml map<l,l>
#define mll map<ll,ll>
#define mcl map<char,ll>
# define umll unordered_map<ll,ll,custom_hash>
# define umcl unordered_map<char,l>
#define pll pair<ll,ll>
#define mp make_pair
# define forl(i,range) for(l i=0;i<range;i++)
# define forll(i,range) for(ll i=0;i<range;i++)
// int ans=upper_bound(start,end ,value)-start;
// auto itr=uper_bound(start,end ,value)-vector.begin();
// for (ll i = 0; i < s1.size() && j < s2.size(); i++) if (s1[i]==s2[j]) j++;//subsequence
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = std::chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll myceil(ll num,ll den)
{
    if ((num >= 0 and den > 0) or ( num <= 0 and den < 0))
        return num%den == 0 ? num/den : num/den + 1;
    return num / den;
}
ll myfloor(ll num,ll den)
{
    if ((num >= 0 and den > 0) or ( num <= 0 and den < 0))
        return num%den == 0 ? num/den : num/den;
    int ans = num / den;
    return num % den == 0 ? ans : ans - 1;
}
void dfs(vector<vector<ll>> &v, vector<ll> &df, vll &seen, ll i){ //Also outputed resultant dfs

    df.pb(i);
    for(ll j=0; j<v[i].size(); j++){
          if(seen[v[i][j]]==0){seen[v[i][j]]=seen[i]; dfs(v, df, seen, v[i][j]);}
     }
}
/* ************************************************************************************************************** */
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
   ll n,m;
   cin>>n>>m;
   vector<vll>v(n);
   forll(i,m){
       ll x,y;
       cin>>x>>y;
       v[x-1].pb(y-1);
   }
   ll ans=0;
   forll(i,n){
       vll seen(n);vll df;
       seen[i]=1;
       dfs(v,df,seen,i);
       ans+=df.size();
   }
   cout<<ans<<"\n";
}

#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert
#define nl "\n"

const ll MOD = 998244353;

ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}

template<typename T> T signum(T a) {
    return (a > 0) - (a < 0);
}

template<typename T> T cmp(T a, T b) {
    return signum(a-b);
}

template<typename T> bool mins(T& lhs , T& rhs) {
    if (rhs < lhs) {
        lhs = rhs;
        return true;
    }

    return false;
}

template<typename T> bool maxs(T& lhs , T& rhs) {
    if (rhs > lhs) {
        lhs = rhs;
        return true;
    }

    return false;
}

const int MAX = INT_MAX;

void gks(int tc) {
    printf("Case #%d: ", tc);
};

vector<bool> v;
ll ans = 0;
vector<vector<int>> g;

void dfs(int r) {
    v[r] = true;
    ans += 1;
    for (auto neigh : g[r]) {
        if (!v[neigh]) {
            dfs(neigh);
        }
    }
}

int main() {
    int n, m;
    cin>>n>>m;
    g.resize(n);
    for (int i = 0;i < m;++i) {
        int u, v;
        cin>>u>>v;
        --u, --v;
        g[u].push_back(v);
    }

    v.resize(n);

    for (int i =0 ;i < n;++i) {
        dfs(i);
        fill(all(v), false);
    }

    cout<<ans<<nl;
}


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

int main(){
    ll n, d; cin>> n>> d;
    ll a[n+n+1]={0};
    for(ll i=1; i<=n+n; i++){
        if(i<=n+1){
            a[i]=i-1;
        }
        else{
            ll k=i-n;
            a[i]=n-k+1;
        }
    }
    ll ans=0;
    for(ll i=0; i<=n+n; i++){
        if(i-d<=n+n && i-d>=0){
            ans+=a[i]*a[i-d];
        }
    }
    cout<< ans<< endl;
}

/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

/* foreach x in 2..n*2
 *    ans+=(number of pairs a+b==x) * (number of pairs c+d+K==x)
 *
 * if x<=n+1
 *    p1=x-1    (since we have a pair foreach a=1..n)
 * else
 *              (we have a pair foreach a=x-n .. n
 *
 */
void solve() {
    cini(n);
    cini(k);

    int ans=0;
    for(int aplusb=2; aplusb<=n+n; aplusb++) {
        /* number of pairs a+b==aplusb */
        int miD=max(1LL, aplusb-n);
        int maD=min(n, aplusb-1);
        int p1=maD-miD+1;

        /* number of pairs c+d+k==aplusb */
        int aplusb2=aplusb-k;
        miD=max(1LL, aplusb2-n);
        maD=min(n, aplusb2-1);
        int p2=max(0LL, maD-miD+1);

        //cerr<<"aplusb="<<aplusb<<" p1="<<p1<<" p2="<<p2<<endl;
        ans+=p1*p2;
    }

    cout<<ans<<endl;

}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


/* Created By::Shashwat Singh
 *             (shashwa_t)
 *
 * Alwayz look for edge cases(n=1 or 1111 or similar mutiple values).
 * Look for integer overflow.(>=10^6);
 * Look for out of bounds(array);
*/
# include<bits/stdc++.h>
# define ll long long
# define pb push_back
# define endl "\n"
# define mod 1000000007ll
# define pi  3.1415926535897932384626
using namespace std;
void solve()
{
  long long n,x=-1; cin>>n;
  string s,t; cin>>s>>t;
  set<long long>ind;
  for(int i=0;i<n;i++)
   {
     if(s[i]=='1')
      ind.insert(i);
   }
   long long ans=0;
   for(int i=0;i<n;i++)
   {
     if(i<=x)
     {
       s[i]='0';
       if(s[i]!=t[i])
       {
         auto it=ind.upper_bound(x);
         if(it!=ind.end())
         {
           x=*it;
           ans+=(x-i);
         }
           else
          {
            cout<<-1; return;
          }
       }
     }
     else if(s[i]!=t[i])
     {
       auto it=ind.upper_bound(i);
       if(it!=ind.end())
       {
         x=*it;
         ans+=(x-i);
       }
       else
       {
         cout<<-1; return;
       }
     }
   }
   cout<<ans;
}
int main()
{
 # ifndef ONLINE_JUDGE
   freopen("input1.txt","r",stdin);
   freopen("output1.txt","w",stdout);
 # endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    solve();
     cout<<endl;

    return 0;
}

#include <bits/stdc++.h>

#define pb push_back
#define db1(x) cout << #x << " = " << x << endl
#define db2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define paging cout << "-----------------------" << endl

using namespace std;
void localFileInput() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
int a, b, c, d;
void sol() {
    cin >> a >> b >> c >> d;
    a = a * d - b * c;
    cout << a << endl;
}
int main()
{
    // localFileInput();
    // int _; scanf("%d", &_); while(_ --)
    sol();
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
char In[1 << 20], *ss = In, *tt = In;
#define getchar() (ss == tt && (tt = (ss = In) + fread(In, 1, 1 << 20, stdin), ss == tt) ? EOF : *ss++)
ll read() {
	ll x = 0, f = 1; char ch = getchar();
	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + int(ch - '0');
	return x * f;
}
int read01() {
	char ch = getchar();
	for(; ch != '0' && ch != '1'; ch = getchar());
	return ch - '0';
}
const int MAXN = 5e5 + 5;
int n, a[MAXN], b[MAXN], qa[MAXN], hda, tla, qb[MAXN], hdb, tlb, to[MAXN];
ll ans;
vector<int> le, ri;
int main() {
	n = read();
	for(int i = 1; i <= n; i++) a[i] = read01();
	for(int i = 1; i <= n; i++) b[i] = read01();
	hda = hdb = 1; tla = tlb = 0;
	for(int i = 1; i <= n; i++) {
		if(a[i]) {
			if(hdb <= tlb) {
				to[i] = qb[hdb++]; le.push_back(i);
			} else qa[++tla] = i;
		}
		if(b[i]) {
			if(hda <= tla) {
				to[qa[hda]] = i; ri.push_back(qa[hda]);
				hda++;
			} else qb[++tlb] = i;
		}
	}
	if(hdb <= tlb || hda <= tla) {
		printf("-1\n");
		return 0;
	}
	if(le.size()) ans += le[0] - to[le[0]];
	for(int i = 1; i < (int)le.size(); i++) {
		ans += le[i] - max(to[le[i]], le[i-1] + 1);
	}
	if(ri.size()) ans += to[ri[ri.size()-1]] - ri[ri.size()-1];
	for(int i = (int)ri.size() - 2; i >= 0; i--) {
		ans += min(to[ri[i]], ri[i+1] - 1) - ri[i];
	}
	printf("%lld\n", ans);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int ans = INT_MAX;
    for (int i = 0; i < (1<<(n-1)); i++)
    {
        int in, out;
        in = out = 0;
        for (int j = 0; j < n; j++)
        {
            in |= a[j];
            if (i&1<<j)
            {
                out ^= in;
                in = 0;
            }
        }
        out ^= in;
        ans = min(ans, out);
    }
    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')';}
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) {os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define int long long
template<typename T>
void dbg_a(T *a,int l,int r){cout<<" {";for(int i = l;i<r;i++) cout<<a[i]<<", ";cout<<a[r]<<"}"<<endl;}
typedef long long ll;
template<typename T = int>
inline T read(){
    T f = 1,r = 0;
    char c = getchar();
    while(c<'0'||c>'9'){if(c == '-') f = -1; c = getchar();}
    while(c>='0'&&c<='9'){ r = (r<<1) + (r<<3) + c - '0';c = getchar();}
    return f*r;
}
typedef pair<int,int> PII;
#define fi first
#define se second
#define mst(a,b) memset(a,b,sizeof(a))
#define For(i,a,b) for(int i = a;i<=b;i++)
#define For_(i,a,b) for(int i = a;i>=b;i--)
#define _for(i,a) for(int i = 0;i<a;i++)
#define All(x) x.begin(),x.end()

//    For(i,1,n) For(j,1,m) printf("f[%lld][%lld] = %lld\n",i,j,f[i][j]);

const int N = 2e5 + 10,M = 2*N + 10,INF = 0x3f3f3f3f;
const int mod = 998244353;
int h[N],ne[M],e[M],idx;
void add(int a,int b){
    e[++idx] = b;ne[idx] = h[a];h[a] = idx;
}
int exgcd(int a,int b,int &x,int &y){
    int d = a;
    if(b){ d = exgcd(b, a%b, y, x);y -= (a/b)*x;}
    else{x = 1;y = 0;}
    return d;
}
int inv(int a,int mo){
    int x,y;
    int d = exgcd(a,mo,x,y);
    return d == 1 ? (x + mo)%mo : -1;//-1表示不存在，并对逆元调整
}
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool merge(int a1,int m1,int a2,int m2,int &A,int &mo){
    int c = (a2 - a1),d = gcd(m1,m2);
    if(c % d) return 0;//gcd(m1,m2)|(a2 - a1)时才有解
    c = (c%m2 + m2)%m2;//将c变为[0,m2)之间的数
    c /= d;m1 /= d;m2 /= d;//两边除以d
    c = c*inv(m1,m2) % m2;//将m1/d 移到右边
    mo = m1*m2*d;// mo = m1 * m2 /d
    A = (c*m1%mo*d%mo + a1)%mo;
    return 1;
}
int EXCRT(int n,int a[],int mo[]){
    int a1 = a[1],m1 = mo[1],A,Mo;
    for(int i = 2;i<=n;i++){
        if(!merge(a1,m1,a[i],mo[i],A,Mo)) return -1;//不合法
        a1 = A;m1 = Mo;
    }
    return (a1 + m1)%m1;
}
int n;
void solve(){
    int x,y,p,q;
    cin>>x>>y>>p>>q;
    int a[3] = {},mo[3] = {};
    int ans = 3e18;
    For(i,x,x+y-1){
        For(j,p,p+q-1){
            a[1] = i,mo[1] = 2*(x+y);
            a[2] = j,mo[2] = p + q;
            int res = EXCRT(2,a,mo);
            if(res == -1) continue;
            ans = min(res,ans);
        }
    }
    if(ans == 3e18)cout<<"infinity"<<"\n";
    else cout<<ans<<"\n";
}
signed main(){
    int T = 1;
    T = read();
    while(T--) solve();
    system("pause");
    return 0;
}

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll =long long; using ull = unsigned long long; using pll = pair<ll,ll>; const ll INF=9e18;
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<fixed<<setprecision(15)<<head;print0(tail...);}
void print() { print0("\n"); }
template<typename Head,typename... Tail>void print(Head head,Tail... tail){print0(head);if(sizeof...(Tail)>0)print0(" ");print(tail...);}
using i128 = __int128_t;
// clang-format on

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

// ax + by = gcd(a, b) となるような (x, y) を求める
// https://qiita.com/drken/items/0c88a37eec520f82b788
ll extgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        //return abs(a);
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

ll divceil(ll x, ll y){
  return (x+y-1)/y;
}
void solve() {
    ll x, y, p, q;
    cin >> x >> y >> p >> q;
    ll a = 2 * x + 2 * y;
    ll b = p + q;
    ll g = gcdf(a, b);
    ll lcm = a * b / g;

    // lcmは2e18くらい
    ll ans = INF;
    for (ll i = 0; i < y; i++) {
        for (ll j = 0; j < q; j++) {
            // (2x+2y)k+x+i=(p+q)m+p+j
            // ak+x+i=bm+p+j
            // ak=bm+c
            // ak+bl=c (l=-m)
            // これは一次不定方程式で、c%gcd(a,b) == 0 なら拡張ユークリッドの互除法により解を求められる https://qiita.com/drken/items/b97ff231e43bce50199a

            ll c = p - x - i + j;
            if (c % g != 0) continue;

            ll k, l;
            extgcd(a, b, k, l);
            ll ratio = c / g;
            k = k * ratio;
            l = l * ratio;
            ll m = -l;

            // ある時刻から LCM(a,b) 秒後には、高橋君と電車は元の時刻と同じ状態になる.
            // 周期を左右にずらすことで「k,mが0以上で最小」になるよう調整する
            // (事実上CRTをやっていると思われる)
            {
                // 周期を右にずらす
                // k+f*z >= 0
                // z>=-k/f
                ll za = -i128(k) * a / lcm + 1;
                ll zb = -i128(m) * b / lcm + 1;
                ll z = max(za, zb);
                k += z * (lcm/a);
                m += z * (lcm/b);
            }
            {
                // 周期を左にずらしてk,mを0以上で最小にする
                // k-v*lcm/a >= 0
                // v <= k*a/lcm;
                ll za = -i128(k) * a / lcm;
                ll zb = -i128(m) * b / lcm;
                ll z = min(za, zb);
                k += z * (lcm / a);
                m += z * (lcm / b);
            }

            ll r = a * k + x + i;
            ans = min(ans, r);
        }
    }

    if (ans == INF) {
        print("infinity");
    } else {
        print(ans);
    }
}
int main() {
    ll t;
    cin >> t;
    for (ll i = 0; i < t; i++) {
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
#define test_case int t;cin>>t;while(t--)
const double pi=acos(-1.0);
void RAmadAN()
{
    /*
    cout<<fixed<<setprecision(2);
    itoa to convert any system itoa(n,bin,2)
    */

    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
long long gcd(long long a,long long b)
{
    return a ? gcd(b%a,a):b;
}
long long lcm(long long a,long long b)
{
    return a/gcd(a,b)*b;
}
int dx_r[]= {1, 0, -1, 0, -1, 1, -1, 1};
int dy_c[]= {0, 1, 0, -1, -1, 1, 1, -1};
int main()
{
    /*freopen("","r",stdin);
    freopen("","w",stdout);*/
    RAmadAN();
    int a,b;
    cin>>a>>b;
    cout<<(2*a+100)-b;
    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque>
#include <string>

using namespace std;

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	int total = a * 2 + 100;
	int left = total - b;
	printf("%d\n", left);

	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 998244353
//#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define bs(yup,x) binary_search(yup.begin(),yup.end(),x) //it will return bollean value
#define lb(yup,x) lower_bound(yup.begin(),yup.end(),x)  //it will return the adress of the number which is equal to or just greater than x ,and if it is equal to yup.end() than their in no such number exist
#define ub(yup,x) upper_bound(yup.begin(),yup.end(),x)
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
using namespace std;
const long long N=1000005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
vi prime;
bool isprime[N];
void pre()
{
    for(int i=2;i<N;i++)
    {
        if(isprime[i])
        {
            for(int j=i*i;j<N;j+=i)
            isprime[j]=false;
            prime.pb(i);
        }
    }
    return;
}

int32_t main()
{

    IOS;
    //fill(isprime, true);
    //pre();
    int qu=1;
    //cin>>qu;
    while(qu--)
    {
       int n;
       cin>>n;
       int a[n];
       rep(i,0,n) cin>>a[i];
       sort(a,a+n);
       int pr1[n],pr2[n],sum=0;
       pr1[0]=0;
       pr2[0]=0;
       int pr3[n];
       rep(i,1,n)
       {
           pr1[i]=a[i]-a[i-1];
           pr2[i]=pr2[i-1]+pr1[i];
           sum+=pr2[i];
       }
      // rep(i,0,n)cout<<pr2[i]<<" ";
       //cout<<"\n";
       int ans=sum;
       pr3[0]=sum;
       rep(i,1,n) pr3[i]=pr3[i-1]-pr2[i],ans+=pr3[i];
       //cout<<"\n";
       //cout<<sum<<" ";
       rep(i,0,n)
       {
           ans-=(n-i-1)*pr2[i];
       }
       cout<<ans;

    }

}

#include<bits/stdc++.h>
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const ll mod=1e9+7,INF = 0x3f3f3f3f;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll exgcd(ll a, ll b, ll &x, ll &y) {if(!b) {x = 1; y = 0; return a;}ll r = exgcd(b, a % b, x, y);ll tmp = x; x = y, y = tmp - a / b * y;return r;}
ll qpow(ll a,ll n){ll r=1%mod;for (a%=mod; n; a=a*a%mod,n>>=1)if(n&1)r=r*a%mod;return r;}
ll qpow(ll a,ll n,ll P){ll r=1%P;for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll EX_BSGS(ll a,ll b,ll p){if(b == 1) return 0;map<ll,ll> pw;ll cnt = 0, t = 1, s, x, m;for(ll d = gcd(a, p); d != 1; d = gcd(a, p)){if(b % d) return -1;++cnt, b /= d, p /= d, t = 1LL * t * a / d % p;
if(b == t) return cnt;}s = b, m = sqrt(p) + 1;for(ll i = 0; i < m; ++i){pw[s] = i;s = 1LL * s * a % p;}x = qpow(a, m, p), s = t;for(ll i = 1; i <= m; ++i){s = 1LL * s * x % p;if(pw.count(s)) return i * m - pw[s] + cnt;
}return -1;} //拔山盖世！
/*const  int maxn=3e5+10;
ll _next[maxn*2],head[maxn],tot,to[maxn*2],w[2*maxn];
void add(ll x,ll y,ll z)
{
_next[++tot]=head[x],head[x]=tot,to[tot]=y,w[tot]=z;
//_next[++tot]=head[y],head[y]=tot,to[tot]=x;
}*/
const int maxn=2e5+10;
ll a[maxn],b[maxn];
int id[maxn];
bool cmp(int x,int y)
{
  return 2*a[x]+b[x]>2*a[y]+b[y];
}
int main()
{

   int n;
   cin>>n;
   ll sum=0;
   for(int i=1;i<=n;i++)
   {
     cin>>a[i]>>b[i];
     id[i]=i;
     sum+=a[i];
   }
   ll ans=0;
   sort(id+1,id+1+n,cmp);
   for(int i=1;i<=n;i++)
   {
      int now=id[i];
      ans+=b[now]+a[now];
      sum-=a[now];
      if(ans>sum)
      {
        cout<<i<<endl;
        break;
      }
   }

}


#include<cstdio>
#include<iostream>
#define re register
using namespace std;

long long n,k;
long long sum=3;
long long a=1,b,c;

template<typename T>
inline void read(T&x){
	x=0;re bool f=true;re char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=false;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	x=f?x:-x;
}

template<typename T>
inline void write(T x){
	if(x<0) x=~x+1,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+'0');
}

int main(){
	read(n),read(k);
	while(1){
		long long res,tmp;
		if(sum<=n+2) res=(sum-1)*(sum-2)/2;
		else if(n+2<sum&&sum<=2*n+1){
			tmp=2*n+1-sum;
			res=(tmp+1+n)*(n-tmp)/2+(2*n-tmp-1)*tmp/2;
		}
		else{
			tmp=3*n-sum+1;
			res=tmp*(tmp+1)/2;
		}
//		if(k<1000000000000000000/2) cout<<"k: "<<k<<" res: "<<res<<" sum: "<<sum<<endl;
		if(k<=res) break;
		k-=res;
		sum++;
	}
//	cout<<"k: "<<k<<" sum: "<<sum<<endl;
	while(1){
		if(sum-a<=2*n) break;
		a++;
	}
//	cout<<"a: "<<a<<endl;
	if(a==1){
		if(sum<=n+2){
			long long i=sum-2;
			while(k>i){
				k-=i;
				a++,i--;
			}
		}
		else if(n+2<sum&&sum<=2*n+1){
			long long i=2*n+2-sum;
			while(1){
				long long res;
				if(i>n) res=2*n-i;
				else res=i;
				if(k<=res) break;
				k-=res;
				a++,i++;
			}
		}
	}
	else{
		long long i=1;
		while(k>i){
			k-=i;
			i++,a++;
		}
	}
	write(a),putchar(' ');
	if(sum-a<=n+1) b=1,c=sum-a-1;
	else b=sum-a-n,c=n;
	k--;
	while(k--) b++,c--;
	write(b),putchar(' '),write(c);
	return 0;
}

#include <bits/stdc++.h>
#define int long long

using namespace std;

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k; cin >> n >> k;
    int real = k;
    vector <vector <int>> f(4, vector <int> (3 * n + 1)), sum(4, vector <int> (3 * n + 1));
    for (int i = 0; i <= 3 * n; ++ i) sum[0][i] = 1;
    /// f[i][j] : chọn i thằng, tổng thu được j
    for (int i = 1; i <= 3; ++ i){
        for (int j = 1; j <= 3 * n; ++ j){
            if (j > n) f[i][j] = (sum[i - 1][j - 1] - sum[i - 1][j - n - 1]);
            else f[i][j] = sum[i - 1][j - 1];
            sum[i][j] += sum[i][j - 1] + f[i][j];
        }
    }
    int en;
    for (int i = 1; i <= 3 * n; ++ i){
        if (k <= f[3][i]){
            en = i;
            break;
        }
        k -= f[3][i];
    }
    for(int i = 1; i <= n; ++ i){
        if (en - i > 2 * n) continue;
        int dau = max(1ll, en - i - n);
        int cuoi = min(n, en - i - 1);
        if (k > cuoi - dau + 1){
            k -= (cuoi - dau + 1);
            continue;
        }
        int x = dau + k - 1;
        int y = en - x - i;
        cout << i << " " << x << " " << y;
        return 0;
  }
}


/*
ID: hedichehaidar
TASK: photo
LANG: C++11
*/

#include<bits/stdc++.h>
typedef long long ll;
ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD)
ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM)
#define ss second
#define ff first
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define vi vector<int>
#define vii vector<pair<int,int>>
#define vl vector<ll>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 1000*1000*1000; // 1 e 9
const int MOD = INF + 7;
const double EPS = 0.000000001; // 1 e -9
const ll inf = (ll)1e18;
ll powe(ll u , ll v , ll mod = MOD){
    ll acc = u;
    ll res = 1;
    while(v){
        if(v % 2){
            res = (res * acc)%mod;
        }
        v /= 2;
        acc = (acc * acc)%mod;
    }
    return res;
}

int main() {
    //ifstream fin ("race.in");
    //ofstream fout ("race.out");
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int x , y ; cin>>x>>y;
    double res = ((double)(x - y) / x) * 100;
    printf("%.9f\n" , res);
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <vector>
// #include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,k,n) for(ll i=k; i<(ll)(n); i++)

int main() {
    double a,b; cin >> a >> b;

    cout << std::fixed << std::setprecision(15) << (a-b)*100/a << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){return b? gcd(b, a % b): a;}

const int N = 73;
int prime[N], vis[N], cnt = 0;
ll l, r, dp[1 << 21];

void init(void) {
	for (int i = 2; i < N; i++) {
		if (vis[i]) continue;
		prime[++cnt] = i;
		for (int j = i; j < N; j += i) vis[j] = 1;
	}
	prime[0] = 1;
}

int main(void){
	init();
	scanf("%lld%lld", &l, &r);
	dp[0] = 1;
	for (ll i = l; i <= r; i++) {
		int now = 0;
		for (int j = 0; j < cnt; j++) {
			if (i % prime[j + 1] == 0) {
				now += (1 << j);
			}
		}
		for (int i = 0; i < (1 << 20); i++) {
			if ((i & now) > 0) continue;
			dp[now | i] += dp[i];
		}
	}
	ll ans = 0;
	for (int i = 0; i < (1 << 20); i++) {
		ans += dp[i];
	}
	printf("%lld\n", ans);
	return 0;
}

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

typedef long long ll;

using namespace std;

const int maxn = 1e2 + 50, INF = 0x3f3f3f3f;

inline ll read () {
	register ll x = 0, w = 1;
	register char ch = getchar ();
	for (; ch < '0' || ch > '9'; ch = getchar ()) if (ch == '-') w = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar ()) x = x * 10 + ch - '0';
	return x * w;
}

ll a, b, ans, pw[maxn];
int sum, cnt[maxn];
bool vis[maxn], black[maxn][maxn];

inline ll GCD (register ll a, register ll b) {
	return b == 0 ? a : GCD (b, a % b);
}

inline void DFS (register int now) {
	if (now == b - a + 2) return ans ++, void ();
	if (vis[now]) DFS (now + 1);
	else {
		DFS (now + 1);
		register bool flag = 1;
		for (register int i = 1; i <= now - 1; i ++)
			if (vis[i] && black[now][i]) flag = 0;
		if (flag) vis[now] = 1, DFS (now + 1), vis[now] = 0;
	}
}

int main () {
	a = read(), b = read(), pw[0] = 1;
	for (register int i = 1; i <= 62; i ++) pw[i] = pw[i - 1] * 2ll;
	for (register ll i = a; i <= b; i ++) {
		for (register ll j = a; j <= b; j ++) {
			if (GCD (i, j) != 1) black[i - a + 1][j - a + 1] = 1;
			else cnt[i - a + 1] ++;
		}
		if (cnt[i - a + 1] == b - a) sum ++, vis[i - a + 1] = 1;
	}
	DFS (1), printf ("%lld\n", ans * pw[sum]);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pf(a) cout << a << endl
#define sz(x) (int)(x).size()
#define pb push_back
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
void go() {
    ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
}
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

void solve() {
    int n;cin >> n;
    vector<int> a(n);for(int i = 0;i < n;i++) cin >> a[i];
    vector<int> b(n);for(int i = 0;i < n;i++) cin >> b[i];
    vector<int> c(n);for(int i = 0;i < n;i++) cin >> c[i];

    unordered_map<int, int> mp;
    for(int i = 0;i < n;i++) mp[c[i]]++;

    unordered_map<int, ll> store;
    for(int i = 0;i < n;i++) store[b[i]] += mp[i + 1];

    ll ans = 0;
    for(int i = 0;i < n;i++) {
        ans += store[a[i]];
    }

    pf(ans);
}

int main() {
    go();
    int t = 1;
    while(t--) solve();
    return 0;
}

// C - Made Up
#include <bits/stdc++.h>
#define repi(i, s, n) for(int i=(int)(s); i<(int)(n); ++i)
#define rep(i, n) repi(i, 0, n)
#define rrep(i, n, s) for(int i=(int)(n-1); i>=(int)(s); --i)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
    int n;
    cin >> n;
    map<int, int> a;
    vector<int> b(n);
    rep(i, n){
        int aa; cin >> aa;
        ++a[aa];
    }
    rep(i, n) cin >> b[i];
    vector<int> d(n, 0);
    rep(i, n){
        int c; cin >> c;
        ++d[c-1];
    }
    ll ans = 0;
    rep(i, n){
        if(d[i]){
            if(a[b[i]]){
                ll v =(ll)a[b[i]]*d[i];
                ans += v;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);

// https://ei1333.github.io/luzhiled/snippets/graph/dinic.html
template< typename flow_t >
struct Dinic {
    const flow_t INF;

    struct edge {
        int to;
        flow_t cap;
        int rev;
        bool isrev;
        int idx;
    };

    vector< vector< edge > > graph;
    vector< int > min_cost, iter;

    Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {}

    void add_edge(int from, int to, flow_t cap, int idx = -1) {
        graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false, idx});
        graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true, idx});
    }

    bool bfs(int s, int t) {
        min_cost.assign(graph.size(), -1);
        queue< int > que;
        min_cost[s] = 0;
        que.push(s);
        while(!que.empty() && min_cost[t] == -1) {
            int p = que.front();
            que.pop();
            for(auto &e : graph[p]) {
                if(e.cap > 0 && min_cost[e.to] == -1) {
                    min_cost[e.to] = min_cost[p] + 1;
                    que.push(e.to);
                }
            }
        }
        return min_cost[t] != -1;
    }

    flow_t dfs(int idx, const int t, flow_t flow) {
        if(idx == t) return flow;
        for(int &i = iter[idx]; i < graph[idx].size(); i++) {
            edge &e = graph[idx][i];
            if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
                flow_t d = dfs(e.to, t, min(flow, e.cap));
                if(d > 0) {
                    e.cap -= d;
                    graph[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    flow_t max_flow(int s, int t) {
        flow_t flow = 0;
        while(bfs(s, t)) {
            iter.assign(graph.size(), 0);
            flow_t f = 0;
            while((f = dfs(s, t, INF)) > 0) flow += f;
        }
        return flow;
    }

    void output() {
        for(int i = 0; i < graph.size(); i++) {
            for(auto &e : graph[i]) {
                if(e.isrev) continue;
                auto &rev_e = graph[e.to][e.rev];
                cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
            }
        }
    }
};
// Dinic< int > g(V);
// g.add_edge(from,to,cost);
// cout << g.max_flow(from,to) << endl;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    Dinic<int> g(600000+2);
    for(int i=1;i<=n;i++){
        int a,b;
        cin>>a>>b;
        g.add_edge(i,a+n,1);
        g.add_edge(i,b+n,1);
    }
    for(int i=1;i<=n;i++)g.add_edge(0,i,1);
    for(int i=n+1;i<=600000;i++)g.add_edge(i,600000+1,1);
    cout << g.max_flow(0,600000+1) << endl;
}

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

int _;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int n,cnt[400050],ans;
set<int> s,p[400050];

inline void dfs(int x)
{
	for(auto v:p[x])
	{
		p[v].erase(x);
		p[x].erase(v);
		cnt[x]--;
		cnt[v]--;
		if(cnt[v] == 0)
			ans--;
		if(cnt[v] == 1)
			dfs(v);
		break;
	}
}

int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		p[x].insert(y);
		p[y].insert(x);
		s.insert(x);
		s.insert(y);
		cnt[x]++;
		cnt[y]++;
	}
	ans=s.size();
	for(auto x:s)
		if(cnt[x] == 1)
			dfs(x);
	printf("%d\n",ans);
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  double a[n],b[n],c[n];
  int ans = n*(n-1)/2;

  rep(i,n){
    cin >> a[i] >> b[i] >> c[i];
     if(a[i] ==2)
     {c[i] -= 0.1;}
    else if(a[i] ==3)
      {b[i] += 0.1;}
    else if(a[i] ==4)
    {c[i] -= 0.1;
     b[i] += 0.1;}
  }

   rep(i,n-1){
     for(int j =i+1;j<n;j++){
       if(c[i] < b[j] || b[i] > c[j])
       {ans -=1;}
     }
   }
    cout << ans << endl;

return 0;
}

/********************************************************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define int long long int
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
const double PI = 4*atan(1);

#define loop(i,n) for(int i=0;i<n;i++)
#define itr(it,v)  for(auto it=v.begin();it!=v.end();++it)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl ;
#define MOD (int)(1e9+7)

void solve()
{
    int n;
    cin>>n;

    int t[n],l[n],r[n];
    int ans=0;
    for(int i=0;i<n;i++)
    {
      cin>>t[i];

      cin>>l[i]>>r[i];

      for(int k=i-1;k>=0;k--)
      {
        int x1=l[k];
        int y1=r[k];

        if((y1<l[i] or x1>r[i]) or((r[k]==l[i] and (t[k]==2 or t[k]==4 or t[i]==4 or t[i]==3)) or (r[i]==l[k] and (t[i]==2 or t[k]==4 or t[i]==4 or t[k]==3))))
        {

        }
        else
          ans++;
      }

      //cout<<ans<<endl;

    }
    cout<<ans<<endl;

}

int32_t main()
{ IOS

    int t=1;
    //cin>>t;

    while(t--)
    {
      solve();
    }
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)size(x)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

string to_string(char c) {
  return string(1, c);
}
string to_string(bool b) {
  return b?"true":"false";
}
string to_string(const char* s) {
	return string(s);
}
string to_string(string s) {
	return s;
}
template<class A> void write(A x) {
	cout << to_string(x);
}
template<class H, class... T> void write(const H& h, const T&... t) {
	write(h);
	write(t...);
}
void print() {
	write("\n");
}
template<class H, class... T> void print(const H& h, const T&... t) {
	write(h);
	if(sizeof...(t))
		write(' ');
	print(t...);}

const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
const ll mod=1e9+7;

//-------------------####Real Programming###------------------

void solve(){
  ll n; cin>>n; ll a[1 << 18], g[1 << 18]; ll ans=1;
  FOR(i,1,n+1) cin>>a[i];
  sort(a+1,a+n+1);
  FOR(i,1,n+1) g[i]=(a[i]-a[i-1]);
  FOR(i,1,n+1) {ans*=(g[i]+1); ans%=mod;}
  cout<<ans<<"\n";
  return;
}
int main() {
  //freopen("blocks.in", "r", stdin);
  //freopen("blocks.out", "w", stdout);
  ios::sync_with_stdio(0);
	cin.tie(0);

  //int t; cin>>t;
  //F0R(i,t){
    //write("Case #", i+1, ": ");
  solve();
  //}
  return 0;
}

///Bismillahir Rahmanir Rahim
/*
    Author: Tanzin Ahammad
*/
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        gcd(a,b)        __gcd(a,b)
#define        lcm(a,b)        (a*b)/gcd(a,b)
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((ll)(v).size())
#define        mem(a,b)        memset(a, b, sizeof(a))
#define        uniq(v)         (v).erase(unique(all(v)),(v).end())
#define        mchk(mask,pos)  (mask & (1ll<<pos))
#define        mset(mask,pos)  (mask bitor (1ll<<pos))
#define        munset(mask,pos) (mask ^ (1ll<<pos))
#define        print_case      cout<<"Case "<<cs<<": "
#define        sumt(a,b)       ((a%mod)+(b%mod))%mod
#define        subt(a,b)       ((a%mod)-(b%mod)+mod)%mod
#define        mult(a,b)       ((a%mod)*(b%mod))%mod
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
const int N = 1e6+5;
const int mod = (int)  1e9 + 7;
ll arr[N];

int main()
{
    IOS;

    ll tc,n,x,i,j;
    cin>>n;
    for(i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    ll mul=1;x=0;
    for(i=0;i<n;i++)
    {
           mul=mult(mul,arr[i]-x+1);
           x=arr[i];
    }
    cout<<mul<<endl;

    return 0;
}


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

int main() {
  int N, C;
  cin >> N;
  vector<double> x(N);
  vector<double> y(N);
  C = 0;

  for (int i = 0; i < N; i++) {
    cin >> x.at(i) >> y.at(i);
  }

  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      double t = (y.at(j) - y.at(i)) / (x.at(j) - x.at(i));
      if (t >= -1 && t <= 1) {
        C = C + 1;
      }
    }
  }

  cout << C;

}

//pikuskd_32->42
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define fr(i,s,e) for(ll i=s;i<=e;i++)
#define rfo(i,s,e) for(ll i=s;i>=e;i--)
#define f(x,m) for(auto x : m)
#define ff first
#define ss second
const ll INF = (1LL << 60) - 1;
#define pb push_back
#define pp pop_back
#define pf push_front
#define ppf pop_front
#define m_p make_pair
#define mod 1000000007
#define TIME cerr<<"Time Taken:"<<(float)clock()/CLOCKS_PER_SEC*1000<<"ms"<<endl
// __builtin_popcount(n)
// cout << fixed << setprecision(2) << a << endl; ->'a' is floating point.

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif

	ll t = 1; //cin>>t;
	while (t--) {
		ll n; cin >> n;
		vector<pair<ll, ll>> v;
		ll x, y;
		fr(i, 0, n - 1) {
			cin >> x >> y; v.pb(m_p(x, y));
		}
		ll c = 0;
		fr(i, 0, n - 1) {
			fr(j, i + 1, n - 1) {
				if (abs(v[j].ss - v[i].ss) <= abs(v[j].ff - v[i].ff)) c++;
			}
		}
		cout << c << endl;
	}
	TIME;
	return 0;
}


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

int main() {
    string s; cin >> s;
    bool flag = false;

    if (s.size() == 1) {
        if (s == "8") flag = true;
    }
    else if (s.size() == 2) {
        if (stoi(s) % 8 == 0) flag = true;
        swap(s[0], s[1]);
        if (stoi(s) % 8 == 0) flag = true;
    }
    else {
        vector<int> cnt(10);
        for (int i = 0; i < (int)s.size(); ++i) {
            cnt[s[i] - '0']++;
        }
        for (int i = 112; i < 1000; i += 8) {
            vector<int> check = cnt;
            string n = to_string(i);
            for (int j = 0; j < 3; ++j) {
                check[n[j] - '0']--;
            }
            if (check[n[0] - '0'] >= 0 && check[n[1] - '0'] >= 0 && check[n[2]- '0'] >= 0) {
                flag = true;
            }
        }
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<utility>
#include<set>
#include<map>
#include<queue>
#include<complex>

#define Debug cout<<"line: "<<__LINE__<<"Debug"<<endl;
#define Yes cout<<"Yes"<<endl;
#define YES cout<<"YES"<<endl;
#define No cout<<"No"<<endl;
#define NO cout<<"NO"<<endl;
#define ALL(a) (a).begin(),(a).end()
#define MOD 1000000007
#define PI 3.14159265358979323846

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vd = vector<double>;
using vl = vector<long long>;

void set_FPD(int n){ cout<<fixed<<setprecision(n); return; }

void Main(){
    string s;
    cin>>s;
    vi num(10,0);
    int size=s.size();
    for(char &x:s) num[x-'0']++;
    if(size<3){
        if(size<2) num[0]+=2;
        else num[0]++;
    }
    for(int i=0;i<10;i++){
        if(size<3 && i>0) continue;
        for(int j=0;j<10;j++){
            if(size<2 && j>0) continue;
            for(int k=0;k<10;k++){
                vi cnt(10,0);
                cnt[i]++;
                cnt[j]++;
                cnt[k]++;
                int n=100*i+10*j+k;
                if(n%8==0 && cnt[i]<=num[i] && cnt[j]<=num[j] && cnt[k]<=num[k]){
                    //cout<<n<<endl;
                    Yes
                    return;
                }
            }
        }
    }
    No
    return;
}

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


#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
long long modPow(long long x, long long a) {
  if (a == 1) return x;
  if (a % 2) return (x * modPow(x, a - 1)) % MOD;
  long long t = modPow(x, a / 2);
  return (t * t) % MOD;
}
long long modInv(long long x) {
  return modPow(x, MOD - 2);
  }
  void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

// nPkの順列に対して処理を実行する
void foreach_permutation(int n, int k, std::function<void(int *)> f) {
  foreach_comb(n, k, [&](int *c_indexes) {
    foreach_permutation(k, [&](int *p_indexes) {
      int indexes[k];
      for (int i = 0; i < k; i++) {
        indexes[i] = c_indexes[p_indexes[i]];
      }
      f(indexes);
    });
  });
}
int main() {
    string  s;
    cin >>  s;
         for (int i = 0; i < s.size(); i++) {
        if(s[i] == '9'){
          s[i] = '6';
        }
        else if(s[i] == '6'){
          s[i] = '9';
        }
      }
      reverse(s.begin(), s.end());
      cout << s << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 998244353;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;

	vector<int> cnt(4);
	ll ans = 0;
	rep(i, n) {
		for (int j = i; j < n; j++) {
			if (s[j] == 'A') cnt[0]++;
			if (s[j] == 'T') cnt[1]++;
			if (s[j] == 'C') cnt[2]++;
			if (s[j] == 'G') cnt[3]++;
			if (cnt[0] == cnt[1] && cnt[2]==cnt[3]) ans++;
		}
		rep(m, 4) cnt[m] = 0;
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define RREP(i, n) for(int i=(n);i>=0;--i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, b) for(int i=(a);i>=(b);--i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}

template <class T>
void debug(const vector<T> &v) {
  cout << "[";
  REP(i, SZ(v)) {
    if(i) cout << ", ";
    cout << v[i];
  }
  cout << "]" << endl;
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << " " << p.second;
}

template <class T, class U>
void debug(const pair<T, U> &p) {
  cout << "(" << p.first << " " << p.second << ")" << endl;
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll MOD998 = 998244353;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int inf = INT_MIN;
const ll linf = LLONG_MIN;
const ld eps = 1e-9;

template<int m>
struct mint {
  int x;

  mint(ll x = 0) : x(((x % m) + m) % m) {}

  mint operator-() const { return x ? m - x : 0; }

  mint &operator+=(mint r) {
    if ((x += r.x) >= m) x -= m;
    return *this;
  }

  mint &operator-=(mint r) {
    if ((x -= r.x) < 0) x += m;
    return *this;
  }

  mint &operator*=(mint r) {
    x = ((ll) x * r.x) % m;
    return *this;
  }

  mint inv() const { return pow(m - 2); }

  mint &operator/=(mint r) { return *this *= r.inv(); }

  friend mint operator+(mint l, mint r) { return l += r; }

  friend mint operator-(mint l, mint r) { return l -= r; }

  friend mint operator*(mint l, mint r) { return l *= r; }

  friend mint operator/(mint l, mint r) { return l /= r; }

  mint pow(ll n) const {
    mint ret = 1, tmp = *this;
    while (n) {
      if (n & 1) ret *= tmp;
      tmp *= tmp, n >>= 1;
    }
    return ret;
  }

  friend bool operator==(mint l, mint r) { return l.x == r.x; }

  friend bool operator!=(mint l, mint r) { return l.x != r.x; }

  friend ostream &operator<<(ostream &os, mint a) {
    return os << a.x;
  }

  friend istream &operator>>(istream &is, mint &a) {
    ll x;
    is >> x;
    a = x;
    return is;
  }
};

using Int = mint<MOD>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vll a(n), b(n);
  REP(i, n) {
    cin >> a[i];
  }
  REP(i, n) {
    cin >> b[i];
  }

  vll c(n);
  ll ma = 0;
  ll maa = 0;
  REP(i, n) {
    chmax(maa, a[i]);
    chmax(ma, maa * b[i]);
    c[i] = ma;
  }
  REP(i, n) {
    cout << c[i] << endl;
  }

  return 0;
}

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

using namespace std;

int n;
ll a[200010], b[200010], maxa[200010], maxb[200010];

int main(){
	scanf("%d", &n);
	ll maxn = -1e18;
	for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	for(int i = 1; i <= n; i++) scanf("%lld", &b[i]);
	maxa[1] = a[1];
	for(int i = 2; i <= n; i++){
		maxa[i] = max(a[i], maxa[i - 1]);
	}
	for(int i = 1; i <= n; i++){
		maxn = max(maxn, maxa[i] * b[i]);
		printf("%lld\n", maxn);
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define u unsigned
#define ull unsigned long long
#define ld long double
#define pb push_back
#define fasterInOut ios::sync_with_stdio(false); cin.tie(0);
#define pi acos(-1)
#define f(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,a,b) for(int i=(a);i>=(b);i--)
#define MAX 1000000
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
    {
        cout<<c;
    }
    else if(a==c)
    {
        cout<<b;
    }
    else if(b==c)
    {
        cout<<a;
    }
    else if(a==b && b!=c)
    {
        cout<<a;
    }
    else
    {
        cout<<0;
    }
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main(void){
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) cout << c << endl;
	else if (b == c) cout << a << endl;
	else if (c == a) cout << b << endl;
	else cout << 0 << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define FOR(i, l, r) for (int i = (l); i < (r); ++i)
#define RFOR(i, l, r) for (int i = (r)-1; (l) <= i; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define CIN(c) cin >> (c)
#define COUT(c) cout << (c) << '\n'
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<ll, ll>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = (1 << 30) - 1; // 1073741824 - 1
// static const ll INF = (1LL << 60) - 1;  // 4611686018427387904 - 1

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    int m, h;
    cin >> m >> h;
    string ans = "No";
    if (h % m == 0) {
        ans = "Yes";
    }
    COUT(ans);
}

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

const int MOD = 1000000007;
const int INF = 1e9;
const long long INFLL = 1e18;
using ll = long long;

int digit(int n){
  int res = 0;
  while(n > 0){
    res += n % 10;
    n /= 10;
  }
  return res;
}

int main(){
  int a, b;
  cin >> a >> b;
  cout << max(digit(a), digit(b)) << endl;

  return 0;
}


#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef unsigned long long int ll;
#define MAX 1000000000
#define mod 1000000007

ll gcd(ll a, ll b){
    if (a == 0)
        return b;
    else
        return gcd(b % a, a);
 }

ll lcm(ll a, ll b)  {
    return (a*b)/gcd(a, b);
}

ll fact(ll n){
    if(n==0)
        return 1;
    else
        return n*fact(n-1);
}

bool dig(char S){
    return S>='0' && S<='9';
}
bool sma(char S){
    return S>='a' && S<='z';
}
bool cap(char S){
    return S>='A' && S<='Z';
}

void solve(ll t){

   ll N;
   cin>>N;
   ll p=1,i;
   for(i=1;i<=N;i++){
    p = lcm(p,i);
   }
   ll r=p+1;/*
   for(i=2;i<=N;i++){
    cout<<r%i<<" ";
   }*/
   cout<<r;

}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("D:\\codes\\input_10.txt","r",stdin);
    //freopen("D:\\codes\\1output.txt","w",stdout);
    ll T=1;
    //cin>>T;
    for(ll t=1;t<=T;t++){
        //cout<<"Case #"<<t<<": ";
        solve(t);
        cout<<"\n";
    }
    return 0;
}

#include<bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//MessageBox(GetForegroundWindow(),"标题","内容",MB_YESNO);
	int n;
	cin>>n;
	int sum=1;
	for(int i=1;i<=n;i++){
		sum*=i/(__gcd(sum,i));
	}
	cout<<sum+1-1+1-1+1-1+1-1+1<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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 (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll A[50];

void calc(set<ll>& time, int v, int end, ll sum, bool rev){
    if(v == end){
        if(rev)
            sum *= -1;
        time.insert(sum);
    }
    else{
        calc(time, v+1, end, sum, rev);
        calc(time, v+1, end, sum + A[v], rev);
    }
}

int main(){
    ll N, T;
    cin >> N >> T;
    REP(i,N){
        cin >> A[i];
    }

    set<ll> timeA;
    set<ll> timeB;

    calc(timeA, 0, N/2, 0, false);
    calc(timeB, N/2, N, 0, true);

    ll ans = -1;
    for(auto&& tA : timeA){
        ll rem = T - tA;
        auto iter = timeB.lower_bound(-rem);
        if(iter != timeB.end()){
            chmax(ans, tA - *iter);
        }
    }

    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
constexpr long long INF = 1<<30;
constexpr long long LINF = 1LL<<60;
constexpr double EPS = 1e-9;
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

ll X[110], Y[110], Z[110], dp[1<<18];
int main(){
    int N, M; cin >> N >> M;
    rep(i, M)cin >> X[i] >> Y[i] >> Z[i];

    dp[0] = 1;
    for(int mask=1; mask<1<<N; mask++){
        int popcnt = __builtin_popcount(mask);
        bool fg = true;
        rep(i, M){
            if(X[i]!=popcnt)continue;
            int cnt = 0;
            rep(j, Y[i]){
                if(mask>>j&1)cnt++;
            }
            if(cnt > Z[i])fg = false;
        }
        if(fg){
            for(int from=0; from<N; from++){
                if(mask>>from&1){
                    dp[mask] += dp[mask^1<<from];
                }
            }
        }
    }
    cout << dp[(1<<N)-1] << ln;
}


#include<bits/stdc++.h>

#define vi             vector<int>
#define vvi            vector<vector<int>>
#define pb             push_back
#define int            long long int
#define mod            1000000007
#define from(i,n)      for(int i=0;i<(int)n;i++)
#define from_j(i,j,n)  for(int i=j:i<(int)n;i++)
using namespace std;

int power(int n , int k) {
    if (k == 0)return 1;
    int temp = power(n, k / 2);
    temp = (temp * temp);
    if (k % 2) return (temp * n);
    return temp;
}
int fact(int x)
{
    int res = 1;
    for(int i=2;i<=x;i++)
        res = i*res;
    return res;
}

int choose(int n, int r)
{
    return fact(n)/(fact(r)*fact(n-r));
}

void sync()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  /*
    #ifndef ONLINEJUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    */
}

int32_t main() {
    sync();

    int n, s, d;
    cin>>n>>s>>d;
    int count = 0;
    from(i,n)
    {
    	int x,y;
    	cin>>x>>y;
    	if(x>=s)
    		continue;
    	else
    	{
    		if(y>d)
    			count++;
    	}
    }
    if(count)
    	cout<<"Yes";
    else
    	cout<<"No";

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=a,i##_end=b;i<i##_end;++i)
using ll=long long;
using pii=pair<int,int>;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
const int mo=1e9+7;
using L=__int128;
ll Pow(ll a,ll b,ll p=mo){ll r=1;for(;b;b>>=1,a=(L)a*a%p)if(b&1)r=(L)r*a%p;return r;}
//template<typename T>
void inc(int &x,int y){x=(x+y>=mo?x+y-mo:x+y);}
int ad(int x,int y){return x+y>=mo?x+y-mo:x+y;}
template<typename T>T gcd(T a,T b){while(b)a%=b,swap(a,b);return a;}
mt19937 rnd(time(0));

int main(){
#ifdef SGR
	freopen("a.txt","r",stdin);
#endif
	ios::sync_with_stdio(0);
	ll n,m;
	cin>>n>>m;
	int x=Pow(10,n,m);
	ll y=Pow(10,n,m*m);
	//cerr<<x<<" "<<y<<endl;
	cout<<(y)/m<<endl;
}


#include <bits/stdc++.h>
using namespace std;
// #define LOCAL // 提出時はコメントアウト
#define DEBUG_

typedef long long ll;
const double EPS = 1e-9;
const ll INF = ((1LL<<62)-(1LL<<31));
typedef vector<ll> vecl;
typedef pair<ll, ll> pairl;
template<typename T> using uset = unordered_set<T>;
template<typename T, typename U> using mapv = map<T,vector<U>>;
template<typename T, typename U> using umap = unordered_map<T,U>;

#define ALL(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define sz(x) (ll)x.size()
ll llceil(ll a,ll b) { return (a+b-1)/b; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> vector<vector<T>> genarr(ll n, ll m, T init) { return vector<vector<T>>(n,vector<T>(m,init)); }

///// DEBUG
#define DUMPOUT cerr
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
template<typename T>istream&operator>>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<typename T,typename U>ostream&operator<<(ostream&os,pair<T,U>&pair_var){os<<"("<<pair_var.first<<", "<<pair_var.second<<")";return os;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&vec){os<<"{";for(int i=0;i<vec.size();i++){os<<vec[i]<<(i+1==vec.size()?"":", ");}
os<<"}";return os;}
template<typename T,typename U>ostream&operator<<(ostream&os,map<T,U>&map_var){os<<"{";repi(itr,map_var){os<<*itr;itr++;if(itr!=map_var.end())os<<", ";itr--;}
os<<"}";return os;}
template<typename T>ostream&operator<<(ostream&os,set<T>&set_var){os<<"{";repi(itr,set_var){os<<*itr;itr++;if(itr!=set_var.end())os<<", ";itr--;}
os<<"}";return os;}
void dump_func(){DUMPOUT<<endl;}
template<class Head,class...Tail>void dump_func(Head&&head,Tail&&...tail){DUMPOUT<<head;if(sizeof...(Tail)>0){DUMPOUT<<", ";}
dump_func(std::move(tail)...);}
#ifndef LOCAL
#undef DEBUG_
#endif
#ifdef DEBUG_
#define DEB
#define dump(...)                                                          \
DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
        << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
        << endl                                                            \
        << "    ",                                                         \
    dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

//////////

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

int solve(ostringstream &cout) {
    #ifdef LOCAL
    ifstream in("../../Atcoder/input.txt");
    cin.rdbuf(in.rdbuf());
    #endif

    ll N,K;
    cin>>N>>K;

    rep(i,K) {
        if (N % 200 == 0) N /= 200;
        else {
            N *= 1000, N += 200;
        }
    }

    cout << N << endl;

    return 0;
}

int main() {
    ostringstream oss;
    int res = solve(oss);

    cout << oss.str();
    return res;
}

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

typedef long long ll;
int n,k;

int main()
{
	scanf("%d%d",&n,&k);
	ll x=n;
	for(int i=1;i<=k;)
	{
		if(x%200ll==0)x/=200ll,i++;
		else
		{
			if(i<k)
			{
				int t=x%2;t*=10;
				x/=2;
				x*=10;
				x+=t/2+1;
				i+=2;
//				cout<<x<<" ";
			}
			else
			{
				cout<<x;
				cout<<200;
				return 0;
			}
		}
	}
	cout<<x;
	return 0;
}


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

#define INF 1234567890
#define ll long long
#define MOD 998244353

ll N, M, K, res;

ll pw(ll a, ll n)
{
	ll ret = 1;
	while(n)
	{
		if (n&1) ret=ret*a%MOD;
		a=a*a%MOD;
		n>>=1;
	}
	return ret;
}

int main()
{
	scanf("%lld %lld %lld", &N, &M, &K);
	if (N < M) swap(N, M);
	if (M == 1)
	{
		printf("%lld\n", pw(K, N));
		return 0;
	}
	for(ll x=1; x<=K; x++)
		res += pw(K-x+1,M)*(pw(x,N)-pw(x-1,N))%MOD;
	res %= MOD; res += MOD; res %= MOD;
	printf("%lld\n", res);
	return 0;
}

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

#define mod % 998244353
#define MAX 998244353
#define ll long long
using namespace std;

int main() {
  int high,wide,k;
  cin >> high;
  cin >> wide;
  cin >> k;
  ll ans = 0;
  if(high == wide and high == 1){
    cout << k mod << endl;
    return 0;
  }
  if(high == 1 or wide == 1){
    if(wide == 1){
      wide = high;
    }
    for(int i = 1;i <= k;i ++){
      int m = wide;
      vector<ll> mul(21);
      vector<ll> mult(21);
      mul[0] = i;
      mult[0] = i-1;
      ll pl = 1;
      ll plt = 1;
      for(int j = 0;j < 20;j++){
        mul[j+1] = (mul[j]*mul[j])mod;
        mult[j+1] = (mult[j]*mult[j])mod;
        if(m % 2 == 1){
          pl = (pl*mul[j])mod;
          plt = (plt*mult[j])mod;
        }
        m = m/2;
      }
      ans = (ans+MAX+pl-plt)mod;
    }
    cout << ans mod << endl;

    return 0;
  }

  for(int i = 1;i <= k;i ++){
    ll pl = 1;
    int m = wide;
    vector<ll> mul(21);
    mul[0] = k-i+1;
    for(int j = 0;j < 20;j ++){
      mul[j+1] = (mul[j]*mul[j])mod;
      if(m % 2 == 1){
        pl = (pl*mul[j]) mod;
      }
      m = m/2;
    }

    ll kakerua = 1;
    ll kakerub = 1;

    if(i == 1){
      kakerub = 0;
    }
    m = high;
    vector<ll> mult(21);
    mul[0] = i;
    mult[0] = i-1;
    for(int j = 0;j < 20;j ++){
      mul[j+1] = (mul[j]*mul[j])mod;
      mult[j+1] = (mult[j]*mult[j])mod;
      if(m % 2 == 1){
        kakerua = (kakerua*mul[j])mod;
        kakerub = (kakerub*mult[j])mod;
      }
      m = m/2;
    }
    kakerua = (MAX-kakerub+kakerua)mod;
    pl = (pl*kakerua)mod;
    ans = (ans +pl)mod;
  }
  cout << ans mod<< endl;

  return 0;
}


#define G 3
#include<map>
#define AK goto
#include<cmath>
#include<queue>
#include<bitset>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define md ((l+r)>>1)
#define cht 1000000007
#define inf 1145141919810
#define mem(i,j)memset(i,j,sizeof(i))
#define F(i,j,n)for(int i=j;i<=n;i++)
#define D(i,j,n)for(int i=j;i>=n;i--)
using namespace std;
namespace sky_chen{
//	char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//	#define gc() p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++
	inline ll read(){ll ans=0,f=1;char a=getchar();while(a>'9'||a<'0'){if(a=='-')f=-1;a=getchar();}while(a>='0'&&a<='9')ans=ans*10+(a^48),a=getchar();return ans*f;}
	inline char red(){char a=getchar();while(a>'z'||a<'a')a=getchar();return a;}
//	inline void print(ll x){if(x>9)print(x/10);*O++=x%10+'0';}
	inline void cadd(ll &x,ll y){x=(x+y)%cht;}
	inline void cmin(ll &x,ll y){x=min(x,y);}
	inline void cmax(ll &x,ll y){x=max(x,y);}
	ll qpow(ll n,ll base=cht-2){ll ans=1;while(base){if(base&1)ans=ans*n%cht;n=n*n%cht;base>>=1;}return ans;}
	const int maxn = 1e6+5;
	const int maxc = 3e5+5;
	ll n,x[maxn],y[maxn];
	struct node{
		ll a=0,b=0,c=0;
	}p1,p2,t,f[maxn],g[maxn];
	int yyds(){
		n=read();
		F(i,1,n)x[i]=read(),y[i]=read();
		ll m=read();
		p1.a=1;p2.b=1;
		f[0]=p1;g[0]=p2;
		F(i,1,m){
			ll opt=read();
			if(!(opt-1)){
				t=p1;p1=p2;p2.a=-t.a;p2.b=-t.b;p2.c=-t.c;
				f[i]=p1;g[i]=p2;
			}
			else if(!(opt-2)){
				t=p2;p2=p1;p1.a=-t.a;p1.b=-t.b;p1.c=-t.c;
				f[i]=p1;g[i]=p2;
			}
			else if(!(opt-3)){
				p1.c=2*read()-p1.c;p1.b=-p1.b;p1.a=-p1.a;
				f[i]=p1;g[i]=p2;
			}
			else{
				p2.c=2*read()-p2.c;p2.b=-p2.b;p2.a=-p2.a;
				f[i]=p1;g[i]=p2;
			}
		}
//		F(i,0,m)cout<<f[i].a<<' '<<f[i].b<<' '<<f[i].c<<' '<<g[i].a<<' '<<g[i].b<<' '<<g[i].c<<endl;
		ll q=read();
		F(i,1,q){
			ll sb1=read(),sb2=read();
			ll za=x[sb2],zb=y[sb2];
			ll nza=f[sb1].a*za+f[sb1].b*zb+f[sb1].c,nzb=g[sb1].a*za+g[sb1].b*zb+g[sb1].c;
			printf("%lld %lld\n",nza,nzb);
		}
	    return 0;
	}
}
int main(){return sky_chen::yyds();}

//sky_chen txdy!


//BadWaperZ
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define fr first
#define sd second
#define pa pair<ll,ll>
#define re register ll
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define MEM(a) memset(a,0,sizeof(a))
#define N 5010
#define M 21
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
inline ll lowbit(ll x){return x&(-x);}
const ll mod=998244353;
ll f[M][N],C[N][N];
ll n,m;
inline ll Z(ll x){return (x>=mod?x-mod:x);}
int main()
{
	//ios::sync_with_stdio(false);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=read();
	C[0][0]=1;
	FOR(i,1,n){C[i][0]=1;FOR(j,1,i)C[i][j]=Z(C[i-1][j]+C[i-1][j-1]);}
	f[0][0]=1;ll t=0;
	FOR(k,1,20)
	{
		int v=(1<<(k-1));
		if(v>m){t=k-1;break;}
		FOR(s,0,m)if(f[k-1][s])for(re j=0;j<=n;j+=2)
		{
			if(s+j*v>m)break;
			f[k][s+j*v]=Z(f[k][s+j*v]+1LL*f[k-1][s]*C[n][j]%mod);
		}
	}
	cout<<f[t][m]<<'\n';
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

const ll inf = 1e18;
const ll mod = 998244353;
const ll logM = 16;

ll N, M;

vector<ll> to_bin(ll N) {
    vector<ll> res(logM);
    vector<ll> tmp;
    while (N>0) {
        tmp.push_back(N%2);
        N /= 2;
    }
    rep(i,tmp.size()) res[i] = tmp[i];
    return res;
}

// nCr (mod p) 計算量 O(3*10^5*logp)
const ll Maximum = 3e5;
ll Fac[Maximum+1], iFac[Maximum+1];
bool made_Fac = false;
// x^n (mod p) 計算量 O(logn)
ll powmodp(ll x, ll n) {
    if (n==0) return 1;
    else if (n%2==0) {
        ll ans = powmodp(x,n/2);
        return ans*ans % mod;
    }
    else return x * powmodp(x,n-1) % mod;
}
// nCr (mod p) 計算量 O(3*10^5*logp)
void make_Fac() {
    Fac[0] = 1;
    iFac[0] = 1;
    for (ll i=0; i<Maximum; i++) {
        Fac[i+1] = Fac[i] * (i+1) % mod;
        iFac[i+1] = iFac[i] * powmodp(i+1,mod-2) % mod;
    }
}
ll nCrmodp(ll n, ll r) {
    if (!made_Fac) {
        make_Fac();
        made_Fac = true;
    }
    r = min(r,n-r);
    if (n==0 or r==0) return 1;
    ll tmp = iFac[n-r] * iFac[r] % mod;
    return tmp * Fac[n] % mod;
}

int main() {
    cin >> N >> M;

    if (M%2) Cout(0);

    vector<ll> S = to_bin(M);

    vector<vector<ll>> dp(logM,vector<ll>(M+1));
    for (ll i=0; i<=N; i+=2) {
        ll up = i/2;
        if (up>M) continue;
        dp[0][up] = nCrmodp(N,i);
    }
    for (ll i=1; i<logM; i++) {
        for (ll k=0; k<=N; k+=2) {
            ll cnt = nCrmodp(N,k);
            for (ll j=0; j<=M; j++) {
                if (S[i]!=j%2) continue;
                ll up = (k + j)/2;
                if (up>M) continue;
                dp[i][up] += cnt * dp[i-1][j] % mod;
                dp[i][up] %= mod;
            }
        }
    }

    ll ans = dp.back()[0];

    cout << ans << endl;
}