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

long long ncr(long long a,long long b)
{
    long long m=1;
    for(int i=a;i>b;i--)
    {
        m*=i;
        m/=a-i+1;
    }
    return m;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, m = 0, n = 0, p = 0, q = 0, mod = 1000000007, pi = 3.1415926535;
    string s1, s2;
    char moji;

   cin >> a >> b >> c;
   d=a+b;
   c--;
   for(int i=0;i<d;i++)
   {
       if(ncr(a+b-1,max(a-1,b))<=c)
       {
           c-=ncr(a+b-1,max(a-1,b));
           cout << 'b';
           b--;
       }
       else
       {
           if(a)
           {
               cout << 'a';
             a--;
           }
           else
           {
              cout << 'b';
             b--;
           }
       }
   }
   cout << endl;
    return 0;
}

#include <iostream>
#include <string>
constexpr int MAX = 30;
long long dp[MAX + 1][MAX + 1];
std::string find_kth(int A, int B, long long K) {
    if (A == 0) {
        return std::string(B, 'b');
    }
    if (B == 0) {
        return std::string(A, 'a');
    }
    if (K <= dp[A - 1][B]) {
        return std::string("a") + find_kth(A - 1, B, K);
    }
    else {
        return std::string("b") + find_kth(A, B - 1, K - dp[A - 1][B]);
    }
}
int main() {
    int A, B;
    long long K;
    std::cin >> A >> B >> K;
    dp[0][0] = 1;
    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            if (i > 0) {
                dp[i][j] += dp[i - 1][j];
            }
            if (j > 0) {
                dp[i][j] += dp[i][j - 1];
            }
        }
    }
    std::cout << find_kth(A, B, K) << '\n';
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("fpmath=387") //extra precision
#define debug_input freopen("stdin.in", "r", stdin)
#define debug_output freopen("stdout.out", "w", stdout)
#define FOR(i, a, b) for(ll i = a; i <= b; i++)
#define FORALL(i, n) for(ll i = 0; i < n; i++)
#define FORD(i, a, b) for(ll i = a; i >= b; i--)
#define SORT(a) sort(a.begin(), a.end())
#define REV(a) reverse(a.begin(), a.end())
#define NP(a) next_permutation(a.begin(), a.end())
#define ALL(a) a.begin, a.end()
#define mp make_pair
#define pb push_back
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll N = 1e5 + 5;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double pi = 3.141592653589793;
const ll dr[4] = {-1,0,1,0}, dc[4] = {0,1,0,-1};

void solve() {
	ll n, x;
	cin >> n >> x;

	ll total = 0;
	FOR(i, 1, n) {
		ll v, p;
		cin >> v >> p;

		total += v * p;
		if(total > 100 * x) {
			cout << i << endl;
			return;
		}
	}
	cout << -1 << endl;
}

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

	ll t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}

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

typedef long long ll;

map<vector<int>, ll> mp;

ll MOD = 1e9 + 7;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    if (N > M + K) {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> f(N + M + 1, 1);
    rep(i, 0, N + M) f[i + 1] = (f[i] * (i + 1)) % MOD;
    ll ans = f[N + M];
    ans *= mod_pow(f[N], MOD - 2, MOD);
    ans %= MOD;
    ans *= mod_pow(f[M], MOD - 2, MOD);
    ans %= MOD;
    //cout << "ans0=" << ans << endl;
    if (K < N && N - K - 1 >= 0) {
        ll x = f[N + M];
        x *= mod_pow(f[M + K + 1], MOD - 2, MOD);
        x %= MOD;
        x *= mod_pow(f[N - K - 1], MOD - 2, MOD);
        x %= MOD;
        //cout << "x=" << x << endl;
        ans = (ans + MOD - x) % MOD;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 998244353;
using graph = vector<vector<int>>;

bool can_reach(const graph &g, const int s, const int t, vector<bool> &visited){
    if(s==t)return true;
    if(!visited[s]){
        visited[s] = true;
        for(const auto u: g[s]){
            if(can_reach(g, u, t, visited)){
                return true;
            }
        }
    }
    return false;
}

struct Point{
    int x;
    int y;
};

double distance(const Point &p, const Point &q){
    return sqrt((p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y));
}

int main()
{
    int n;
    cin >> n;
    vector<Point> vp;
    for(int i=0; i<n; ++i){
        int x, y;
        cin >> x >> y;
        vp.push_back({x, y});
    }
    double thres_min = 1e-5, thres_max = 100.0;
    while(thres_max - thres_min > 1e-6){
        double thres = (thres_min + thres_max) / 2.0;
        auto g = graph(n+2);
        for(int i=0; i<n; ++i){
            for(int j=i+1; j<n; ++j){
                if(distance(vp[i], vp[j]) < 2*thres){
                    g[i].push_back(j);
                    g[j].push_back(i);
                }
            }
            //上下端
            if(vp[i].y < -100 + 2 * thres){
                g[i].push_back(n);
                g[n].push_back(i);
            }
            if(vp[i].y > 100 - 2 * thres){
                g[i].push_back(n+1);
                g[n+1].push_back(i);
            }
        }
        auto visited = vector<bool>(n+2, false);
        if(can_reach(g, n, n+1, visited)){
            thres_max = thres;
        }else{
            thres_min = thres;
        }
    }
    printf("%1.18f\n", (thres_min + thres_max) / 2.0);
    return 0;
}

#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

class UnionFind {
    int cnt;
    vector<int> par, rank, size;
public:
    UnionFind() {}
    UnionFind(int _n) :cnt(_n), par(_n), rank(_n), size(_n, 1) {
        for (int i = 0; i<_n; ++i) par[i] = i;
    }
    int find(int k) {
        return (k == par[k]) ? k : (par[k] = find(par[k]));
    }
    int operator[](int k) {
        return find(k);
    }
    int getSize(int k) {
        return size[find(k)];
    }
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return;
        --cnt;
        if (rank[x] < rank[y]) {
            par[x] = y;
            size[y] += size[x];
        } else {
            par[y] = x;
            size[x] += size[y];
            if (rank[y] == rank[x]) ++rank[x];
        }
    }
    int count() {
        return cnt;
    }
};

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

    vi X(N), Y(N);
    rep(i, N)cin >> X[i] >> Y[i];
    double ok = 0, ng = 200;
    rep(ITER, 60) {
        UnionFind uf(N + 2);
        double d = (ok + ng) / 2;
        rep(i, N) {
            if (100 - Y[i] < d)uf.unite(i, N);
            if (Y[i] + 100 < d)uf.unite(i, N + 1);
            rep(j, i) {
                if (hypot(X[i] - X[j], Y[i] - Y[j]) < d)uf.unite(i, j);
            }
        }
        (uf[N] == uf[N + 1] ? ng : ok) = d;
    }
    cout << ok/2 << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rev(i,n,a) for(ll i=n-1;i>=a;i--)
#define f first
#define s second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpii vector<pair<int,int>>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define secreterror() ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve(){
    ll n;
    cin>>n;
    vector<pair<ll,ll>>arr(n);
    rep(i,0,n){
        cin>>arr[i].first>>arr[i].second;
    }
    map<ll,ll>mp;
    bool ok=false;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){

                ll a=arr[i].first*(arr[j].second-arr[k].second)+arr[j].first*(arr[k].second-arr[i].second)+arr[k].first*(arr[i].second-arr[j].second);

                if(a==0){
                    ok=true;
                    break;
                }

            }

        }
    }
    if(ok){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}

int main()
{
    secreterror()
    // ll t;
    // cin>>t;
    //while(t--){
        solve();

    //}

}

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

#define   fi(a,b) for(int i=a;i<b;i++)
#define   fj(a,b) for(int j=a;j<b;j++)
#define   ff first
#define   ss second
#define   ll long long
#define   ld long double
#define   ull unsigned long long
#define   bp(x) __builtin_popcount(x)
#define   pr(x) for(auto it: x) cout<<it<<" "; cout<<endl;
#define   getMax(x) max_element(x.begin(),x.end())
#define   getMin(x) min_element(x.begin(),x.end())
#define   endl "\n"
typedef   vector<int> vi;
typedef   vector< pair<int,int> > vii;
typedef   vector<long long> vl;
typedef   pair<int,int> pii;
typedef   pair<ll,ll> pll;
typedef   vector< pair<ll,ll> > vll;
//int dx[]={1,0,-1,0};
//int dy[]={0,1,0,-1};
//int dx[]={-1,0,1,1,1,0,-1,-1};
//int dy[]={-1,-1,-1,0,1,1,1,0};

void nikal_pehli_fursat_mai(){
    int n;
    cin>>n;
    map<string, bool>mp;
    fi(0, n){
        string s;
        cin>>s;
        mp[s] = 1;
    }
    for(auto it: mp){
        string s = it.ff;
        if(s[0]=='!'){
            string s1 = s.substr(1);
            if(mp[s1]){
                cout<<s1<<endl;
                return;
            }
        }
    }
    cout<<"satisfiable"<<endl;
}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc=1;
    // cin>>tc;
    while(tc--){
    nikal_pehli_fursat_mai();
    }
}


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

// 拡張ユークリッド互除法
// (g,x,y): ax+by=g
tuple<ll,ll,ll> extgcd(int a, int b){
	if(b==0) return {a, 1, 0};
	auto[g, x, y] = extgcd(b, a%b);
	return {g, y, x-a/b*y};
}

int solve(int n, int s, int k){
	auto[g, x, y] = extgcd(k, n);
	if(s%g) return -1;
	n /= g, s /= g, k /= g;
	return (-s * x % n + n)%n;
}

int main(){
	int t; cin>>t;
	while(t--){
		int n, s, k; cin>>n>>s>>k;
		cout<< solve(n, s, k) <<endl;
	}
}

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>
#include<cassert>

using namespace std;

#define ll long long
#define reps(i, a, b) for(int i = a; i < b; i++)
#define rreps(i, a, b) for(int i = a-1; i >= b; i--)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) rreps(i, n, 0)
#define P pair<int, int>
#define vec vector<int>
#define mat vector<vector<int> >

const ll mod = 1000000007;
const int INF = 1001001001;

ll extgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll g = extgcd(b, a%b, y, x);
    y -= (a/b) * x;
    return g;
}

void solve() {
    ll n, s, k;
    cin >> n >> s >> k;
    ll g, x, y;
    g = extgcd(k, n, x, y);
    if (s % g != 0) {
        cout << -1 << endl;
        return;
    }
    n /= g;
    s /= g;
    k /= g;
    ll ans = ((x*(-s))%n+n) % n;
    cout << ans << endl;
}

int main(){
    int t;
    cin >> t;
    rep(i, t){
        solve();
    }
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for(int i = 0; i < N; ++i)  cin >> A[i] >> B[i];

    int ans = INF;
    for(int i = 0; i < N; ++i)  chmin(ans, A[i] + B[i]);
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            if(j == i)  continue;
            chmin(ans, max(A[i], B[j]));
        }
    }
    cout << ans << endl;

    return 0;
}

//BY: YASH JAIN, CF: BitSane
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define May_the_fork_be_with_you ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define rall(v) v.rbegin(),v.rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define deb(x) cout<<#x<<": "<<x<<endl;
#define debn(x) cout<<#x<<": "<<x<<"  ";
#define MOD 1000000007
#define mod 998244353
#define INF 1e18
#define ll long long
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define int long long
#define N 100005
#define sq(x) ((x)*(x))
typedef vector<int> vi;
ll gcd(ll a, ll b) {if (!b)return a; return gcd(b, a % b);}
ll power(ll x, ll y, ll p = INF) {ll res = 1; x %= p; while (y > 0) {if (y & 1)res = (res * x) % p; y = y >> 1; x = (x * x) % p;} return res;}
// Do Not use power when calculating powers of 2 (its inefficient)

void solve() {
    int n, m; cin >> n >> m;
    vi res, a(n), b(m);
    forn(i, n) cin >> a[i];
    forn(j, m) cin >> b[j];
    forn(i, n) {
        bool foo = false;
        forn(j, m) {
            if (a[i] == b[j]) {
                foo = true;
                break;
            }
        }
        if (!foo) res.eb(a[i]);
    }
    forn(j, m) {
        bool foo = false;
        forn(i, n) {
            if (a[i] == b[j]) {
                foo = true;
                break;
            }
        }
        if (!foo) res.eb(b[j]);
    }
    sort(all(res));
    for (auto x : res) cout << x << " ";
}

int32_t main() {

#ifndef ONLINE_JUDGE
    // for geting input form input.txt
    freopen("input.txt", "r", stdin);
    // for wrting output to output.txt
    freopen("output.txt", "w", stdout);
#endif

    May_the_fork_be_with_you
    int t = 1;
    int x = 1;
    // cin >> t;
    cout << fixed << setprecision(12);
    while (t--) {
        // cout << "Case #" << x << ": ";
        solve();
        x++;
    }

#ifndef ONLINE_JUDGE
    cerr << "Time Taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
#endif
}


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

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M;
const ll mo=998244353;

ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

ll pat[202020][100];

void solve() {
	int i,j,k,l,r,x,y; string s;

	cin>>N>>M;

	int cnt=0;
	ll ret=0;
	for(i=1;i<=M;i++) {
		pat[i][1]=1;
		for(j=i*2;j<=M;j+=i) {
			for(x=1;x<=99;x++) {
				if(pat[i][x]==0) break;
				(pat[j][x+1]+=pat[i][x])%=mo;
			}
		}
		for(x=1;x<=99;x++) if(pat[i][x]) {
			(ret+=comb(N-1,x-1)*pat[i][x])%=mo;
		}

	}
	cout<<ret<<endl;

}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

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

const int N = 2e5 + 5, mod = 998244353;

int fact[N], inv[N];

vector<int> primes[N];

int mul(int a, int b){
    return 1ll * a * b % mod;
}

int add(int a, int b){
    return (a + b) % mod;
}

int fp(int b, int p){
    if(!p) return 1;
    ll ret = fp(b, p >> 1);
    ret = ret * ret % mod;
    if(p&1) ret = ret * b % mod;
    return ret;
}

void pre(){
    fact[0] = inv[0] = 1;
    for(int i = 1; i < N; i++){
        fact[i] = mul(fact[i - 1], i);
        inv[i] = fp(fact[i], mod - 2);
    }
}

int ncr(int n, int r){
    if(n < r) return 0;
    int ret = mul(fact[n], inv[n - r]);
    return mul(ret, inv[r]);
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    pre();
    int n, m;
    cin >> n >> m;
    if(n == 1) return cout << m, 0;
    for(int i = 2; i <= m; i++){
        if((int) primes[i].size() > 0) continue;
        for(int j = i; j <= m; j += i){
            int c = 1, tmp = j;
            while(tmp % i == 0){
                tmp /= i;
                c++;
            }
            primes[j].push_back(c);
        }
    }
    int ans = 0;
    for(int i = 1; i <= m; i++){
        int tmp = 1;
        for(auto j: primes[i]){
            int sum = 0;
            for(int k = 1; k <= j; k++){
                sum = add(sum, mul(ncr(n - 2, k - 1), ncr(j, k)));
            }
            tmp = mul(tmp, sum);
        }
        ans = add(ans, tmp);
    }
    cout << ans;

    return 0;
}


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

using namespace std;

typedef long long ll;
int p[102][2];
int q[102][2];
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=m;i++){
    cin>>p[i][0]>>p[i][1];
  }
  int k;
  cin>>k;
  for(int i=0;i<k;i++){
    cin>>q[i][0]>>q[i][1];
  }
  int ans = 0;
  for(int i=0;i<(1<<k);i++){
    int trt = 0;
    int cnt[102] = {};
    for(int j=0;j<k;j++){
      if(i&(1<<j)){
        cnt[q[j][1]]++;
      }
      else{
        cnt[q[j][0]]++;
      }
    }
    for(int j=1;j<=m;j++){
      if(cnt[p[j][0]]>0 and cnt[p[j][1]]>0)trt++;
    }
    ans = max(ans,trt);
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> a(n), b(n);
  int ans = INT_MAX;
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i == j) ans = min(ans, a[i] + b[j]);
      else ans = min(ans, max(a[i], b[j]));
    }
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long int
#define endl "\n"
#define MOD 1000000007
#define mod 1000000007
#define M 1000000007
#define pb push_back
#define take(a,b,c) for(int b=0;b<c;b++) cin>>a[b]
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mx 1000005
#define fiint(a,b) memset(a,b,sizeof(a))
#define bitcount __builtin_popcount
#define fori(i,a,b) for(int i=a;i<b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cout<<x<<endl;
#define cases(t) int t; cin>>t; while(t--)
#define inf1 INT_MAX
#define all(a) a.begin(),a.end()
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<int,int>
#define pint pair<int,int>
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mp make_pair

#define sz(x) (int)x.size()
#define PI    3.14159265359

int factorial[10000001]={0};

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

int powerFunction(int x,int y){
    int res = 1;
     int p = mod;
    x = x;
    while (y > 0){
        if (y & 1)
            res = (res*x)%p ;
        y = y>>1;
        x = (x*x)%p ;
    }
    return res;
}

void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
    factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}

int nCr(int n, int r)
{
    if(r < 0 || r > n){
        return 0;
    }
    int temp = factorial[n];
    temp *= (powerFunction(factorial[r], MOD-2)%MOD);
    temp %= MOD;
    temp *= (powerFunction(factorial[n-r], MOD-2)%MOD);
    temp %= MOD;
    return temp;
}

vec tree(5*300005);

int up(int node,int l ,int r , int idx , int v)
{

    if(l == r)
    {
        tree[node] = v;
        return tree[node];
    }

    int mid  = (l + r )/2;
    if(idx <= mid  )
    up(node*2 ,l , mid , idx , v  );
    else
    up(node*2 + 1 , mid + 1 , r , idx , v );
    tree[node] = tree[node*2] + tree[2*node + 1];
    return tree[node];
}

int sum(int node,int st , int en , int l ,int r )
{
    if(en < l || r < st)
        return 0;
    if(st >= l && en <= r)
        return tree[node];
    int mid = (st + en)/2;
    return sum(node*2,st , mid , l , r ) + sum(node*2 + 1, mid + 1 , en , l , r) ;
}

signed main()
{
    int n;cin>>n;
    //vec ans;
    vec v(n+1);
    int ans = 0 ;
    for(int i = 0 ; i < n;i++)
    {
        cin>>v[i];
        ans += sum(1,0,n-1,v[i],n);
        up(1, 0, n-1, v[i], 1);
    }
    for(int i = 0 ; i < n ;i++)
    {
        cout<<ans<<endl;
        ans += n -1 - v[i]*2;
    }

}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

// 1-indexed
const int N = 1000010;
vector<ll> bit(N);
// a[p] += x
void add(int p, int x) {
  for (int i = p; i <= N; i += i & -i) {
    bit[i] += x;
  }
}
// a[1] + a[2] + ... + a[p]
ll sum(int p) {
  ll res = 0;
  for (int i = p; i > 0; i -= i & -i) {
    res += bit[i];
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i]++;
  }
  ll cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += i - sum(a[i]);
    add(a[i], 1);
  }
  cout << cnt << endl;
  for (int i = 1; i <= n - 1; ++i) {
    cnt += n - 2 * a[i - 1] + 1;
    cout << cnt << endl;
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep2(i, j, n) for(int i=j;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

map<int, ll> table;
int main(){
    int N;
    cin >> N;
    ll C;
    cin >> C;
    rep(i, N){
        int a, b, e;
        cin >> a >> b >> e;
        table[a-1] += e;
        table[b] -= e;
    }
    vector<pair<int, ll>> table2;
    for(pair<int, ll> p : table){
        table2.pb(p);
    }
    sort(all(table2));
    ll rui[table2.size()+1];
    ll sum = 0;
    rui[0] = 0;
    rep(i, table2.size()){
        rui[i+1] = rui[i] + table2[i].second;
        if(i>0 && rui[i]>C){
            sum += (table2[i].first - table2[i-1].first)*C;
        } else if(i>0) {
            sum += (table2[i].first - table2[i-1].first)*rui[i];
        }
    }

    cout << sum << endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define lx x<<1
#define rx x<<1|1
map<int,ll>mp;
int main(){
	int n,C;
	scanf("%d%d",&n,&C);
	for(int i=1;i<=n;i++){
		int a,b,c;scanf("%d%d%d",&a,&b,&c);
		mp[a]+=c,mp[b+1]-=c;
	}
	int l=0;ll ans=0,s=0;
	for(auto p:mp){
		ans+=1LL*min(1LL*C,s)*(p.fi-l);
		l=p.fi;
		s+=p.se;
	}printf("%lld\n",ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long
#define For(i,k,n) for(int i=k;i<n;i++)
#define Forll(i,k,n) for(long long int i=k;i<n;i++)
#define Forull(i,k,n) for(long long int i=k;i<n;i++)

const ll MOD = 1e9 + 7;
const ll INF = 1e9;

void solve(){
   int a,b,c;
   cin>>a>>b>>c;

   if(a*a+b*b<c*c)
   cout<<"Yes"<<"\n";
   else
   cout<<"No"<<"\n";

    }

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

     ll int tc=1;
    //cin >> tc;
    for (ll int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();

    }
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int, int> >
#define vpll vector <pair <long long, long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define vb vector <bool>
#define vvb vector <vb>
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MANX MAXN
#define itn int
#define dbg(x); {cout << #x << "=" << x << ", ";}
#define in(x); { for (auto &to : x) cin >> to;}
#define out(x); { for (auto &to : x) cout << to << " "; cout << '\n'; }

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const int mod1 = 1e9+7;
const int mod2 = 1e9+21;

void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a*a+b*b<c*c?"Yes\n":"No\n");
}

int main() {
    #ifdef Mip182
    freopen("a.in", "r", stdin);
    #else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #endif
    int _t;
    _t=1;
//    cin>>_t;
    while (_t--)
        solve();
    #ifdef Mip182
    cout<<'\n'<<"Time : "<<(double)(clock())/CLOCKS_PER_SEC<<'\n';
    #endif
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 10000000000000000 //10^16
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

struct edge {
  ll to;
};
vector<vector<edge>> graph;

vector<ll> gold(200000, -1); // gold.at(i)は町iから到達可能なi以外の町で最も高い金の値段
vector<ll> A(200000);
vector<ll> gold2(200000, -1); // gold.at(i)は町iから到達可能な町で最も高い金の値段

ll bfs(ll x){
    if(gold2.at(x) != -1){
        return gold2.at(x);
    }
    ll M = A.at(x);
    ll L = -INF;
    bool upd = false;
    for(auto e : graph.at(x)){
        ll K = bfs(e.to);
        if(K >= M){
            upd = true;
            M = K;
        }
        chmax(L, K);
    }
    if(upd){
        gold.at(x) = M;
    }
    else{
        gold.at(x) = L;
    }
    gold2.at(x) = M;
    return M;
}

int main()
{
    ll N, M;
    cin >> N >> M;
    graph.resize(N);
    rep(i, N) cin >> A.at(i);
    vector<ll> X(M), Y(M);
    rep(i, M){
        cin >> X.at(i) >> Y.at(i);
        X.at(i)--;
        Y.at(i)--;
        graph.at(X.at(i)).push_back({Y.at(i)});
    }
    rep(i, N){
        if(gold.at(i) != -1){
            continue;
        }
        bfs(i);
    }
    ll ans = -INF;
    rep(i, N){
        chmax(ans, gold.at(i) - A.at(i));
    }
    cout << ans << endl;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const long double INF = 2e12;
const long double eps = 1e-12;

int N, M, K;
vector<int> A;

long double solve(long double ans){
	vector<long double> dp(N + 1), sum(N + 1);
	rep(i,N){
		int n = N - 1 - i;
		if(A[n]) dp[n] = ans;
		else dp[n] = (sum[i] - sum[max(0, i - M)]) / M + 1;
		sum[i+1] = sum[i] + dp[n];
	}
	return dp[0];
}

long double binary_search(long double left, long double right){
	if(right - left < eps * left) return left;
	long double ans = sqrt(left * right);
	long double res = solve(ans);
	if(ans > res) right = ans;
	else left = ans;
	return binary_search(left, right);
}

int main(){
	cin >> N >> M >> K;
	A = vector<int>(N + 1);
	rep(i,K){
		int a;
		cin >> a;
		A[a] = 1;
	}
	int num = 0;
	rep(i,N+1){
		if(A[i]) num++;
		else num = 0;
		if(num >= M){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << setprecision(20) << binary_search(1, INF) << endl;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using pint = pair<int,int>;
const int D = 100000;

int main()
{
	int N; cin >> N;
	vector<int> a(N);
	vector<vector<bool>> dp(N + 1, vector<bool>(D + 1, false));
	dp[0][0] = true;
	for(auto &i : a) cin >> i;

	for(int i = 0; i < N; i++) {
		for(int j = 0; j <= D; j++) {
			if(!dp[i][j])continue;
			dp[i + 1][j] = true;
			if(j + a[i] <= D)dp[i + 1][j + a[i]] = true;
		}
	}
	int sum = accumulate(a.begin(), a.end(), 0);

	int ans = 1e9;
	for(int i = 0; i <= D; i++) {
		if(dp[N][i] == true) {
			ans = min(ans, max(i, sum - i));
		}
	}

	cout << ans << endl;
}

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

#define  all(x)        (x).begin(),(x).end()
#define  pb            push_back
#define  lb            lower_bound
#define  ub            upper_bound
#define  fi            first
#define  se            second
#define  pii           pair<int,int>
#define  fastIO        ios_base::sync_with_stdio(false); cin.tie(NULL);
#define  mp            make_pair
#define endl '\n'
#define int long long

typedef double db;
typedef long long ll;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int dp[101][N];

bool go(int n, vector<int>& arr, int sum) {

	if (sum == 0) return true;
	if (n == 0) return false;

	int& ret = dp[n][sum];
	if (ret != -1) return ret;

	if (arr[n - 1] <= sum) {
		//either inc or exclude
		bool inc = go(n - 1, arr, sum - arr[n - 1]);
		bool exc = go(n - 1, arr, sum);
		return ret = (inc | exc);
	}
	else {
		return ret = go(n - 1, arr, sum);
	}
}

void solve() {

	int n; cin >> n;
	vector<int> arr(n);
	int sum = 0;

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

	memset(dp, -1, sizeof(dp));

	int reqd = sum / 2;

	int sum1 = -1, sum2 = -1;

	for (int i = reqd; i >= 0; i--) {

		bool cur = go(n, arr, i);
		if (cur == 1) {
			sum1 = i;
			break;
		}
	}

	sum2 = sum - sum1;
	cout << max(sum1, sum2);
}

signed main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	fastIO

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

	for (int tt = 1; tt <= t; tt++) {
		solve();
	}
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> P(M);
  for (int i = 0; i < M; i++) cin >> P.at(i).first >> P.at(i).second;
  sort(P.begin(), P.end());
  set<int> S;
  S.insert(N);
  int l = 0;
  while (l < M) {
    vector<int> A, B;
    int r = l;
    while (r < M) {
      if (P.at(r).first == P.at(l).first) r++;
      else break;
    }
    for (int i = l; i < r; i++) {
      int y = P.at(i).second;
      if ((S.count(y - 1) || S.count(y + 1)) && !(S.count(y))) A.push_back(y);
      if ((!S.count(y - 1) && !S.count(y + 1)) && S.count(y)) B.push_back(y);
    }
    for (int i = 0; i < A.size(); i++) S.insert(A.at(i));
    for (int i = 0; i < B.size(); i++) S.erase(B.at(i));
    l = r;
  }
  cout << S.size() << endl;
}

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

#define REP(i,n) for(long long i=0; i<n; i++)
#define pii pair<long long,long long>
#define vi vector<long long>
#define vii vector<pii>
#define ll long long

long long par[200001],sizeT[200001],sizeP[200001],sizeX[200001],N,M;

void Initialize(){
	for(long long i=1; i<=N; i++){
		par[i]=i;
	}
}

long long FindPar(long long x){
	if(par[x]==x){
		return x;
	}else{
		par[x]=FindPar(par[x]);
		return par[x];
	}
}

void Join(long long a, long long b){
	long long RepA=FindPar(a),RepB=FindPar(b);
	if(RepA==RepB)return;
	par[RepA]=RepB; sizeP[RepB] += sizeP[RepA]; sizeP[RepA] = 0;
}

int main(){
	cin>>N>>M;
	for(long long i=1; i<=N; i++){
		cin>>sizeP[i];
	}
	for(long long i=1; i<=N; i++){
		cin>>sizeX[i];
	}
	Initialize();
	for(long long i=1; i<=M; i++){
		long long a,b;
		cin>>a>>b;
		Join(a,b);
	}
	for(long long i=1; i<=N; i++){
		sizeT[FindPar(i)]+=sizeX[i];
	}
	for(long long i=1; i<=N; i++){
		if(sizeT[i]!=sizeP[i]){
			cout<<"No"<<endl; return 0;
		}
	}
	cout<<"Yes"<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(c) (c).begin(), (c).end()

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

    vector <pair <int, int> > time(N);
    for (auto &el : time) cin >> el.first >> el.second;

    int ans = INT_MAX;

    for (int i = 0; i < N; i++) {
        ans = min(ans, time[i].first + time[i].second);
    }

    sort(all(time));

    int x = INT_MAX;
    for (int i = 1; i < N; i++) {
        x = min(x, time[i].second);
    }

    ans = min(ans, max(time[0].first, x));

    sort(all(time), [] (const pair <int, int> &A, const pair <int, int> &B) {
        return A.second < B.second;
    });

    x = INT_MAX;

    for (int i = 1; i < N; i++) {
        x = min(x, time[i].first);
    }

    ans = min(ans, max(time[0].second, x));

    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    cout << '\n';
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
  int a=100000;
  int b=100000;
  int aa=0;
  int N=0;
  int ans=0;
  cin>>N;
  vector<int>A(N),B(N);
  for(int i=0; i<N; i++){
    cin>>A.at(i)>>B.at(i);
  }
  for(int i=0; i<N; i++){
    if(A.at(i)<a){
      a=A.at(i);
      aa=i;
    }
  }
  for(int j=0; j<N; j++){
    if(j==aa){
      continue;
    }
    else if(B.at(j)<b){
      b=B.at(j);
    }
  }
  if(a>b){
    ans=a;
  }
  else{
    ans=b;
  }
  if(A.at(aa)+B.at(aa)>=ans){
    cout<<ans<<endl;
  }
  else {
    cout<<A.at(aa)+B.at(aa)<<endl;
  }

}


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

typedef long long ll;
const ll MXN = 3e3 + 10;
ll H, W, Par[MXN], Sz[MXN];
vector<ll> R[MXN], C[MXN];
string s[MXN];
ll f1, f2, f3;
ll Find(ll x){
    return (x == Par[x] ? x : Par[x] = Find(Par[x]));
}
bool Union(ll u, ll v){
    u = Find(u), v = Find(v);
    if(u == v) return 0;
    if(Sz[v] > Sz[u]) swap(u, v);
    Sz[u] += Sz[v], Par[v] = u;
    return 1;
}
void Build(){
    for(int i = 1; i <= H + W; i ++){
        Par[i] = i, Sz[i] = 1;
    }
    for(int i = 1; i <= H; i ++){
        for(int j = 1; j <= W; j ++){
            if(s[i][j] == '#') Union(i, j + H);
        }
    }
}
int main(){
    //ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> H >> W;
    if(min(H, W) <= 2) return cout << 0, 0;
    for(int i = 1; i <= H; i ++){
        cin >> s[i];
        s[i] = "$" + s[i];
    }
    s[1][1] = s[1][W] = s[H][1] = s[H][W] = '#';
    Build();
    for(int i = 1; i <= H + W; i ++){
        if(Find(i) != i) continue;
        f1 += Union(i, 1);
    }

    Build();
    for(int i = 1; i <= H; i ++){
        f2 += Union(1, i);
    }

    Build();
    for(int j = 1; j <= W; j ++){
        f3 += Union(1, j + H);
    }
    for(int i = 1; i <= 100; i ++) Build();
    cout << min({f1, f2, f3}) << '\n';
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
vector<string> unique(vector<string> vec){ //あんまり値渡しは良くない気がするけど一回ならいいか。
    //12文字ならKMPとかするまでもないね。
    sort(vec.begin(),vec.end(),[](auto const& l,auto const& r){
        if(l.size()==r.size())return l>r;
        return l.size()>r.size();
    });//文字列長い順にsort
    vector<pair<string,int>> cur;
    for(int i=0;i<vec.size();i++){
        string a=vec[i]; // 今から、aの判定をします
        bool f=false;
        for(int j=0;j<cur.size();j++){
            string b=cur[j].first; //bと比較します。
            for(int k=0;k+a.size()<=b.size();k++){
                if(b.substr(k,a.size())==a){
                    cur[j].second++;
                    f=true;
                }
            }
        }
        if(!f){
            cur.push_back({a,0});
        }
    }
    sort(cur.begin(),cur.end(),[](auto const& l,auto const& r){
        if(l.second==r.second){
            if(l.first.size()==r.first.size()){
                return l.first>r.first;
            }
            return l.first.size()>r.first.size();
        }
        return l.second>r.second;
    });
    vector<string> ret;
    for(int i=0;i<cur.size();i++){
        ret.push_back(cur[i].first);
    }
    return ret;
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<string> v(m);
    for(int i=0;i<m;i++){
        cin>>v[i];
    }
    v=unique(v);
    m=v.size();
    vector<string> b(n,string(n,'.'));
    int cov=0;
    for(int i=0;i<m;i++){//iを埋め込む。
        bool ac=false;
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                bool f=true;
                for(int l=0;l<v[i].size();l++){
                    if(b[j][(k+l)%n]!='.'&&b[j][(k+l)%n]!=v[i][l]){
                        f=false;
                        break;
                    }
                }
                if(f){
                    for(int l=0;l<v[i].size();l++){
                        b[j][(k+l)%n]=v[i][l];
                    }
                    ac=true;
                    cov++;
                    break;
                }
            }
            if(ac){
                break;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<b[i]<<endl;
    }
//    cerr<<"Analytics:"<<endl<<" Actual M="<<m<<endl<<" Cover Piece="<<cov<<endl;
    return 0;
}


#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 998244353;
const int IMAX = 10000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

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

	int N, M;
	cin >> N >> M;
	if (M & 1) {
		co(0);
		return 0;
	}

	ll dp[5001] = {};
	dp[0] = 1;
	int cb[5001] = {};
	for (int i = 1; i * 2 <= N; i++) {
		cb[i] = f.comb(N, i * 2);
	}

	rep1(k, 12) {
		int are = (1 << k);
		int kari = 0;
		for (int i = M - are; i >= 0; i -= are) {
			for (int j = kari + 1; 2 * j <= N && i + are * j <= M; j += 2) {
				(dp[i + are * j] += dp[i] * cb[j]) %= mod;
			}
			kari ^= 1;
		}
	}
	co(dp[M]);

	Would you please return 0;
}

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for(ll i = a; i < (ll)(n); ++i)
#define repr(i, a, n) for(ll i = n - 1; (ll)a <= i; --i)
#define ENDL '\n'
typedef pair<int, int> Pi;
typedef pair<ll, ll> PL;
constexpr ll mod = 1000000007;  // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 + 99);
const ld PI = acos((ld)-1);
const vector<ll> dx = {-1, 0, 1, 0}, dy = {0, 1, 0, -1};
template <typename T, typename U> inline bool chmin(T& t, const U& u) {
  if(t > u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T, typename U> inline bool chmax(T& t, const U& u) {
  if(t < u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
inline void yes() { cout << "Yes" << ENDL; }
inline void no() { cout << "No" << ENDL; }

template <typename T, typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(; n; n >>= 1) {
    if(n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template <typename T> istream& operator>>(istream& is, vector<T>& vec) {
  for(auto&& x : vec) is >> x;
  return is;
}

template <typename T, typename Y>
ostream& operator<<(ostream& os, const pair<T, Y>& p) {
  return os << "{" << p.fs << "," << p.sc << "}";
}

template <typename T> ostream& operator<<(ostream& os, const V<T>& v) {
  os << "{";
  for(auto e : v) os << e << ",";
  return os << "}";
}

template <typename... Args> void debug(Args&... args) {
  for(auto const& x : {args...}) { cerr << x << ' '; }
  cerr << ENDL;
}

ll dp[55][55]={};

signed main() {
  cin.tie(0);
  cerr.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, x;
  cin >> n >> x;
  V<ll> v(n);
  cin >> v;

  V<ll> ned(n, 0);
  ll tmp=x;
  repr(i, 0, n) {
    ned[i] = tmp / v[i];
    tmp %= v[i];
  }

  dp[0][0]=1;
  rep(i,0,n-1){
    dp[i+1][0]+=dp[i][0];
    if((1+ned[i])*v[i]<v[i+1])dp[i+1][0]+=dp[i][1];

    /*
    if(ned[i]){
      dp[i+1][0]+=dp[i][0]+dp[i][1];
    }else{
      dp[i+1][0]+=dp[i][1];
    }*/

    if(ned[i]){
      dp[i+1][1]+=dp[i][0];
      dp[i+1][1]+=dp[i][1];
    }
    else dp[i+1][1]+=dp[i][1];
  }

  cout<<dp[n-1][0]+dp[n-1][1]<<ENDL;

}
//! ( . _ . ) !
// CHECK overflow,vector_size,what to output?


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cctype>
#include <bitset>
#include <cmath>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
typedef long long ll;
int n;

int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
void solve(){
	scanf("%d",&n);
	int GCD=0;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		GCD=gcd(GCD,x);
	}
	printf("%d\n",GCD);
}
int main(){
	solve();
	return 0;
}

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

int main(){
    ll n; cin >> n;
    map<ll, ll> mp;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        mp[a] += 1;
    }

    ll res = 0;

    auto begin = mp.begin(), end = mp.end();
    for(auto iter = begin; iter != end; iter++) res += iter->second * (iter->second - 1) / 2;

    cout << n*(n-1)/2 - res << endl;
}


#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
ll mod;
ll ksm(ll x,ll y)
{
	if(y==0)
	{
		return 1;
	}
	ll ret=ksm(x,y>>1);
	ret=(ret*ret)%mod;
	if(y&1)
	{
		ret=(ret*x)%mod;
	}
	return ret;
}
ll a,b,c,vis[15];
vector<ll> md;
int main(){
	ll i,x,st;
	cin>>a>>b>>c;
	x=1;
	memset(vis,-1,sizeof(vis));
	for(i=0;i<100;i++)
	{
		md.push_back(x);
		vis[x]=i;
		x*=a;
		x%=10;
		if(vis[x]!=-1)
		{
			st=vis[x];
			break;
		}
	}
	mod=md.size()-st;
	x=(ksm(b,c)-st+100*mod)%mod+st;
	mod=10;
	cout<<ksm(a,x)<<endl;
	return 0;
}

#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

ll mod_pow(ll x,ll count, ll mod){

	if(count == 0)return 1;
	ll ret = mod_pow((x*x)%mod,count/2,mod);
	if(count%2 == 1){

		ret = (ret*x)%mod;
	}
	return ret;
}

int main(){

	ll A,B,C;

	scanf("%lld %lld %lld",&A,&B,&C);

	ll ch = A%10;

	if(ch == 1 || ch == 6 || ch == 5){

		printf("%lld\n",ch);
		return 0;
	}

	ll mult = mod_pow(B,C,4);
	ll ans = mod_pow(ch,mult+4,10);

	printf("%lld\n",ans);

	return 0;
}


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

int main() {
  string s;
  cin >> s;
  cout << s.at(1) << s.at(2) << s.at(0) <<endl;
}

#include <bits/stdc++.h>

const long long INF = 1e9;
const long long MOD = 1e9 + 7;
//const long long MOD = 998244353;
const long long LINF = 1e18;
using namespace std;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define COUT(x) cout<<(x)<<endl
#define SCOUT(x) cout<<(x)<<" "
#define VECCOUT(x) for(auto&youso_: (x) )cout<<right<<setw(10)<<youso_<<" ";cout<<endl
#define ENDL cout<<endl
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) long long __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define mp make_pair
#define PQ priority_queue<long long>
#define PQG priority_queue<long long,V,greater<long long>>

typedef long long ll;
typedef vector<long long> vl;
typedef vector<long long> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef pair<long long, long long> pll;

#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
template<class T>
void mod(T &x) {
    x %= MOD;
    x += MOD;
    x %= MOD;
}

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

struct COMB{
    vl fact, fact_inv, inv;
    void init_nCk(long long SIZE) {
        fact.resize(SIZE + 5);
        fact_inv.resize(SIZE + 5);
        inv.resize(SIZE + 5);
        fact.at(0) = fact.at(1) = fact_inv.at(0) = fact_inv.at(1) = inv.at(1) = 1;
        for(long long i = 2; i < SIZE + 5; i++) {
            fact.at(i) = fact.at(i - 1)*i%MOD;
            inv.at(i) = MOD - inv.at(MOD%i)*(MOD/i)%MOD;
            fact_inv.at(i) = fact_inv.at(i - 1)*inv.at(i)%MOD;
        }
    }
    long long nCk (long long n, long long k) {
        assert(!(n < k));
        assert(!(n < 0 || k < 0));
        return fact.at(n)*(fact_inv.at(k)*fact_inv.at(n - k)%MOD)%MOD;
    }
};
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}

void Main() {
    SCIN(S);
    for(int i = 0; i < S.size(); i++) {
        cout << S.at((i + 1)%S.size());
    }
    cout << endl;
}

int main() {
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 10010010010010010
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<int> w(m);
  rep(i, n){
    cin >> h[i];
  }
  ssort(h);
  rep(i, m){
    cin >> w[i];
  }
  vector<ll> pair1((n-1)/2+1);
  vector<ll> pair2((n-1)/2+1);
  rep(i, (n-1)/2){
    if(i>0){
      pair1[i]=h[2*i+1]-h[2*i]+pair1[i-1];
    } else {
      pair1[i]=h[2*i+1]-h[2*i];
    }
  }
  for(int i=(n-1)/2-1; i>=0; i--){
    if(i<(n-1)/2-1){
      pair2[i]=h[2*i+2]-h[2*i+1]+pair2[i+1];
    } else {
      pair2[i]=h[2*i+2]-h[2*i+1];
    }
  }
  ll ans=INFll;
  rep(i, m){
    int wit=lower_bound(h.begin(), h.end(), w[i])-h.begin();
    ll cand=0;
    if(wit%2==0){
      cand+=h[wit]-w[i];
    } else {
      cand+=w[i]-h[wit-1];
    }
    if(wit/2==0){
      cand+=pair2[0];
    } else if(wit/2==(n-1)/2){
      cand+=pair1[wit/2-1];
    } else {
      cand+=pair1[wit/2-1]+pair2[wit/2];
    }
    ans=min(ans, cand);
  }
  cout << ans << endl;
  return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
const int N = 1e8 + 10;
typedef long long ll;
int main(){
	int t,n,m;
	cin>>n>>m;
	int ans1=0,ans2=0;
	while(n){
		ans1+=n%10;
		n/=10;
	}
	while(m){
		ans2+=m%10;
		m/=10;
	}
	cout<<max(ans1,ans2)<<endl;
	return 0;
}


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

/*
find my code templates at https://github.com/galencolin/cp-templates
also maybe subscribe please thanks
*/

#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}

typedef long long ll;
// typedef int ll;
// #pragma warning("int")

typedef long double lld;
typedef unsigned long long ull;

template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}

mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 rng(61378913);
/* usage - just do rng() */

void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}

// #include <atcoder/all>
// using namespace atcoder;

const lld pi = 3.14159265358979323846;
// const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;

ll n, m, q, k, l, r, x, y, z;
const ll template_array_size = 1e6 + 15258;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;

void solve(int tc = 0) {
	cin >> n >> s >> t;
	string a = s, b = t;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if (a != b) {
		cout << "-1\n";
		return;
	}

	vector<ll> at;
	for (ll i = 0; i < n; i++) if (t[i] == '0') at.push_back(i);

	ll ans = 0, pt = 0;
	for (ll i = 0; i < n; i++) {
		if (s[i] == '0') {
			if (i != at[pt++]) ++ans;
		}
	}
	cout << ans << '\n';
}

int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif

	send help

	#ifndef galen_colin_local
		// usaco("code");
	#endif

	// usaco("cowland");

	// freopen("tc.cpp", "r", stdin);
	// freopen("tc2.cpp", "w", stdout);

	cout << setprecision(15) << fixed;

	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);

	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cerr << setprecision(4) << fixed;
		cerr << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)

int main() {
  string s, t;
  int n;
  cin >> n;
  cin >> s >> t;
  vector<int> szero;
  vector<int> tzero;
  REP(i, n) {
    if (s[i] - '0' == 0) {
      szero.push_back(i);
    }
    if (t[i] - '0' == 0) {
      tzero.push_back(i);
    }
  }

  if (szero.size() != tzero.size()) {
    cout << -1 << endl;
    return 0;
  }
  int length = szero.size();
  int ans = 0;
  REP(i, length) {
    if (szero[i] != tzero[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define mod 1000000007

int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<pair<ll,ll>> v1,v2;
    for(ll i=0;i<n;i++)
    {
        ll l,r;
        cin>>l>>r;
        v1.push_back({l,i});
        v2.push_back({r,i});
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    if(v1[0].second==v2[0].second)
    {
        ll ans=min(v1[0].first+v2[0].first,min(max(v1[0].first,v2[1].first),max(v1[1].first,v2[0].first)));
        cout<<ans<<endl;
    }
    else
        cout<<max(v1[0].first,v2[0].first)<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }

int main() {
	int n;
	scanf("%d", &n);
	int a[n][2];
	for(int i = 0; i < n; ++i){
		scanf("%d", &a[i][0]);
		scanf("%d", &a[i][1]);
	}
	int ans = 1e9 + 7;
	for(int i = 0; i < n; ++i){
		ans = min(ans, a[i][0] + a[i][1]);
	}
	for(int i = 0; i < n; ++i){
		int val1 = a[i][0];
		int val2 = a[i][1];
		for(int j = 0; j < n; ++j){
			if(i != j) {
				ans = min(ans, max(val1, a[j][1]));
				ans = min(ans, max(val2, a[j][0]));
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

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

  int n;
  cin >> n;

  vector<int> ans(n);
  for (int i = 1; i <= n; i++) {
    multiset<int> st;
    int now = i;
    for (int j = 2; j * j <= n; j++) {
      while (now % j == 0) {
        st.insert(j);
        now /= j;
      }
    }
    if (now >= 2) st.insert(now);
    ans.at(i - 1) = st.size() + 1;
  }

  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << ans.at(i);
  }
  cout << '\n';
}

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

#include <bits/stdc++.h>

using namespace std;

#define DEBUG
#ifdef DEBUG
inline void debug_print() { cerr << endl; }
template <typename T1, typename... T2> void debug_print(const T1 a, const T2 &... b) { cerr << a << ' '; debug_print(b...); }
#define debug(...) cerr << __LINE__ << ": [" << #__VA_ARGS__ << "] = " , debug_print(__VA_ARGS__);
#else
#define debug(...) true
#endif

inline void print() { cout << '\n'; }
template <typename T1, typename... T2> void print(const T1 a, const T2 &... b) { cout << a << ' '; print(b...); }

template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto e : v) os << e << ' '; return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) { for (auto e : v) os << e << ' ';  return os; }
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &v) { for (auto e : v) os << e << ' ';  return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp) { for (auto e : mp) os << e << ' '; return os; }

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

const int INF = (1<<30)-1;
const long long LINF = 1LL<<60;
const double EPS = 1e-10;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int dx[8] = {-1,0,1,0,1,-1,1,-1};
const int dy[8] = {0,1,0,-1,1,-1,-1,1};

//-------------------------- Libraries --------------------------//

//--------------------------- Solver ----------------------------//

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

    if (N == 1) {
        cout << 1 << '\n';
        return;
    }

    vector<int> A(N+1, 1);

    for (int i = 2; i <= N; i++) {
        for (int j = i+i; j <= N; j+=i) {
            A[j] = A[i]+1;
        }
    }

    int ma = 0;
    for (int i = 0; i <= N; i++) {
        chmax(ma, A[i]);
    }
    A[1] = ma+1;

    for (int i = 1; i <= N; i++) {
        cout << A[i] << ' ';
    }
    cout << '\n';
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int t = 1;
    //cin >> t;
    while (t--) solve();

    return 0;
}


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

ll dp[65][3];
ll n;
vector<ll>v;
void ctdp()
{
    dp[0][0]=1;
    dp[0][1]=1;
    for(ll i=1;i<=n;i++){
        if(v[i-1]==0){
            dp[i][0]=dp[i-1][0];
            dp[i][1]=dp[i-1][0]+(2*dp[i-1][1]);
        }else{
            dp[i][0]=(2*dp[i-1][0])+dp[i-1][1];
            dp[i][1]=dp[i-1][1];
        }
    }
}

int main()
{
    cin>>n;
    for(ll i=0;i<n;i++){
        string tmp;
        cin>>tmp;
        if(tmp=="AND")v.push_back(1);
        else v.push_back(0);
    }
    ctdp();
    cout<<dp[n][1]<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N=4e5+2;
int stk[N],top;
int n,m,p,e,a[N],b[N];
int main()
{
	scanf("%d",&n);
	m=n<<1;
	for(int i=1;i<=m;++i)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+m+1);
	for(int i=1;i<=m;++i)
		if(a[i]<b[n])++p;
		else if(a[i]>b[n])++e;
	for(int i=1;i<=m;++i)
	{
		int fl=0;
		if(a[i]>b[n])fl=1;
		else if(a[i]==b[n]&&p<n)++p;
		else if(a[i]==b[n]&&p==n)fl=1,++e;
		//else if(a[i]==b[n]&&!top)fl=1,++e;
		if(top&&stk[top]!=fl)putchar(')'),--top;
		else stk[++top]=fl,putchar('(');
	}
}


// Problem: C. The Sports Festival
// Contest: Codeforces - Codeforces Round #715 (Div. 2)
// URL: https://codeforces.com/contest/1509/problem/C
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)

/*
    authored by
    aden_frost
    on 07-03-2021
    Go Corona Corona Go!!
    hurray! mission - 1 - completed;
    mission - 2
    ____________

    40 more to go
*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define lli long long int
#define MOD1 998244353
#define MOD 1000000007
using namespace std;
using namespace std::chrono;
void fastaf(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(void)
{
	lli N,M;
	map<lli,lli>mp;
	cin>>N>>M;
	for(int i=0;i<N;i++)
	{
		string S;
		cin>>S;
		lli sum=0;
		for(int j=0;j<M;j++)
			sum+=(S[j]-'0');
		mp[sum]++;
	}
	lli ans=0;
	for(auto x: mp)
	{
		lli sum=0;
		for(auto y: mp)
		{
			if((x.first!=y.first)&&(abs(x.first-y.first)%2!=0))
			{
				sum+=y.second;
			}
		}
		sum*=x.second;
		ans+=sum;
	}
	ans/=2;
	cout<<ans;
}
/*
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
int main()
{
    fastaf();
    int Testcases=1;
    //cin>>Testcases;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    while(Testcases--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}

#include<stdio.h>
#define reg register
#define ri reg int
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define nrep(i, x, y) for(ri i = x; i >= y; --i)
#define DEBUG 1
#define ll long long
#define il inline
#define swap(a, b) ((a) ^= (b) ^= (a) ^= (b))
#define max(i, j) (i) > (j) ? (i) : (j)
#define min(i, j) (i) < (j) ? (i) : (j)
#define read(i) io.READ(i)
#define print(i) io.WRITE(i)
#define push(i) io.PUSH(i)
struct IO {
#define MAXSIZE (1 << 20)
#define isdigit(x) (x >= '0' && x <= '9')
  char buf[MAXSIZE], *p1, *p2;
  char pbuf[MAXSIZE], *pp;
#if DEBUG
#else
  IO() : p1(buf), p2(buf), pp(pbuf) {}
  ~IO() {
    fwrite(pbuf, 1, pp - pbuf, stdout);
  }
#endif
  inline char gc() {
#if DEBUG
    return getchar();
#endif
    if(p1 == p2)
      p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
    return p1 == p2 ? ' ' : *p1++;
  }
  inline bool blank(char ch) {
    return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
  }
  template <class T>
  inline void READ(T &x) {
    register double tmp = 1;
    register bool sign = 0;
    x = 0;
    register char ch = gc();
    for(; !isdigit(ch); ch = gc())
      if(ch == '-') sign = 1;
    for(; isdigit(ch); ch = gc())
      x = x * 10 + (ch - '0');
    if(ch == '.')
      for(ch = gc(); isdigit(ch); ch = gc())
        tmp /= 10.0, x += tmp * (ch - '0');
    if(sign) x = -x;
  }
  inline void READ(char *s) {
    register char ch = gc();
    for(; blank(ch); ch = gc());
    for(; !blank(ch); ch = gc())
      *s++ = ch;
    *s = 0;
  }
  inline void READ(char &c) {
    for(c = gc(); blank(c); c = gc());
  }
  inline void PUSH(const char &c) {
#if DEBUG
    putchar(c);
#else
    if(pp - pbuf == MAXSIZE) {
      fwrite(pbuf, 1, MAXSIZE, stdout);
      pp = pbuf;
    }
    *pp++ = c;
#endif
  }
  template <class T>
  inline void WRITE(T x) {
    if(x < 0) {
      x = -x;
      PUSH('-');
    }
    static T sta[35];
    T top = 0;
    do {
      sta[top++] = x % 10;
      x /= 10;
    } while(x);
    while(top)
      PUSH(sta[--top] + '0');
  }
  template <class T>
  inline void WRITE(T x, char lastChar) {
    WRITE(x);
    PUSH(lastChar);
  }
} io;
ll n, m, odd, even, num, a;
int main() {
	read(n), read(m);
	rep(i, 1, n) {
		num = 0;
		rep(j, 1, m) {
			scanf("%1lld", &a);
			num += a;
		}
		if(num % 2) ++odd;
		else ++even;
	}
	print(odd * even);
}


#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a * b / gcd(a, b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}

static const double pi = 3.141592653589793;
int modpow(int a,int n,int p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**/int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
	int getsize(){
		set<int> ma;
		rep(i,table.size())ma.insert(root(i));
		int re=ma.size();
		return re;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(10);
	int n,m;
	in(n,m);
	vlint a(n),b(n);
	vint c(m),d(m);
	in(a,b);

	rep(i,m)in(c[i],d[i]);
	unionfind uni;
	uni.init(n);
	rep(i,m)uni.marge(c[i]-1,d[i]-1);
	map<int,lint> ma;
	map<int,lint> mb;
	rep(i,n)ma[uni.root(i)]+=a[i];
	rep(i,n)mb[uni.root(i)]+=b[i];
	rep(i,n){
		if(ma[uni.root(i)]!=mb[uni.root(i)]){
			out("No");
			return 0;
		}
	}
	out("Yes");
	return 0;
}

#include<bits/stdc++.h>
#define int long long
#define N 200010
using namespace std;
int n,m;
int a[N];
vector<int> v[N];
int dp[N],ans[N],res=-1e18;
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%lld%lld",&x,&y);
		v[x].push_back(y);
	}
	for(int i=1;i<=n;i++)
		ans[i]=-1e18;
	for(int i=n;i>=1;i--){
		for(int j=0;j<v[i].size();j++){
			if(dp[v[i][j]]+a[v[i][j]]-a[i]>dp[i]){
				dp[i]=dp[v[i][j]]+a[v[i][j]]-a[i];
			}
			if(dp[v[i][j]]+a[v[i][j]]-a[i]>ans[i]){
				ans[i]=dp[v[i][j]]+a[v[i][j]]-a[i];
			}
		}
	}
	for(int i=1;i<=n;i++)
		res=max(res,ans[i]);
	cout<<res<<endl;
	return 0;
}


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

// template {{{
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

#define  range(i, l, r) for (i64 i = (i64)(l); i < (i64)(r); (i) += 1)
#define rrange(i, l, r) for (i64 i = (i64)(r) - 1; i >= (i64)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr i32 dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr i32 dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

vector<i64> divisor(i64 n) {
  vector<i64> res;
  for (i64 i = 1; i * i <= n; i++) {
    if (n % i != 0) continue;
    res.emplace_back(i);
    if (i * i == n) continue;
    res.emplace_back(n / i);
  }

  return res;
}

void solve() {
  i64 s = input(), p = input();

  auto ds = divisor(p);
  for (auto &d : ds) {
    i64 n = d, m = p / d;
    if (n + m != s) continue;

    cout << "Yes" << endl;
    return;
  }

  cout << "No" << endl;
}

signed main() {
  solve();
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll S, P; cin >> S >> P;
  for (ll i = 1; i * i <= P; i++) {
    if (P % i) continue;
    if (i + P / i == S) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


#include <iostream>

using namespace std;
int main()
{
  int a,b,c,result;
  cin>>a >>b>>c;
  if((a*a)+(b*b) < (c*c))
     cout<<"Yes"<<endl;
  else
        cout<<"No"<<endl;
}

#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<stdio.h>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <sstream>

//#include<bits/stdc++.h>
#define FILE_NAME "A"
#define mp make_pair
#define SZ(x) (int)x.size()
#define pb push_back

#define fi first
#define se second
#define watch(x) cout << (#x) << " is " << (x) << endl
#define whole(x) x.begin(), x.end()
#define in insert

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;

const ll maxn = (2e5) + 11;
const int MOD = (1e9) + 7;
const ll  INF = (1e10) + 777;
const ld pi = 2 * acos(0.0);
const ll E9 = 1e9;
const ll E8 = 1e8;
const ll E7 = 1e7;
const ll E6 = 1e6;
const ll E5 = 1e5;
const ll E4 = 1e4;
const ll E3 = 1e3;

ll  toup(ll n,int div){
        return n%div==0?(n/div):((n+(div-n%div))/div);
}

ll n,sum=0,er,er2,m,ans=0,a[maxn],cnt=0,pref[maxn],l,r;

string s,t;
//map<ll,int>mm;
vector<ll>v;

//vector<ll>v;
//vector<pair<ll,ll>>vp;
//vector<pair<int,int>>g[50000];

void solve() {
        ll k;
        cin>>n>>m>>k;
        cout<<(n*n+m*m<k*k?"Yes":"No");
}

int main(){
        int test=1;
//        cin>>test;
        while(test--){
                solve();
//                nosolve();
        }

}


#include<bits/stdc++.h>

using namespace std;

#define ll long long int
#define get(a) ll a ; cin >> a ;
#define show(a) cout << a << endl;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	double a, b, w;

	cin >> a >> b >> w;

	int lower = int(ceil(1000*w/b)) ;
	int upper = int(floor(1000*w/a));
	if(lower > upper)
		cout << "UNSATISFIABLE" << endl;
	else
		cout << lower << " " << upper << endl;

	return 0;
}

#include <iostream>
using namespace std;

int A, B;
double W;

int isin(double N) {
    if(N >= A and N <= B) {
        return true;
    } else {
        return false;
    }
}

int main() {
    cin >> A >> B >> W;
    int max = 0;
    int min = 0;
    for (int i = 1; i <= W * 1000; i++) {
        double pre = W * 1000 / i;

        if(isin(pre)) {
            min = i;
            break;
        }
    }

    for (int i = W * 1000; i > 0; i--) {
        double pre = W * 1000 / i;

        if(isin(pre)) {
            max = i;
            break;
        }
    }

    if (min == 0) {
        min = max;
    }
    if (max == 0) {
        max = min;
    }

    if (min == 0 and max == 0) {
        cout << "UNSATISFIABLE" << endl;
    } else {
        cout << min << " " << max << endl;
    }
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using tii = tuple<int,int,int>;
template<typename T>bool chmin(T&x,const T&y) {if(x>y){x=y;return 1;} else return 0;}
template<typename T>bool chmax(T&x,const T&y) {if(x<y){x=y;return 1;} else return 0;}

int main() {
    double a, b, c;
    cin >> a >> b >> c;
    ll X, Y, R;
    X = round(a * 10000);
    Y = round(b * 10000);
    R = round(c * 10000);
    ll top = (Y + R) / 10000 * 10000 + 60000;
    while (top > Y + R) top -= 10000;
    ll down = (Y-R) / 10000 * 10000 - 60000;
    while (down < Y - R) down += 10000;
    ll ans = 0;
    for (ll y = down; y <= top; y += 10000) {
        ll l = sqrt(R * R - (y - Y) * (y - Y)) + 10;
        while (l * l > R * R - (y-Y) * (y-Y)) l--;
        ll left = (X - l) / 10000 * 10000 - 60000;
        while (left < X - l) left += 10000;
        ll right = (X + l) / 10000 * 10000 + 60000;
        while (right > X + l) right -= 10000;
        if (left > right) continue;
        ans += (right - left) / 10000 + 1;
        // cout << left << ' ' << right << ' ' << l << '\n';
        // cout << ans << '\n';
    }
    cout << ans << '\n';
    return 0;
    // get dp together, ll, paraphrase, debug
}

// 07

#include <iostream>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;

int in(){
  double x;
  cin >> x;
  x*=10000;
  return round(x);
}

bool ok(ll dx,ll dy,ll z){
  return dx*dx+dy*dy <= z*z;
}

ll f(ll x,ll y,ll z,ll lim){
  int l=0,r=1;
  ll res = 0;
  for(int i=1e9+50000;i>=lim;i-=10000){
    while(ok(x-l*10000,i-y,z))--l;
    while(ok(r*10000-x,i-y,z))r++;
    res += r-l-1;
  }
  return res;
}

int main(){
  ll x=in(),y=in(),z=in();
  x%=10000;
  y%=10000;
  ll ans = f(x,y,z,10000);
  ans += f(x,-y,z,0);
  cout << ans << endl;
  return 0;

}


// 状压表示点的集合
// 每次尝试加入一个点，看能不能构成一个完全图
// 若能，则这个点集的完全图数为1
// 否则采用环形DP的方法求最小完全图数
// 太菜了，写不出来QAQ

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define INF 0x3f3f3f3f

using namespace std;

const int maxn = 18;

int n, m;
int grap[maxn + 1][maxn + 1];
int f[1 << maxn], good[1 << maxn];

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

    for (int i = 1; i < (1 << n); i++) {
        vector<int> u;
        for (int j = 1; j <= n; j++) {
            if (i & (1 << (j - 1))) u.push_back(j);
        }
        good[i] = true;
        for (int j = 0; j < u.size(); j++) {
            for (int k = j + 1; k < u.size(); k++) {
                if (!grap[u[j]][u[k]]) good[i] = false;
            }
        }
    }

    for (int i = 1; i < (1 << n); i++)
        f[i] = INF;

    for (int i = 1; i < (1 << n); i++) {
        if (good[i]) {
            f[i] = 1;
            continue;
        }
        for (int j = i; j; j = (j - 1) & i) {
            f[i] = min(f[i], f[j] + f[i ^ j]);
        }
    }

    printf("%d\n", f[(1 << n) - 1]);
    return 0;
}

#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;

#define REP(i,b,e) for(int i=b; i<e; i++)
#define PRINT(vec) {printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");}
#define fi first
#define se second

const int MOD = 1e9+7;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
    ll n, k;
    scanf("%ld %ld", &n, &k);
    ll dist[n][n];
    REP(i, 0, n) REP(j, 0, n) scanf("%ld", &dist[i][j]);

    ll ans = 0;
    ll a[n-1];
    REP(i, 0, n-1) a[i] = i+1;
    do{
        ll tmp = dist[0][a[0]];
        REP(i, 1, n-1){
            tmp += dist[a[i-1]][a[i]];
        }
        tmp += dist[a[n-2]][0];
        if(tmp==k) ans++;
    }while(std::next_permutation(a, a+n-1));

    printf("%ld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

/*
    実行時MODint :
    template <int& MOD = 1000000007>
    static int MOD;
    cin >> MOD;
*/
template <int MOD = 1000000007>
struct Mint {
    int x;

    constexpr Mint() : x(0) {}
    constexpr Mint(long long t)
        : x(t >= 0 ? (t % MOD) : (MOD - (-t) % MOD) % MOD) {}

    Mint pow(int n) {
        Mint res(1), t(x);
        while (n > 0) {
            if (n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        int a = x, b = MOD, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint &operator+=(Mint a) {
        x += a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator-=(Mint a) {
        x += MOD - a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator*=(Mint a) {
        x = int(1LL * x * a.x % MOD);
        return *this;
    }

    Mint &operator/=(Mint a) {
        return (*this) *= a.inv();
    }

    Mint operator+(Mint a) const {
        return Mint(x) += a;
    }
    Mint operator-(Mint a) const {
        return Mint(x) -= a;
    }
    Mint operator*(Mint a) const {
        return Mint(x) *= a;
    }
    Mint operator/(Mint a) const {
        return Mint(x) /= a;
    }

    Mint operator-() const {
        return Mint(-x);
    }

    bool operator==(const Mint a) {
        return x == a.x;
    }
    bool operator!=(const Mint a) {
        return x != a.x;
    }
    bool operator<(const Mint a) {
        return x < a.x;
    }

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

    friend istream &operator>>(istream &is, Mint &a) {
        int t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

signed main() {
    int n;
    cin >> n;
    char caa, cab, cba, cbb;
    cin >> caa >> cab >> cba >> cbb;
    if (n <= 3) {
        cout << 1 << endl;
        return 0;
    }
    if ((cab == 'A' && caa == 'A') || (cab == 'B' && cbb == 'B')) {
        cout << 1 << endl;
        return 0;
    }
    if ((cab == 'A' && caa == 'B' && cba == 'A') ||
        (cab == 'B' && cbb == 'A' && cba == 'B')) {
        Mint<> dp[n][2];
        dp[0][0] = 1;
        rep(i, n - 1) {
            dp[i + 1][0] += dp[i][1];
            dp[i + 1][1] += (dp[i][0] + dp[i][1]);
        }
        cout << dp[n - 1][1] << endl;
        return 0;
    }
    cout << Mint<>(2).pow(n - 3) << endl;
    return 0;
}

#include<bits/stdc++.h>
#include <iterator>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x)
#define gc getchar
#define pdd pair<dd,dd>
#define read_arr(a,n) for(ll i=1;i<=n;i++)cin>>a[i];
#define init_arr(a,n) for(ll i=1;i<=n;i++)a[i]=n-i+1;
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
#define arr array
using namespace std;

int main() {
	ll n;
	cin>>n;
	if(n%2==0)cout<<"White";
	else cout<<"Black";

}


#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define pii pair<int, int>

using namespace std;

using ll = long long;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define M (1'000'000'007)

int main() {
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    int ans = 0;
    int dx[] = {-1, 1, 0, 0};
    int dy[] = {0, 0, -1, 1};
    for (int x = 0; x < w; x++) {
        for (int y = 0; y < h; y++) {
            if (s[y][x] != '.')
                continue;
            for (int i = 0; i < 4; i++) {
                if (x + dx[i] >= 0 && x + dx[i] < w && y + dy[i] >= 0 &&
                    y + dy[i] < h) {
                    if (s[y + dy[i]][x + dx[i]] == '.')
                        ans++;
                }
            }
        }
    }

    cout << ans / 2 << endl;

    return 0;
}

//Bismillah Hir Rehmanir Rahim
//Allah knows best
using namespace std;
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include<bits/stdc++.h>
#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>
#define endl "\n"
#define mini -10000000000000000
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define ll long long
#define pi 3.141592653589793
#define vi              vector<int>
#define si              set<int>
#define pb              push_back
#define mp              make_pair
#define mod             1000000007
#define rr              return 0
#define ff              first
#define in              insert
#define ss              second
#define setbits(x)      __builtin_popcountll(x)
#define zrbits(x)       __builtin_ctzll(x)
#define deb(x)          cout << #x << " = " << x << endl
#define set_bit(x, idx) x = x|1LL<<idx
#define check_bit(x, idx) min(x&(1LL<<idx),1LL)
#define toggle_bit(x, idx) x = x^(1LL<<idx)
int main()
{
     ios;
      #ifdef DEBUG
     freopen("input.txt", "r", stdin);
     #endif
     ll i,j,k,n,m;
     cin>>n>>m;
     string s[n],t;
     f(i,0,n) cin>>s[i];
     ll c=0,ct=0,ans=0;
     for(i=0;i<n;i++)
     {
         t=s[i];
         c=0;
         for(j=0;j<m;j++)
         {
             if(t[j]=='.')
             c++;
             else
             {
                 if(c>1)
                 ans=ans+c-1;
                 c=0;
             }
         }
         if(c>1)
           {
            ans=ans+c-1;
             c=0;
           }
     }
     if(c>1)
     {
            ans=ans+c-1;
             c=0;
     }
     c=0;
     //deb(ans);
     for(j=0;j<m;j++)
     {
         c=0;
        for(i=0;i<n;i++)
        {
           // deb(s[i][j]);
            if(s[i][j]=='.')
            c++;
            else
            {
                 if(c>1)
                 ans=ans+c-1;
                 c=0;
            }
        }
           if(c>1)
          {
            ans=ans+c-1;
             c=0;
          }
          c=0;
     }
     cout<<ans<<endl;
     rr;
}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
#define test ll t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define pop pop_back
#define int long long int
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mod 1000000007
#define inf 1LL<<60

int32_t main()
{
	fast;
    /*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	int h,m;
	cin>>m>>h;
	if(h%m==0)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b;
	cin>>a>>b;
	if(b%a==0) cout<<"Yes\n";
	else cout<<"No\n";
}


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

int main() {
    ll n;
    while (cin >> n) {
        ll l = 2, r = 2e9;
        while (l <= r) {
            ll mid = l + r >> 1;
            if (mid * (mid + 1) / 2 <= n + 1)
                l = mid + 1;
            else
                r = mid - 1;
        }
        cout << n - l + 2 << '\n';
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LL long long int
int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    LL N;
    cin >> N;
    LL ans=0;
    map<LL,LL> hash;
    for(LL i=2 ; i <=(100000) ; i++)
    {
        LL temp = i*i ;
        while(temp <= N)
        {
            if(hash[temp]==false)
            {
                ans++;
            }
            hash[temp]=true;
            temp= temp*i;
        }
    }
    cout<< N-ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define deb(k) cerr << #k << ": " << k << "\n";
#define size(a) (int)a.size()
#define fastcin cin.tie(0)->sync_with_stdio(0);
#define st first
#define nd second
#define pb push_back
#define mk make_pair
#define int long long
typedef long double ldbl;
typedef double dbl;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef vector<int> vint;
#define MAXN 300100
#define MAXLG 20
const int inf = 0x3f3f3f3f;
const ll mod = 1000000007;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const int N = 300100;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(){
	int n;
	cin>>n;
	vector<pair<int, string>>v(n);
	for(int i=0;i<n;i++){
		string s;
		int t;
		cin>>s>>t;
		v[i] = {t, s};
	}
	sort(v.rbegin(), v.rend());
	cout<<v[1].nd<<"\n";

	// Have you read the problem again?
	// Maybe you understood the wrong problem
}

int32_t main(){
	fastcin;
	int t_ = 1;
	//cin>>t_;
	while(t_--)
		solve();
	return 0;
}

//...Bismillahir Rahmanir Rahim. . .

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

// typedefs...
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

// constants...
const double PI = acos(-1);
const ll mod = 1000000007; // 998244353;
const int MXS = 2e5+5;
const ll MXI = 1e9+5;
const ll MXL = 1e18+5;
const ll INF = 1e9+5;
const ll INFLL = 1e18+5;
const ll EPS = 1e-9;

// defines...
#define MP        make_pair
#define PB        push_back
#define fi         first
#define se         second
#define sz(x)      (int)x.size()
#define all(x)      begin(x), end(x)
#define si(a)       scanf("%d", &a)
#define sii(a, b)    scanf("%d%d", &a, &b)
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define boost_      ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define iter_(i,n)    for (int i = 0; i < int(n); i++)
#define for_n(i, n)  for (int i = 1; i <= int(n); i++)
#define print_array(a) for(int i=0;i<n;i++)  cout<<a[i]<<" ";
#define rev(i,n)     for(int i=n;i>=0;i--)
#define itr          ::iterator
#define s_sort(s)    sort(s.begin(),s.end())
#define n_sort(a, n)    sort(a,a+n)
#define precise_impact cout<<setprecision(10)<<fixed;
#define endl         "\n"
// functions...
ll gcd(ll a, ll b){ while (b){ a %= b; swap(a, b);} return a;}
ll lcm(ll a, ll b){ return (a/gcd(a, b)*b);}
ll ncr(ll a, ll b){ ll x = max(a-b, b), ans=1; for(ll K=a, L=1; K>=x+1; K--, L++){ ans = ans * K; ans /= L;} return ans;}
ll bigmod(ll a,ll b){ if(b==0){ return 1;} ll tm=bigmod(a,b/2); tm=(tm*tm)%mod; if(b%2==1) tm=(tm*a)%mod; return tm;}
ll egcd(ll a,ll b,ll &x,ll &y){ if(a==0){ x=0; y=1; return b;} ll x1,y1; ll d=egcd(b%a,a,x1,y1); x=y1-(b/a)*x1; y=x1; return d;}
int main()
{
    ll t;
    cin>>t;
    vector<pair<ll,string> > v;
    while(t--)
    {
        string s;
        ll n;
        cin>>s>>n;
        v.PB({n,s});
    }
    sort(all(v));
    cout<<v[v.size()-2].se<<endl;
}


#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

//union-find
struct uni
{
	vector<int>par,siz;
	int g_;
	uni(int n):par(n),siz(n,1LL),g_(n)
	{
		for(int i=0;i<n;i++)par[i]=i;
	}
	void init(int n)
	{
		par.resize(n);
		siz.assign(n,1LL);
		for(int i=0;i<n;i++)par[i]=i;
	}
	void merge(int x,int y)
	{
		int rx=root(x);
		int ry=root(y);
		if(rx==ry)return;
		g_--;
		if(siz[rx]<siz[ry])swap(rx,ry);
		siz[rx]+=siz[ry];
		par[ry]=rx;
		return;
	}
	int grcount(){return g_;}
	int root(int x){return par[x]==x?x:par[x]=root(par[x]);}
	bool same(int x,int y){return root(x)==root(y);}
	int size(int x){return siz[root(x)];}
};
int bitsum(int bit)
{
	int r=0;
	for(int i=1;i<=bit;i<<=1)if(i&bit)r++;
	return r;
}
main()
{
	int n,m;cin>>n>>m;
	vector<pair<int,int>>ab(m);
	for(auto&[a,b]:ab){cin>>a>>b;a--;b--;}
	long ans=0;
	for(int bit=0;bit<1<<n;bit++)
	{
		uni uf(2*n);
		int flag=0;
		for(auto[a,b]:ab)
		{
			if(!(bit&1<<a)&&!(bit&1<<b)){flag=1;break;}
			if((bit&1<<a)&&(bit&1<<b))uf.merge(a,b+n),uf.merge(b,a+n);
		}
		if(!flag)
		{
			for(int i=0;i<n;i++)if(uf.same(i,i+n)){flag=1;break;}
			if(!flag)ans+=pow(2,uf.grcount()/2-(n-bitsum(bit)));
		}
	}
	cout<<ans<<endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
const ll INF = 1LL << 60;
const ll MOD = 1'000'000'007LL;
const dbl EPS = 1e-12;
const dbl PI = 3.14159265358979323846;
#define coutALL(x)                                \
    for (auto i = x.begin(); i != --x.end(); ++i) \
        cout << *i << ' ';                        \
    cout << *--x.end() << endl;
ll myceil(ll a, ll b)
{
    return (a + (b - 1)) / b;
}
ll myfloor(ll a, ll b) { return a / b; }
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;
}

using Graph = vector<vector<int>>;

vector<bool> seen;
vector<int> colors;
bool valid(const Graph &G, int v, int color)
{
    for (auto nx : G[v])
    {
        if (colors[nx] == color)
            return 0;
    }
    return 1;
}
void dfs(const Graph &G, int v, vector<int> &nodes)
{
    if (seen[v])
        return;
    nodes.push_back(v);
    seen[v] = true;
    for (auto next : G[v])
    {
        dfs(G, next, nodes);
    }
}
void colornize(const Graph &G, const vector<int> &nodes, int idx, ll &num)
{
    if (idx == nodes.size())
    {
        num++;
        return;
    }
    for (int color = 1; color <= 3; ++color)
    {
        if (valid(G, nodes[idx], color))
        {
            colors[nodes[idx]] = color;
            colornize(G, nodes, idx + 1, num);
            colors[nodes[idx]] = 0;
        }
    }
}

void solve()
{
    int N, M;
    cin >> N >> M;
    Graph G(N);
    REP(i, M)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    seen.assign(N, false);
    colors.assign(N, 0);
    vector<int> nodes;
    ll ans = 1;
    REP(start, N)
    {
        if (seen[start])
            continue;
        nodes.clear();
        dfs(G, start, nodes);
        ll tmp = 0;
        colornize(G, nodes, 0, tmp);
        ans *= tmp;
    }
    cout << ans << endl;
}
signed main()
{
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define getchar_unlocked getchar

int A[100005];
int B[100005];
int offset[100005];
int minLevel1[100005];
int minLevel2[100005];
int N, L;

inline int nextInt(){
    int x=0;
    char ch=0;
    do{
        ch=getchar_unlocked();
    }while(ch<'0'||ch>'9');
    while(ch>='0'&&ch<='9'){
        x=10*x+(ch-'0');
        ch=getchar_unlocked();
    }
    return x;
}

int main(){
    N = nextInt();
    L = nextInt();
    for(int i = 1; i <= N; i ++){
        A[i] = nextInt();
        offset[i] = A[i]-i;
    }
    for(int i = 1; i <= N; i ++){
        B[i] = nextInt();
    }

    for(int i = 1; i <= N; i ++){
        minLevel1[i] = 0;
        minLevel2[i] = 0;
        //printf("offset[%d]=%d\n", i, offset[i]);
    }

    long long ans = 0;
    int lo = 1;
    int hi2 = 1;
    for(int i = 1; i <= N; i ++){
        if(A[i] == B[i]){continue;}
        if(B[i] == i || B[i] == L-N+i){
            ans ++;
        }else{
            while(lo < N+2 && offset[lo] < B[i]-i){
                lo ++;
            }

            if((lo == N+2) || (offset[lo] != B[i]-i)){
                printf("-1");
                return 0;
            }

            hi2 = max(hi2, lo);
            while(hi2 < N+2 && offset[hi2] <= B[i]-i){
                hi2 ++;
            }

            int hi = hi2-1;
            //int hi = upper_bound(offset+1, offset+(1+N), B[i]-i) - offset - 1;

            if(lo > i){
                minLevel2[lo] = max(minLevel2[lo], lo - i);
            }else{
                minLevel1[hi] = max(minLevel1[hi], i - hi);
            }

            //printf("i=%d [%d, %d]\n", i, lo, hi);
            //ans += min(abs(lo - i), abs(hi - i));
        }
    }

    for(int i = 1; i <= N; i ++){
        ans += minLevel1[i] + minLevel2[i];
    }

    printf("%lld\n", ans);
    return 0;
}

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

template <typename T>
void print(const vector<T>& a, const string& name = "") {
	if (!name.empty()) cout << name << ": ";
	for (const auto& item : a) {
		cout << item << " ";
	}
	cout << endl;
}

template <typename T1, typename T2>
void print(const pair<T1, T2>& p, const string& name = "") {
	if (!name.empty()) cout << name << ": ";
	cout << "(" << p.first << ", " << p.second << ") " << endl;
}

template <typename T1, typename T2>
void print(const vector<pair<T1, T2>>& pairs, const string& name = "") {
	if (!name.empty()) cout << name << ": ";
	for (const auto& pair : pairs) {
		cout << "(" << pair.first << ", " << pair.second << ") ";
	}
	cout << endl;
}
template <typename T1, typename T2>
void print(const map<T1, T2>& m, const string& name = "") {
	if (!name.empty()) cout << name << ": ";
	for (const auto& p : m) {
		cout << "(" << p.first << ", " << p.second << ") ";
	}
	cout << endl;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int N; cin >> N;
	// you can attain 0..L-N
	int L; cin >> L; L -= N;

	vector<int> A; A.reserve(N+2);
	A.push_back(0);
	for (int i = 0; i < N; i++) {
		int a; cin >> a; a--;
		A.push_back(a-i);
	}
	A.push_back(L);

	vector<int> B; B.reserve(N+2);
	B.push_back(0);
	for (int i = 0; i < N; i++) {
		int a; cin >> a; a--;
		B.push_back(a-i);
	}
	B.push_back(L);

	// A[i] and B[i] store the number of holes to the left of position i.
	// (except for end position, there this does not seem correct).

	N += 2;

	map<int, int> minA;
	map<int, int> maxA;
	map<int, int> minB;
	map<int, int> maxB;

	for (int i = 0; i < N; i++) {
		maxA[A[i]] = i;
		maxB[B[i]] = i;
	}
	for (int i = N-1; i >= 0; i--) {
		minA[A[i]] = i;
		minB[B[i]] = i;
	}

	// minA[h] stores the minimum index at which we
	// have h holes to the left.
	// maxA[h] stores the maximum index at which we have
	// h holes to the left.
	// So if we have 5 penguins in a row without gaps
	// we will have minA[h] = x, maxA[h] = x + 4

	// print(A, "A");
	// print(B, "B");
	// print(minA, "minA");
	// print(maxA, "maxA");
	// print(minB, "minB");
	// print(maxB, "maxB");

	int64_t ans = 0;
	// Loop over minimum index at which we have h holes
	// in the goal state in non-decreasing order of h.
	for (auto it : minB) {
		int v = it.first;
		// cout << "value: " << v << endl;
		if (minA.count(v)) {
			// cout << "minA[v], maxA[v]: " << minA[v] << " " << maxA[v] << endl;
			// cout << "minB[v], maxB[v]: " << minB[v] << " " << maxB[v] << endl;
			// cout << "set minB[" << v << "] to " << min(minB[v], minA[v]) << endl;
			// cout << "set maxB[" << v << "] to " << max(maxB[v], maxA[v]) << endl;
			const int diffA = maxA[v] - minA[v];
			const int diffTotal = max(maxB[v], maxA[v]) - min(minA[v], minB[v]);
			ans += diffTotal - diffA;
			// minB[v] = min(minB[v], minA[v]);
			// maxB[v] = max(maxB[v], maxA[v]);
			// cout << "answer += " << (maxB[v] - minB[v]) - (maxA[v] - minA[v]) << endl;
			// ans += (maxB[v] - minB[v]) - (maxA[v] - minA[v]);
		} else {
			cout << -1 << '\n';
			exit(0);
		}
	}

	cout << ans << '\n';

	return 0;
}