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

#define f(t) ll t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vec vector<ll>
#define vecpair vector<pair<ll,ll>>

using ll = long long;
using ld = long double;

const int N = 2e5 + 5;

int main(){
    IOS;
    int n,product=0;
    cin>>n;
    vector<int>a(n),b(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        product+=a[i]*b[i];
    }
    if(product==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pp pop_back
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f0(i,a,n) for(i=a;i<n;i++)
#define f1(i,a,b) for(i=a;i<=b;i++)
#define all(v) sort(v.begin(),v.end());
#define stp setprecision
#define nl endl
#define I insert
#define ipt(a,n) for(i=0;i<n;i++)cin>>a[i];
#define pll pair<ll,ll>
#define pii pair<int,int>
#define vl vector<ll>
#define mp map<ll,ll>
#define sr(a,n) sort(a,a+n);
#define cx(x) cout<<x<<"\n";
#define cy(x) cout<<x<<" ";
#define cn cout<<"No\n";
#define cw cout<<"Yes\n";
#define bs binary_search
#define S second
#define F first
#define pi 3.141592653589793238
#define ct cout<<
ll sieve[1000001];
void prime()
{
    ll i,j;
    sieve[0]=0,sieve[1]=0;
    for(i=2;i<=1e6;i++)
        sieve[i]=1;
    for(i=2;i<=1e6;i++)
    {
        if(sieve[i]==1)
        {
            for(j=2*i;j<=1e6;j+=i)
                sieve[j]=0;
        }
    }
}
ll be(ll a,ll b,ll m)
{
    ll r=1;
    while(b!=0)
    {
        if(b&1)
            r=(r*a)%m;
        a=(a*a)%m;
        b=b/2;
    }
    return r;
}

int main()
{
    fast;
    //prime();

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n],b[n],i,s=0;
        ipt(a,n);
        ipt(b,n);
        f0(i,0,n)
        s+=a[i]*b[i];
        if(!s)
            cw
        else
            cn
    }
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7
#define INF LONG_MAX/3
#define bit(n) (1LL<<(n))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

string S;
ll K;

ll memo[200005][20];

ll get(ll idx, ll num) {
	if(memo[idx][num] >= 0) return memo[idx][num];

	if(idx == S.size()) {
		if(num == K) return 1;
		return 0;
	}

	ll newnum = 16 - num;
	ll ret = 0;
	//同じのとる
	ret += num * get(idx+1, num);
	ret %= DIV;

	//新しいのとる
	if(newnum > 0) {
		ret += newnum * get(idx+1, num + 1);
		ret %= DIV;
	}
	memo[idx][num] = ret;
	return ret;
}

ll getnum(char ch) {
	if(ch >= '0' && ch <= '9') return ch - '0';
	return ch - 'A' + 10;
}

int main(){
	cin >> S >> K;

	ll ans = 0;
	set<ll> done;

	rep(i, 200005) rep(j, 20) memo[i][j] = -1;

	rep(idx, S.size()) {
		ll num = getnum(S[idx]);

		//ここまで0でここから始まる場合
		if(idx != 0) {
			ans += 15 * get(idx + 1, 1);
			ans %= DIV;
		}

		//ここまで一致してきてここから下回る場合
		ll start = 0;
		if(idx == 0) start = 1;
		for(ll n = start; n < num; n++) {
			if(done.count(n)) {
				ans += get(idx + 1, done.size());
			} else {
				ans += get(idx + 1, done.size() + 1);
			}
			ans %= DIV;
		}

		done.insert(num);
	}
	if(done.size() == K) ans++;

	cout << ans % DIV << endl;
}

#include <bits/stdc++.h>
using namespace std;
/*
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
*/
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"

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

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

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
ll mod_pow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }

const int mod = 1e9 + 7;

void solve() {
    ll N, K;
    cin >> N >> K;

    vector<vector<ll>> dp(4, vector<ll>(3 * N + 1));
    dp[0][0] = 1;
    for (int i = 0; i < 3; i++) {
        vector<ll> imos(3 * N + 2);
        for (ll j = 0; j <= 3 * N; j++) {
            ll l = min(3 * N + 1, j + 1);
            ll r = min(3 * N + 1, j + N + 1);
            imos[l] += dp[i][j];
            imos[r] -= dp[i][j];
        }
        ll now = 0;
        for (int j = 0; j < 3 * N + 1; j++) {
            now += imos[j];
            dp[i + 1][j] = now;
        }
    }

    vector<ll> acc(3 * N + 2);
    for (ll i = 0; i < 3 * N + 1; i++) {
        acc[i + 1] = acc[i] + dp[3][i];
    }

    ll ok = 0;
    ll ng = 3 * N + 1;
    while (ng - ok > 1) {
        ll c = (ok + ng) / 2;
        if (acc[c + 1] < K) {
            ok = c;
        } else {
            ng = c;
        }
    }

    ll sum = ng;
    ll rest = K - acc[ng];
    for (ll i = 1; i <= N; i++) {
        if (rest > dp[2][sum - i]) {
            rest -= dp[2][sum - i];
        } else {
            for (ll j = 1; j <= N; j++) {
                if (rest > dp[1][sum - i - j]) {
                    rest -= dp[1][sum - i - j];
                } else {
                    ll k = sum - i - j;
                    cout << i << " " << j << " " << k << endl;
                    return;
                }
            }
        }
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);

    solve();
}


#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define reps(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repit(i,C) for (auto i = (C).begin(); i != (C).end(); i++)
#define pr(a) cout << a
#define prl(a) cout << (a) << endl
#define prld(a) cout << setprecision(15)<< (a) << endl
#define allrange(a) a.begin(),a.end()

bool solve_translated(vector<pair<int,int>> &S,vector<pair<int,int>> &T){
    int N = S.size();
    int dx = S[0].first-T[0].first;
    int dy = S[0].second-T[0].second;
    bool flg = true;
    reps(i,1,N){
        if(!((S[i].first==T[i].first+dx) && (S[i].second==T[i].second+dy))){flg = false; break;}
    }
    return flg;
}
/*ピタゴラ三角形
    5	12	13
    8	15	17
    3	4	5
*/
vector<pair<int,int>> Pitagora_rot(vector<pair<int,int>> &S,int a, int b , int c){
    int N = S.size();
    vector<pair<int,int>> PS(N);
    auto pt0 = S[0];
    PS[0] = pt0;
    bool flg = true;
    reps(i,1,N){
        int dx = S[i].first - pt0.first;
        int dy = S[i].second - pt0.second;
        int x=dx*a-dy*b;
        int y=dx*b+dy*a;
        if(((x%c)!=0) || ((y%c)!=0)) {flg = false; break;}
        PS[i] = make_pair(x/c+pt0.first, y/c+pt0.second);
    }
    if(flg) return PS;
    else return vector<pair<int,int>>();
}

int main(){
    std::cin.tie(0); // cinとcoutの同期を解除
    std::ios::sync_with_stdio(false);
    int N;cin >> N;

    vector<pair<int,int>> S(N),T(N);
    rep(i,N)
    {
        int x,y;
        cin >> x >> y;
        S[i].first = x;S[i].second = y;
    }

    rep(i,N)
    {
        int x,y;
        cin >> x >> y;
        T[i].first = x;
        T[i].second = y;
    }
    sort(allrange(T));

/*ピタゴラ三角形
    5	12	13
    8	15	17
    3	4	5
*/
/*    vector<vector<int>> tri(12);
    tri[0]={0,1,1};
    tri[1]={-1,0,1};
    tri[2]={0,-1,1};
    tri[3]={1,0,1};
    tri[4]={3,4,5};
    tri[5]={4,3,5};
    tri[6]={-3,4,5};
    tri[7]={-4,3,5};
    tri[8]={-3,-4,5};
    tri[9]={-4,-3,5};
    tri[10]={3,-4,5};
    tri[11]={4,-3,5};*/

    vector<vector<int>> tri(0);
    tri.push_back(vector<int>({3,4,5}));
    tri.push_back(vector<int>({4,3,5}));
    tri.push_back(vector<int>({-1,0,1}));
    tri.push_back(vector<int>({0,-1,1}));
    tri.push_back(vector<int>({-3,4,5}));
    tri.push_back(vector<int>({-4,3,5}));
    tri.push_back(vector<int>({0,1,1}));
    tri.push_back(vector<int>({1,0,1}));
    tri.push_back(vector<int>({-3,-4,5}));
    tri.push_back(vector<int>({-4,-3,5}));
    tri.push_back(vector<int>({3,-4,5}));
    tri.push_back(vector<int>({4,-3,5}));

 //   tri.push_back(vector<int>({-5, -12, 13}));
 //   tri.push_back(vector<int>({-12, -5, 13}));
 //   tri.push_back(vector<int>({-8,-15,17}));
 //   tri.push_back(vector<int>({-15,-8,17}));
 //   tri.push_back(vector<int>({5, 12, 13}));
 //   tri.push_back(vector<int>({12, 5, 13}));
 //   tri.push_back(vector<int>({8,15,17}));
 //   tri.push_back(vector<int>({15,8,17}));
 //   tri.push_back(vector<int>({-5, 12, 13}));
 //  tri.push_back(vector<int>({-12, 5, 13}));
  //  tri.push_back(vector<int>({-8,15,17}));
  //  tri.push_back(vector<int>({-15,8,17}));
 //   tri.push_back(vector<int>({5, -12, 13}));
 //   tri.push_back(vector<int>({12, -5, 13}));
 //   tri.push_back(vector<int>({8,-15,17}));
 //   tri.push_back(vector<int>({15,-8,17}));

    bool flg;

    if(S.size()==2 && T.size()==2){
        auto sx = S[0].first-S[1].first;
        auto sy = S[0].second-S[1].second;
        auto tx = T[0].first-T[1].first;
        auto ty = T[0].second-T[1].second;
        flg= (sx*sx+sy*sy==tx*tx+ty*ty);
    } else {
        rep(j,tri.size()){
            auto S2 = Pitagora_rot(S,tri[j][0],tri[j][1],tri[j][2]);
            if(S2.empty()) continue;
            sort(allrange(S2));
            flg = solve_translated(S2,T);
            if(flg) break;
        }
    }
    if(flg) prl("Yes"); else prl("No");
}

#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
typedef ll fuko[yuzu|10];
fuko a;
map<ll,ll> dp;
ll dfs(ll x,int d) {
  if (!d) return 0;
  if (dp.count(x)) return dp[x];
  ll y=x%a[d];
  if (!y) return 1;
  ll zw=dfs(y,d-1);
  if (y>0&&llabs(x-y+a[d])<a[d+1]) zw+=dfs(y-a[d],d-1);
  if (y<0&&llabs(x-y-a[d])<a[d+1]) zw+=dfs(y+a[d],d-1);
  return dp[x]=zw;
}
int main() {
  int i,n=read();
  ll x; read(x);
  for (i=1;i<=n;++i) read(a[i]);
  a[i]=1e18;
  printf("%lld\n",dfs(x,n));
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int getint()
{
	char ch;
	do{ch=getchar();}while (ch!='-'&&(ch<'0'||ch>'9'));
	int ans=0,f=0;if (ch=='-') f=1; else ans=ch-'0';
	while (isdigit(ch=getchar())) ans=ans*10+ch-'0';
	if (f) ans*=-1;
	return ans;
}
int k,a[2][10];
int num[20];
bool  ch()
{
	for(int i=1;i<=9;i++)
	  num[i]=0;
	for(int i=0;i<=1;i++)
	  for(int j=1;j<=5;j++)
	    num[a[i][j]]++;
	for(int i=1;i<=9;i++)
	  if(num[i]>k)
	    return 0;
	return 1;
}
int acnt(int id)
{
	int ans=0;
	for(int i=1;i<=9;i++)
	  num[i]=0;
	for(int i=1;i<=5;i++)
	  num[a[id][i]]++;
	for(int i=1;i<=9;i++)
	  ans+=pow(10,num[i])*i;
	return ans;
}
long long us[20];
int main()
{
	scanf("%d%d#%d#",&k,&a[0][0],&a[1][0]);
	for(int i=1;i<=9;i++)
	  us[i]=k;
	for(int i=0;i<=1;i++)
	{
		for(int j=1;j<=4;j++)
		{
			a[i][j]=a[i][0]%10;
			a[i][0]/=10;
			us[a[i][j]]--;
		}
	}
	double cnt=0,ans=0;
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			a[0][5]=i;a[1][5]=j;
			if(!ch())continue;
			long long mid;
			if(i==j)
			  mid=us[i]*(us[i]-1);
			else
			  mid=us[i]*us[j];
			cnt+=mid;
			if(acnt(0)>acnt(1))
			  ans+=mid;
		}
	}
//	cout<<ans<<" "<<cnt<<"\n";
	printf("%.7lf",ans/cnt);
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll INF = 1e18;
#define rep(i, n) for(long long i = 0; i < n; i++)
#define rep1(i, n) for(long long i = 1; i <= n; i++)
#define rrep(i, n) for(long long i = n-1; i > 0; i—)
#define rrep1(i, n) for(long long i = n; i >= 0; i—)
//備忘録
//char型　10進数で48が'0'
//long long型の最大値は 9,223,372,036,854,775,807
//文字列の削除 : s.erase(何文字目(イテレータ),何文字)
//二次元配列テンプレ : vector<vector<ll>> a(タテ,vector<ll>(ヨコ));
//s.size()のバグは大抵関係ないところにある
//文字列→数字　stoll(string)
//その逆　to_string(num)
//逆ソート (t.begin(), t.end(), greater<ll>())

int main() {
  ll k; cin >> k;
  string s,t; cin >> s >> t;
  vector<ll> a(10, k);
  rep(i, s.size()-1) a[s[i]-48] -= 1;
  rep(i, t.size()-1) a[t[i]-48] -= 1;

  ll sa=0,sb=0;
  vector<ll> haveA(10, 0);
  vector<ll> haveB(10, 0);
  rep1(i, 9){
    rep(j, s.size()-1) if(s[j]-48 == i) haveA[i] += 1;
    rep(j, t.size()-1) if(t[j]-48 == i) haveB[i] += 1;
    sa += i*pow(10, haveA[i]);
    sb += i*pow(10, haveB[i]);
  }

  ll pk = 0;
  rep1(i, 9) rep1(j, 9){
    ll ca=sa,cb=sb;
    ca = ca - (i*pow(10, haveA[i])) + (i*pow(10, haveA[i]+1));
    cb = cb - (j*pow(10, haveB[j])) + (j*pow(10, haveB[j]+1));
    if(ca > cb){
      if(i != j) pk += a[i]*a[j];
      else if(a[i] >= 2) pk += a[i]*(a[j]-1);
    }
  }
  ll all=0;
  rep1(i, 9) rep1(j, 9){
    if(i != j) all += a[i]*a[j];
    else if(a[i] >= 2) all += a[i]*(a[j]-1);
  }
  double dpk,dall;
  dall = all;
  dpk = pk;
  cout << setprecision(15) << double(dpk/dall) << endl;
  return 0;
}


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

const int N=2e+5+10;
vector<int> adj[N];
pair<int,int> edj[N];
int n,lft[N],rgt[N],t;
long long int c[N];

void dfs(int v,int p)
{
	lft[v]=++t;
	for(auto c:adj[v])
	{
		if(c!=p)
		{
			dfs(c,v);
		}
	}
	rgt[v]=t;
}
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		cin>>edj[i].first>>edj[i].second;
		adj[edj[i].first].push_back(edj[i].second);
		adj[edj[i].second].push_back(edj[i].first);
	}
	t=0;
	dfs(1,0);
	int q;
	cin>>q;
	while(q--)
	{
		int t,i;
		long long int x;
		cin>>t>>i>>x;
		int a=edj[i].first,b=edj[i].second;
		i = b;
		if(lft[a]>lft[b])
		{
			i=a;
			t=3-t;
		}
		if(t==1)
		{
			//i=edj[i].second;
			c[1]+=x;
			c[lft[i]]-=x;
			c[rgt[i]+1]+=x;
			c[n+1]-=x;
		}
		else
		{
			//i=edj[i].second;
			c[lft[i]]+=x;
			c[rgt[i]+1]-=x;
		}
	}
	for(int i=1;i<=n;i++)
	{
		//cout<<lft[i]<<" "<<rgt[i]<<" ";
		c[i]+=c[i-1];
		//cout<<c[i]<<"\n";
	}
	for(int i=1;i<=n;i++)
		cout<<c[lft[i]]<<"\n";
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); ++i)

ll INF = 1ll << 60;

int main(){
  int n;
  cin >> n;
  vl a(n-1), b(n-1);
  vvl g(n, vl(0));
  rep(i, 0, n-1){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }

  vl dps(n,-1);
  dps[0] = 0;
  queue<ll> que;
  que.push(0);
  while(!que.empty()){
    ll d = que.front();
    que.pop();

    for(ll i : g[d]){
      if(dps[i] == -1){
        dps[i] = dps[d]+1;
        que.push(i);
      }
    }
  }

  int q;
  cin >> q;

  vl sum(n);

  rep(i, 0, q){
    ll t, e, x;
    cin >> t >> e >> x;
    e--;
    ll ae, be;
    ae = a[e];
    be = b[e];
    if(dps[ae] > dps[be]){
      t ^= 3;
      swap(ae, be);
    }

    if(t == 1){
      sum[0] += x;
      sum[be] -= x;
    }
    else{
      sum[be] += x;
    }

  }

  que.push(0);

  while(!que.empty()){
    ll d = que.front();
    que.pop();

    for(ll i : g[d]){
      if(dps[i] > dps[d]){
        sum[i] += sum[d];
        que.push(i);
      }
    }
  }

  rep(i, 0, n)
    cout << sum[i] << endl;

  return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define inf 1000000000000000018
int mod = 1e9 + 7;
int po(int x, int y, int m)  { if (y == 0) return 1; int t = po(x, y / 2, m) % m; t = (t * t) % m; if (y & 1) return (t * x) % m;	return t % m; }

void fun() {
	vector<vector<int>> ncr(61, vector<int> (61));
	for (int r = 1; r < 61; ++r)
		ncr[0][r] = 0;
	ncr[0][0] = 1;
	for (int n = 1; n < 61; ++n) {
		ncr[n][0] = 1;
		for (int r = 1; r < 61; ++r) {
			ncr[n][r] = ncr[n - 1][r] + ncr[n - 1][r - 1];
		}
		ncr[n][n] = 1;
	}
	// cout << ncr[4][3];
	int a, b, k;
	cin >> a >> b >> k;
	int n = (a + b);
	for (int i = 0; i < n ; ++i) {
		int cnt = ncr[a - 1 + b][b];
		// cout << (a - 1 + b) << " " << b << " " << cnt << endl;
		if (cnt >= k) {
			cout << 'a';
			a -= 1;
		}
		else {
			cout << 'b';
			b -= 1;
			k -= cnt;
		}
	}
}

signed main() {

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

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);

	int t = 1;
	// cin >> t;
	while (t--) {
		fun();
	}
	// cout << ncr[6][2];

	return 0;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

#define ll long long
#define INF INT_MAX
#define FIO ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define mod 1000000007ll
#define forn(i,n) for(int i=0;i<n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define forba(i,b,a) for(int i=b;i>=a;i--)
#define debx(x) cout << #x << ": " << x << endl
#define debxy(x,y) cout << #x << ": " << x << ' ' << #y << ": " << y << endl
#define YESp cout << "YES" << endl
#define NOp cout << "NO" << endl
#define Yesp cout << "Yes" << endl
#define Nop cout << "No" << endl
#define write(a) cout << a << endl
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vpi vector<pair<int, int>>
#define pq priority_queue

ll fast_exp(ll base, ll power){ll ans=1;while(power){if(power&1)ans=(ans*base)%mod;base=(base*base)%mod;power=power>>1;}return ans%mod;}
ll modInv(ll a,ll p){return fast_exp(a,p-2)%p;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll modFact(ll n){if(n>=mod)return 0;ll result=1;for(ll i = 1; i <= n; i++)result=(result*i)%mod;return result;}

pii moves[] = {{-1, 0}, {1, 0}, {0 ,-1}, {0, 1}};

/****** S ****** X ****** T ****** Y ****** A ****** M ******/
ll ncr(ll n, ll r)
{

    // p holds the value of n*(n-1)*(n-2)...,
    // k holds the value of r*(r-1)...
    long long p = 1, k = 1;

    // C(n, r) == C(n, n-r),
    // choosing the smaller value
    if (n - r < r)
        r = n - r;

    if (r != 0) {
        while (r) {
            p *= n;
            k *= r;

            // gcd of p, k
            long long m = __gcd(p, k);

            // dividing by gcd, to simplify
            // product division by their gcd
            // saves from the overflow
            p /= m;
            k /= m;

            n--;
            r--;
        }

        // k should be simplified to 1
        // as C(n, r) is a natural number
        // (denominator should be 1 ) .
    }

    else
        p = 1;

    return p;
}

int main() {
  FIO
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", sto");
  ll a, b, k;
  cin >> a >> b >> k;
  string ans = "";
  while(a > 0 || b > 0) {
    if(k == 1) {
      forn(i, a) ans += 'a';
      forn(i, b) ans += 'b';
      a = 0;
      b = 0;
      break;
    }
    ll mn = 1, mx = ncr(a+b-1, a-1);
    if(k <= mx) {
      ans += 'a';
      a--;
    } else {
      ans += 'b';
      b--;
      k -= mx;
    }
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define rep(i,a,n) for (int i = a; i < n; i++)
#define SORT(s) sort(s.begin(), s.end())
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
using namespace std;
typedef long long ll;

int main() {

  int n;
  cin >> n;

  int m = pow(2,n);

  vi a(m/2), b(m/2);
  REP(i,m) {
    if(i < m/2) cin >> a[i];
    else cin >> b[i-m/2];
  }

  int amax = 0, bmax = 0, a1, b1;
  REP(i,m/2) {
    if (amax < a[i]) {
      amax = a[i];
      a1 = i+1;
    }
    if (bmax < b[i]) {
      bmax = b[i];
      b1 = i+m/2+1;
    }
  }

  cout << (amax < bmax ? a1 : b1) << endl;

  return 0;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[(1<<n)];
    int maxi = -1,ind;
    for(int i=0;i<(1<<n);i++) {
        cin>>a[i];
        if(maxi<a[i]){
            maxi=a[i];
            ind=i;
        }
    }
    if(ind >= (1<<(n-1)) ){
        maxi=-1;
        for(int i=0;i<(1<<(n-1));i++){
            if(maxi<a[i]){
                maxi=a[i];
                ind=i;
            }
        }
        cout<<ind+1<<endl;
    }
    else{
        maxi=-1;
        for(int i=(1<<(n-1));i<(1<<n);i++){
            if(maxi<a[i]){
                maxi=a[i];
                ind=i;
            }
        }
        cout<<ind+1<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int64_t>;
using vvi = vector<vi>;
using pii = pair<int64_t, int64_t>;
using vvp = vector<vector<pii>>;
int64_t INF = 1e18;
int64_t mod = 1e9+7;

int main() {
  int x;
  cin >> x;
  x = max(0, x);
  cout << x << endl;
}

#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
const long double Pi = 3.141592653;
const ll mod=1e9+7;
long long INF = 1000000000000000000;
bool cmp(pair<int,int>a,pair<int,int>b)
{
    return (a.first<b.first) || (a.first==b.first && a.second<b.second);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;//cin>>t;
    while(t--)
    {
        string x;cin>>x;
        for(int i=0;i<x.length();i++)
        {
            if(x[i]!='.')
            cout<<x[i];
            else
            break;
        }
    }
}


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

#define ll long long

void solve() {
	int n, a;
	string s;
	cin >> n >> a >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'x') {
			if (a > 0) {
				a--;
			}
		} else {
			a++;
		}
	}
	cout << a << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}

#include<bits/stdc++.h>

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

int main() {
    int n;
    double d, h;
    cin >> n >> d >> h;

    double max_h = 0;
    rep(i, n) {
        double x, y;
        cin >> x >> y;
        max_h = max(max_h, (d * y - h * x) / (d - x));
    }
    cout << setprecision(10) << max_h << endl;
}


#include <bits/stdc++.h>

using namespace std;

#define ull unsigned long long
#define ll long long
#define ui unsigned int
#define us unsigned short
#define inf_int 1e9
#define inf_ll 1e18
#define mod 1000000007
#define smod 998244353

const int maxN = 1e5 + 5;

ll table[maxN][2]; // + -
ll cnt[maxN][2];

ll mulmod(ll a, ll b){
	ll ans = 0;

	while(b > 0){
		if(b&1) ans = (ans + a) % mod;

		b >>= 1;
		a = (a+a)%mod;
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);

	int n;
	cin >> n;

	ll data[n];
	for(int x=0;x<n;x++){
		cin >> data[x];
	}

	fill(cnt[0], cnt[n], 0);

	table[0][0] = data[0];
	table[0][1] = 0;
	cnt[0][0] = 1;

	for(int x=1;x<n;x++){
		table[x][0] = (table[x-1][0] + table[x-1][1] + mulmod(cnt[x-1][0]+cnt[x-1][1], data[x])) % mod;
		table[x][1] = (table[x-1][0] - mulmod(cnt[x-1][0], data[x])) % mod;
		cnt[x][0] = (cnt[x-1][0] + cnt[x-1][1]) % mod;
		cnt[x][1] = cnt[x-1][0] % mod;
	}

	cout << (table[n-1][0] + table[n-1][1] + 2*mod) % mod << "\n";
    return 0;
}

#include <cstdio>
#include <algorithm>
#define int long long
const int M = 200005, p = 998244353;
int n, m, f[20][M], fac[M], inv[M], ans;
int Pow(int a, int b) {
	int an = 1;
	while(b) {
		if(b & 1) an = an * a % p;
		a = a * a % p;
		b >>= 1;
	}
	return an;
}
int C(int n, int m) {
	if(n < m) return 0;
	return fac[n] * inv[m] % p * inv[n-m] % p;
}
void init(int n) {
	fac[0] = 1;
	for(int i = 1; i <= n; i++) fac[i] = fac[i-1] * i % p;
	inv[n] = Pow(fac[n], p-2);
	for(int i = n; i >= 1; i--) inv[i-1] = inv[i] * i % p;
}
signed main() {
	scanf("%lld%lld", &n, &m);
	init(n);
	for(int i = 1; i <= m; i++) f[1][i] = 1;
	for(int i = 1; i <= 18; i++)
		for(int j = 1; j <= m; j++)
			for(int k = 2*j; k <= m; k += j)
				f[i+1][k] = (f[i+1][k] + f[i][j]) % p;
	for(int i = 1; i <= std::min(18ll, n); i++)
		for(int j = 1; j <= m; j++)
			ans = (ans + f[i][j] * C(n-1, i-1)) % p;
	printf("%lld", ans);
	return 0;
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t);

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

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

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

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

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}

int main(){

    ll a, b, c, d; cin >> a >> b >> c >> d;

    cout << (a*d-b*c) << endl;

    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (int)(n); i++)
#define INF 1000000000
//配列 vector<型> 配列名(要素数, 初期値);
//二次元配列 vector<vector<型>> 配列名(要素数縦,vector<int>(要素数横, 初期値))
//配列のサイズ(二次元縦) 配列名.size(), 二次元横 配列名[0].size()
// 1秒間のforループは10^8くらい

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

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

int main() {
  int V, S, T, D;
  cin >> V >> T >> S >> D;

  if (V * T > D || V * S < D) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

vector<int> col;
vector<int> ans;
vector<int> col2;
// dfs
// s:始点 i:dfs回数 t:始点からの距離
vector<int> vis;
void dfs(Graph &G, int s, int i) {
    if (col[col2[s]] == 0)
        ans.push_back(s);
    col[col2[s]]++;
    for (int nx : G[s]) {
        if (vis[nx] == i)
            continue;
        vis[nx] = i;
        dfs(G, nx, i);
    }
    col[col2[s]]--;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    col.assign(100001, 0);
    col2.assign(N + 1, 0);
    rep(i, N) { cin >> col2[i + 1]; }
    Graph G(N + 1);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    // main関数内で
    vis.assign(N + 1, -1);
    vis[1] = 0;
    dfs(G, 1, 0); // s:始点 i:dfs回数
    sort(ans.begin(), ans.end());
    rep(i, ans.size()) { cout << ans[i] << "\n"; }
}

#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(long i=0; i<(long)(n);i++)
#define REP(i,s,t) for(long i=s; i<t; i++)
#define RNG(i,s,t,u) for(long i=s; i<t; i+=u)
#define MOD 998244353
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Initpar(long n, vl &par){
  //par = vector<int>(n);
  for(long i=0; i<n; i++) par.at(i) = i;
}

int root(long x, vl &par){
  if(x == par.at(x)) return x;
  else return par.at(x) = root(par.at(x), par);
}

void unite(long x, long y, vl &par){
  long rx = root(x, par);
  long ry = root(y ,par);
  if(rx == ry) return ;
  if(rx < ry) par.at(ry) = rx;
  else par.at(rx) = ry;
}

bool same(long x, long y, vl &par){
  return root(x, par) == root(y, par);
}

void update_par(vl &par){
  for(long i=0;i<par.size();i++){
    root(i, par);
  }
}

int main(){
  long n,k;
  cin >> n >> k;
  vvl a(n, vl(n));
  rep(i,n){
    rep(j,n) cin >> a.at(i).at(j);
  }
  vl permu(n+300,1);
  REP(i,1,n+300){
    permu.at(i) = permu.at(i-1)*i % MOD;
  }
  long ans = 1;
  vl rpar(n);
  vl cpar(n);
  Initpar(n,rpar);
  Initpar(n,cpar);

  rep(i,n){
    REP(j,i+1,n){
      bool flag = true;
      rep(l,n){
        long p = a[i][l] + a[j][l];
        if(p > k){
          flag = false;
          break;
        }
      }
      if(flag){
        unite(i,j,rpar);
      }
    }
  }
  update_par(rpar);
  vl rcnt(n,0);
  rep(i,n){
    rcnt.at(rpar.at(i))++;
  }
  rep(i,n){
    ans = (ans * permu.at(rcnt.at(i))) % MOD;
  }

  rep(i,n){
    //cout << "01" << i << endl;
    //cout << n << endl;
    REP(j,i+1,n){
      //cout << i << j << endl;
      bool flag = true;
      rep(l,n){
        long p = a[l][i] + a[l][j];
        //cout << p << endl;
        if(p > k){
          flag = false;
          break;
        }
      }
      if(flag){
        unite(i,j,cpar);
      }
    }
  }
  update_par(cpar);
  //update_par(cpar);
  vl ccnt(n,0);
  rep(i,n){
    ccnt.at(cpar.at(i))++;
  }
  rep(i,n){
    ans = (ans * permu.at(ccnt.at(i))) % MOD;
  }
  cout << ans << endl;
  if(ans < 0) 3/0;
  //rep(i,n) cout << permu.at(i) << endl;
}


#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int main()
{
  vector<int> v;
  vector<int> u;
  int N,a,b;
  cin>>N;
  for(int i=0;i<N;i++){
      cin>>a;
      v.push_back(a);
  }
  for(int q=0;q<N;q++){
      cin>>b;
      u.push_back(b);
  }
  int result = inner_product(
                v.begin(), v.end(),
                u.begin(),
                0.0f);

  std::cout << (result==0?"Yes":"No") << std::endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000005
#define MOD 1000000007

ll findgcd(ll n,ll m){
    return __gcd(n,m);
}
ll findlcm(ll n,ll m){
    return (n*m)/findgcd(n,m);
}

ll nodig(ll n){
    int ans =0;
    while(n!=0){
        ans+=1;
        n=n/10;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
        ll n,temp=0,cnt=0,sum=0,ans=0;
        cin>>n;
        vector<ll> a(n),b(n);
        rep(i,n) cin>>a[i];
        rep(i,n) cin>>b[i];
        rep(i,n){
            sum+=(a[i]*b[i]);
        }
        if(sum==0) cout<<"Yes";
        else cout<<"No";

return 0;
}


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

#define scd(v) scanf("%d",&v)
#define scld(v) scanf("%ld",&v)
#define sclld(v) scanf("%lld",&v)
#define scs(v) scanf("%s",&v)
#define sclf(v) scanf("%lf",&v)

#define rep(i, j) for(int i = 0;i < j;i++)
#define all(v) v.begin(),v.end()
#define cnt(v,n) count(ALL(v),n)
#define sz(v) v.size()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf int(1e9)
#define ll long long
#define pi 3.14159265358979

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

void solve(){
    int a,b;
    string s;
    cin >> a >> b;
    cin >> s;
    for(int i = 0;s[i];i++){
        if(s[i] == 'x'){
            if(b > 0)b--;
        }else b++;
    }
    cout << b << endl;
}

int main(){
    ios_base::sync_with_stdio(false),cin.tie(0);
    int t=1;
    while(t--) solve();
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MX = 1e5 + 5;

int N, M;
long long int odd, even;
string s[MX];

int main(){
    cin.tie(nullptr), ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> s[i];
    for(int i = 0; i < N; i++){
        int cnt = 0;
        for(char c : s[i]) if(c == '1') cnt++;
        if(cnt % 2 == 0) even++;
        else odd++;
    }
    cout << odd * even;
}


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

int main(){
    int T;
    cin >> T;
    ll tmp;
    for (int i = 0; i < T; i++) {
        cin >> tmp;
        if(tmp%2){
            cout << "Odd" << endl;
        }else if(tmp%4){
            cout << "Same" << endl;
        } else{
            cout << "Even" << endl;
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> v(n, vector<int> (4));
  for (int i = 0; i < n; i++) {
    v.at(i).at(0) = 500 * (i % 20);
    v.at(i).at(1) = 1000 * (i / 20);
    v.at(i).at(2) = v.at(i).at(0) + 500;
    v.at(i).at(3) = v.at(i).at(1) + 1000;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 4; j++) {
      if (j != 3) {
        cout << v.at(i).at(j) << " ";
      }
      else {
        cout << v.at(i).at(j) << 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;

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

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define int long long
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define precise(x) fixed << setprecision(x)

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    if(a == 0) return 0;
    b %= (M - 1);  //M must be prime here

    int res = 1;

    while(b > 0)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }

    return res;
}

const int N = 100;
vector<bool> isprime(N,true);

void solve()
{
   isprime[1] = isprime[0] = 0;

   for(int i=2;i<N;i++)
       if(isprime[i])
        for(int j=i+i;j<N;j+=i) isprime[j] = 0;

   vector<int> pr;

   for(int i=2;i<=72;i++) if(isprime[i]) pr.pb(i);

   int l,r;
    cin >> l >> r;

   int n = r - l + 1;

   vector<int> a(n);
   f(i,n) a[i] = l + i;

   vector<int> mask(n,0);

   f(i,n)
   {
       f(j,20) if(a[i] % pr[j] == 0) mask[i] |= (1<<j);
   }

   vector<int> cur(1<<20,0),nex(1<<20,0);
   cur[0] = 1;

   f(j,n)
   {
       f(i,(1<<20))
       {
           nex[i] = 0;
       }

       f(i,(1<<20))
       {
           nex[i] = cur[i];
       }

       f(i,(1<<20))
       {
           if((i & mask[j]) == 0) nex[i | mask[j]] += cur[i];
       }

       swap(cur,nex);
   }

   cout << accumulate(all(cur),0);
}

signed main()
{
    fast;

    int t = 1;

//    cin >> t;

    while(t--)

    solve();
}

#include<bits/stdc++.h>
using namespace std;
string s;
long long k , diff [300005] , num [300005][20];
long long mod = 1e9 + 7 , dp [200005][3][17] , kk;
map < char , long long > mp;
long long ff ( int x , int on , int dif )
{
    if ( dif > 16 ) return 0;
    if ( x == s . size () )
    {
        if ( dif == k ) return 1;
        else return 0;
    }
    if ( dp [x][on][dif] != -1 ) return dp [x][on][dif];
    long long ans = 0;
    if ( on )
    {
        int eq = mp [ s [x] ];
        for ( int i = 0 ; i <= eq ; i ++ )
        {
            long long last = diff [ x - 1 ];
            if ( x == 0 ) last = 0;
            if ( i < eq )
            {
                if ( num [x][i] == 0 ) ans += ff ( x + 1 , 0 , last + 1 );
                else ans += ff ( x + 1 , 0 , last );
                ans %= mod;
            }
            if ( i == eq ) ans += ff ( x + 1 , 1 , diff [x] );
        }
        ans %= mod;
    }
    else
    {
        ans += ff ( x + 1 , 0 , dif ) * dif;
        ans += ff ( x + 1 , 0 , dif + 1 ) * ( 16 - dif );
        ans %= mod;
    }
    return dp [x][on][dif] = ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    mp ['0'] = 0;
    mp ['1'] = 1;
    mp ['2'] = 2;
    mp ['3'] = 3;
    mp ['4'] = 4;
    mp ['5'] = 5;
    mp ['6'] = 6;
    mp ['7'] = 7;
    mp ['8'] = 8;
    mp ['9'] = 9;
    mp ['A'] = 10;
    mp ['B'] = 11;
    mp ['C'] = 12;
    mp ['D'] = 13;
    mp ['E'] = 14;
    mp ['F'] = 15;
    memset ( dp , -1 , sizeof dp );
    cin >> s >> k;
    for ( int i = 0 ; i < s . size () ; i ++ )
    {
      if ( i )
      {
        for ( int j = 0 ; j <= 16 ; j ++ ) num [i][j] += num [ i - 1 ][j];
      }
        if ( num [i][ mp [ s [i] ] ] == 0 ) kk ++;
        num [i][ mp [ s [i] ] ] ++;
        diff [i] = kk;
    }
    long long add = 0;
    add += ff ( 1 , 1 , diff [0] );
    for ( int i = 1 ; i < mp [ s [0] ] ; i ++ ) add += ff ( 1 , 0 , 1 );
    for ( int i = 1 ; i < s . size () ; i ++ ) add += ff ( i + 1 , 0 , 1 ) * 15;
    cout << add % mod;
}


#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define hell 1000000007
using namespace std;

ll pr (ll x , ll y)
{
    ll ans=1;
    if(y==0) return 1;
    while(y>0)
    {
        if(y%2) ans*=x;
        x*=x;
        y/=2;
        ans%=hell;
        x%=hell;
    }
    return ans;

}

void multiply(ll F[2][2], ll M[2][2]) {
   int a = (F[0][0] * M[0][0])%hell + (F[0][1] * M[1][0])%hell;
   int b= (F[0][0] * M[0][1])%hell + (F[0][1] * M[1][1])%hell;
   int c = (F[1][0] * M[0][0])%hell + (F[1][1] * M[1][0])%hell;
   int d = (F[1][0] * M[0][1])%hell+ (F[1][1] * M[1][1])%hell;
   a%=hell;
   b%=hell;
   c%=hell;
   d%=hell;
   F[0][0] = a;
   F[0][1] = b;
   F[1][0] = c;
   F[1][1] = d;
}
void power(ll F[2][2], ll n) {
   if (n == 0 || n == 1)
      return;
   ll M[2][2] = {{1,1},{1,0}};
   power(F, n / 2);
   multiply(F, F);
   if (n % 2 != 0)
      multiply(F, M);
}
ll ff(ll n) {
   ll F[2][2] = {{1,1},{1,0}};
   if (n == 0)
      return 0;
   power(F, n - 1);
   return F[0][0];
}

ll inv ( ll x)
{
    return pr(x, hell - 2);
}

void solve()
{
  ll n,m,i,j,k,c=0,y=0,ans=0,a=0,b;
  string s;
  cin>>s>>k;
  rep(i,0,k)
  {

      string smin=s,smax=s;
      sort(all(smin));
      sort(all(smax));
      reverse(all(smin));
      int lmax = stoi(smin);
      int lmin = stoi(smax);
      int aa = lmax - lmin;
      //cout<<aa<<endl;
      s = to_string(aa);

  }
  cout<<s;

  }

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    solve();
}

#include<bits/stdc++.h>

using namespace std;

#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  1e5+5;
const ll   mod   =  998244353;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll n, k;

void solve(){
	cin >> n >> k;
	ll ans = 0;
	for(int i = 2; i <= 2 * n; i++){
		ll sum = k + i;
		ll x = i;
		if(sum > 2 * n or sum < 2) continue;
		if(x > n) x -= 2 * (x - (n + 1));
		if(sum > n) sum -= 2 * (sum - (n + 1));
		ans += (x - 1) * (sum - 1);
	}
	deb1(ans)
}

int main(){
	GODSPEED;
	int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; i++){
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
    int a, b, c; cin >> a >> b >> c;
    cout << a + b + c - min(a, (min(b, c))) << endl;
}

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

#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i)
    {
        solve();
    }
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)
void YesNo(bool x) {
    if (x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int sum;
int ABCD[4];

bool dfs(int i, int tmp) {
    if (tmp*2 == sum) {
        return true;
    }
    if (i+1 >= 4) return false;
    else return dfs(i+1, tmp+ABCD[i+1])|dfs(i+1, tmp);
}

int main() {
    sum = 0;
    rep(i, 4) {
        cin >> ABCD[i];
        sum+=ABCD[i];
    }
    YesNo(dfs(-1, 0));
}


#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string>
#include<algorithm>
#include <cstring>
#include<math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdint>
#include <map>
#include <functional>

using namespace std;

typedef long long  ll;
typedef unsigned long long llu;

const int INF = 1 << 29;
const long long mod = 1e9 + 7;
const double pi = 3.141592653589793238;

pair<int, int> mp[201010];

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int sum = a + b + c;
	int min = a;
	min = (a > b) ? b : a;
	min = (min > c) ? c : min;
	cout << sum - min << endl;
	return 0;
}

#include "bits/stdc++.h"
using namespace std;
using ll=int64_t;
using ld=long double;
using ull=unsigned long long;
template <class T>
using grid=vector<vector<T>>;
#define ALL(x) x.begin(),x.end()
#define rep(iter,from,to) for(ll iter=from;iter<to;++iter)

const ll MOD=1e9+7;
const ll INF=1e17;
//#######################################################################
vector<vector<ll>> input(ll N, ll width){
    string str;
    vector<vector<ll>> vec(N,vector<ll>(width));
    for(ll i=0;i<N;++i){
        cin>>str;
        reverse(ALL(str));
        for(ll j=0;j<width;++j){
            vec[i][j]=str.back();
            str.pop_back();
        }
    }
    return vec;
}
void op(vector<ll> vec){
    ll size=(ll)vec.size();
    for(ll i=0;i<size-1;++i) cout<<vec[i]<<" ";
    cout<<vec.back()<<endl;
}

void op(vector<vector<ll>> vec){
    ll height=(ll)vec.size();
    ll width=(ll)vec[0].size();
    for(ll i=0;i<height;++i) {
        for(ll j=0;j<width-1;++j) cout<<vec[i][j]<<" ";
        cout<<vec[i].back()<<endl;
    }
}
//########################################################################

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

int main(void){
    std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (ll i=(ll)N-1; i>=0; i--)
#define popcount __builtin_popcount

const ll LLINF = pow(2,61)-1;
const ll INF = pow(2,30)-1;

ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

const ll MOD = 998244353;
struct MLL {
  ll x, mod;
  MLL(ll y=0, ll m=MOD) { x = y; mod = m; }

  MLL &operator+= (const MLL &p) { x = (x+p.x)%mod;       return *this; }
  MLL &operator-= (const MLL &p) { x = (x-p.x+mod)%mod;   return *this; }
  MLL &operator*= (const MLL &p) { x = (x*p.x)%mod;       return *this; }
  MLL &operator/= (const MLL &p) { x = (x*p.inv().x)%mod; return *this; }
  MLL  operator+  (const MLL &p) const { return MLL(*this)+=p; }
  MLL  operator-  (const MLL &p) const { return MLL(*this)-=p; }
  MLL  operator*  (const MLL &p) const { return MLL(*this)*=p; }
  MLL  operator/  (const MLL &p) const { return MLL(*this)/=p; }
  bool operator== (const MLL &p) const { return x==p.x; }
  bool operator!= (const MLL &p) const { return x!=p.x; }
  bool operator<  (const MLL &p) const { return x< p.x; }
  bool operator<= (const MLL &p) const { return x<=p.x; }
  bool operator>  (const MLL &p) const { return x> p.x; }
  bool operator>= (const MLL &p) const { return x>=p.x; }
  MLL pow(MLL n) const { MLL result(1), p(x); ll tn = n.x; while(tn){ if (tn&1) result*=p; p*=p; tn>>=1; } return result; }
  MLL inv() const { return pow(MOD-2); }
};

MLL operator+ (ll x, MLL p) { return (MLL)x+p; }
MLL operator- (ll x, MLL p) { return (MLL)x-p; }
MLL operator* (ll x, MLL p) { return (MLL)x*p; }
MLL operator/ (ll x, MLL p) { return (MLL)x/p; }

vector<MLL> fac;
void c_fac(ll x=pow(10,7)+10) { fac.resize(x); rep(i,x) fac[i] = i ? fac[i-1]*i : 1; }
MLL nck(MLL n, MLL k) { return fac[n.x]/(fac[k.x]*fac[(n-k).x]); };

ostream &operator<< (ostream &ost, const MLL &p) { return ost << p.x; }
istream &operator>> (istream &ist, MLL &p) { return ist >> p.x; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  c_fac();
  ll N, M; cin >> N >> M;
  MLL dp[21][M+1] = {}; repr(i,1,M+1) dp[1][i] = 1;
  repr(i,1,20) repr(j,1,M+1) {
    for (ll k=2; j*k<=M; k++) {
      dp[i+1][j*k] += dp[i][j];
    }
  }
  // rep(i,20) debug(dp[i],dp[i]+(M+1));

  MLL result = 0;
  repr(i,1,21) {
    if (i>N) break;
    MLL sum = 0; repr(j,1,M+1) sum += dp[i][j];
    result += sum * nck(N-1,i-1);
  }
  cout << result << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod = 998244353;
const int INF = 1e9 + 100;
const ll LINF = 1e18 + 100;

#ifdef DEBUG
#define dbg(x) cout << #x << " = " << (x) << endl << flush;
#define dbgr(s, f) { cout << #s << ": "; for (auto _ = (s); _ != (f); _++) cout << *_ << ' '; cout << endl << flush; }
#else
#define dbg(x) ;
#define dbgr(s, f) ;
#endif
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define fast_io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define endl '\n'

#define MAXN 200100

ll poww(ll a, ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
		b /= 2;
	}
	return res;
}

int n, m;
int siv[MAXN];
ll fact[MAXN];

ll comb(int n, int r)
{
	return fact[n] * poww(fact[r] * fact[n - r] % mod, mod - 2) % mod;
}

int32_t main(void)
{
	fast_io;
	cin >> n >> m;

	fact[0] = 1;
	FOR(i, 1, MAXN) fact[i] = fact[i - 1] * i % mod;

	FOR(i, 2, MAXN)
	{
		if (siv[i]) continue;
		for (int j = i; j < MAXN; j += i)
			siv[j] = i;
	}

	ll ans = 1;
	FOR(k, 2, m + 1)
	{
		vector<int> cnt;
		int cur = siv[k];
		int x = k;
		while (x > 1)
		{
			int c = 0;
			while (siv[x] == cur)
			{
				c++;
				x /= cur;
			}
			cur = siv[x];
			cnt.pb(c);
		}
		ll res = 1;
		for (int u : cnt)
		{
			res = res * comb(u + n - 1, n - 1) % mod;
		}
		ans = (ans + res) % mod;
	}

	cout << ans << endl;

	return 0;
}


// D - Happy Birthday! 2
#include <bits/stdc++.h>
using namespace std;
#define vec vector
using vi = vec<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define sz(a) int(a.size())

int N;
vi A(200);
vec<vi> B(200);
vec<bool> used(200);

void print(int n, vi v){
	cout<< n <<" "; rp(i, 0, n) cout<< v[i] << (i<n-1? " ":"\n");
}

bool dfs(int n, int r, vi C){
	if(sz(C) == n){
		if(!B[r].size()){ B[r] = C; return false; }
		puts("Yes"); print(sz(B[r]), B[r]); print(sz(C), C);
		return true;
	}
	rp(i, C.back(), N){
		if(used[i]) continue;
		used[i] = true;
		C.push_back(i+1);
		if(dfs(n, (r + A[i])%200, C)) return true;
		C.pop_back();
		used[i] = false;
	}
	return false;
}

int main(){
	cin>>N;
	for(int&x:A) cin>>x;
	rp(n, 1, N+1) rp(i, 0, N) if(dfs(n, A[i]%200, {i+1})) return 0;
	puts("No");
}


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

int main(){
	double t; ll n; cin>>t>>n;
	double r=(100.0*n+t-1)/t;
	cout<<(ll)r+(n-1)<<endl;
}

#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    lint t, n;
    cin >> t >> n;

    lint ans;

    for(lint i = 1 ; ; ++i){
        lint a = (100 * i) / (100 + t);
        lint b = a + 1;
        if((100 + t) * a / 100 != i && (100 + t) * b / 100 != i){
            ans = i;
            break;
        }
    }

    ans += (n - 1) / t * (100 + t);

    lint nokori = (n - 1) % t;

    while(nokori > 0){
        ++ans;
        lint a = (100 * ans) / (100 + t);
        lint b = a + 1;
        if((100 + t) * a / 100 != ans && (100 + t) * b / 100 != ans){
            --nokori;
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int,int> Pii;
#define reg register
#define mp make_pair
#define pb push_back
#define Mod1(x) ((x>=P)&&(x-=P))
#define Mod2(x) ((x<0)&&(x+=P))
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
template <class T> inline void cmin(T &a,T b){ ((a>b)&&(a=b)); }
template <class T> inline void cmax(T &a,T b){ ((a<b)&&(a=b)); }

char IO;
template <class T=int> T rd(){
	T s=0; int f=0;
	while(!isdigit(IO=getchar())) f|=IO=='-';
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}

const int N=2e5+10,INF=1e9+10;

int n;
vector <int> G[N];
int F[N][20],D[N],E[N],L[N];
int ma=-1,id;
void dfs(int u,int f) {
	if(D[u]>ma) ma=D[u],id=u;
	F[u][0]=f,E[u]=D[u];
	rep(i,1,18) F[u][i]=F[F[u][i-1]][i-1];
	for(int v:G[u]) if(v!=f) D[v]=D[u]+1,dfs(v,u),cmax(E[u],E[v]);
	L[u]=G[u][0]==f?(G[u].size()==1?0:G[u][1]):G[u][0];
	sort(G[u].begin(),G[u].end(),[&](int x,int y){ return E[x]<E[y]; });
}
int LCA(int x,int y){
	if(D[x]<D[y]) swap(x,y);
	for(int del=D[x]-D[y],i=0;(1<<i)<=del;++i) if(del&(1<<i)) x=F[x][i];
	if(x==y) return x;
	drep(i,18,0) if(F[x][i]!=F[y][i]) x=F[x][i],y=F[y][i];
	return F[x][0];
}
int Dis(int x,int y){ return D[x]+D[y]-2*D[LCA(x,y)]; }

int lst;
ll Ans=1e18,A[N],M,B[N];
void dfs2(int u,int f) {
	//cout<<u<<' ';
	if(!lst) A[lst=u]=1;
	else A[u]=A[lst]+Dis(lst,u),lst=u;
	M=A[u];
	for(int v:G[u]) if(v!=f) dfs2(v,u);
}

void Work(int u){
	lst=0;
	dfs(u,0),dfs2(u,0);
	if(M<Ans) {
		Ans=M;
		rep(i,1,n) B[i]=A[i];
	}
	//puts("");
}

int main(){
	n=rd();
	rep(i,2,n) {
		int u=rd(),v=rd();
		G[u].pb(v),G[v].pb(u);
	}
	dfs(1,0),Work(id);
	int u=1;
	while(L[u]) u=L[u];
	Work(u);
	while(L[u]) u=L[u];
	Work(u);
	ll ans=0;
	rep(i,1,n) cmax(ans,B[i]);
	//printf("%lld\n",ans);
	rep(i,1,n) printf("%lld ",B[i]);
}

#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <string>
#include <list>
#include <map>
using namespace std;

int min(int a,int b){
    if(a>b){
        return b;
    }else{
        return a;
    }
}

long long int max(long long int a,long long int b){
    if(a>b){
        return a;
    }else{
        return b;
    }
}

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

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

void f(vector<vector<int>>& a,vector<vector<int>>& b,int N,int K){
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            int l=0;
            for(int k=0;k<N;k++){
                if(a[k][i]+a[k][j]>K){
                    break;
                }
                l+=1;
            }
            if(l==N){
                b[i][j]=1;
                b[j][i]=1;
            }
        }
    }
}

void g(vector<vector<int>>& a,vector<vector<int>>& c,int N,int K){
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            int l=0;
            for(int k=0;k<N;k++){
                if(a[i][k]+a[j][k]>K){
                    break;
                }
                l+=1;
            }
            if(l==N){
                c[i][j]=1;
                c[j][i]=1;
            }
        }
    }
}

int h(vector<vector<int>>& b,vector<int>& x,int N){
    int M=1;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        a[i]=0;
    }
    stack<int> d;
    for(int i=0;i<N;i++){
        int j=0;
        if(a[i]==0){
            d.push(i);
            a[i]=1;
        }
        while(!d.empty()){
            int k=d.top();
            d.pop();
            j+=1;
            for(int l=0;l<N;l++){
                if(b[k][l]==1 && a[l]==0){
                    d.push(l);
                    a[l]=1;
                }
            }
        }
        if(j>1){
            x.push_back(j);
            M=max(M,j);
        }
    }
    return M;
}

int main(){
    long long int r1,r2,c1,c2;
    cin>>r1>>c1>>r2>>c2;
    int ans=3;
    if(r1==r2 && c1==c2){
        ans=min(ans,0);
    }
    if(r1+c1==r2+c2 || r1-c1==r2-c2 || abs(r1-r2)+abs(c1-c2)<=3){
        ans=min(ans,1);
    }
    if(abs(r1-c1)%2==abs(r2-c2)%2){
        ans=min(ans,2);
    }
    if(r1-r2-c1+c2<=3 && r1-r2-c1+c2>=-3){
        ans=min(ans,2);
    }
    if(-r1+r2-c1+c2<=3 && -r1+r2-c1+c2>=-3){
        ans=min(ans,2);
    }
    if(abs(r1-r2)+abs(c1-c2)<=6){
        ans=min(ans,2);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int mask_to_int(string s)
{
    int ret = 0;
    for (size_t i = 0; i < s.size(); ++i)
        ret = (ret * 2) + (s[i] == '1');
    return ret;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        a[i] = mask_to_int(s);
    }

    // cnt[1][x] = number of y differ x in last 10 bits that cnt diff = odd
    vector<int> cnt[2];

    const int SECOND_HALF = (1 << 10) - 1;

    cnt[0].resize(1 << 20);
    cnt[1].resize(1 << 20);

    for (int x : a) {
        int first = x >> 10;
        for (int second = 0; second < 1 << 10; ++second) {
            int p = __builtin_popcount((x & SECOND_HALF) ^ second) & 1;
            ++cnt[p][(first << 10) | second];
        }
    }

    long long res = 0;
    for (int x : a) {
        int second = x & SECOND_HALF;
        for (int first = 0; first < 1 << 10; ++first) {
            int p = __builtin_popcount((x >> 10) ^ first) & 1;
            res += cnt[!p][(first << 10) | second];     // we count pairs with odd diff, hence !p
        }
    }

    cout << res / 2;
    return 0;
}

#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#include <algorithm>
#include <iostream>
#include <utility>
#include <cstring>
#include <cassert>
#include <vector>
#include <random>
#include <cstdio>
#include <string>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#define MOD 1000000007LL
typedef long long ll;
typedef std::pair < int, int > pii;
int main() {
    ll n, k;
    scanf("%lld%lld", &n, &k);
    for (; k--; ) {
        if (n % 200 == 0) n /= 200;
        else n = n * 1000 + 200;
    }
    printf("%lld\n", n);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int h, w, a, b, res;

void dfs(int idx, int bt, int a, int b)
{
    if (idx == h * w)
        ++res;

    if (bt & (1 << idx))
        dfs(idx + 1, bt, a, b);

    if (b)
        dfs(idx + 1, bt | (1 << idx), a, b - 1);

    if (a)
    {
        if (!(bt & (1 << (idx + 1))) && idx % w < w - 1)
            dfs(idx + 2, bt | (1 << idx) | (1 << (idx + 1)), a - 1, b);

        if (idx + w < w * h && !(bt & (1 << (idx + w))))
            dfs(idx + 1, bt | (1 << idx) | (1 << (idx + w)), a - 1, b);
    }
}

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

    cin >> h >> w >> a >> b;
    dfs(0, 0, a, b);
    cout << res;
}

#include<bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
using namespace std;

 // Ordered Set  VSCODE M KAM NI KARRA PATANI KIA DARD HAI
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loop1(i,a,b) for(int i=a;i<=b;i++)
#define rloop(i,a,b) for(int i=a;i>b;i--)
#define rloop1(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
//#define mp make_pair
#define pii pair<int,int>
//#define int   long long
#define min_heap priority_queue <int, vector<int>, greater<int> >
#define ff first
#define ss second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define MOD 1000000007
//#define modInv(a) binExp(a,mod-2)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test int t;cin>>t;while(t--)
#define nl "\n"
#define ceill(a,b) (a/b)+((a%b)!=0)
//-------------------------IMPORTANT FUNCTIONS START---------------------
int powr(int x,  int y)
{
    int res = 1;

    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

/*ll power(ll a, ll b, ll mod){
	ll x = 1LL, y = a;
	while (b > 0LL){
		if (b%2LL){
			x = (x*y);
			if(x>mod) x%=mod;
		}
		y = (y*y);
		if(y>mod) y%=mod;
		b /= 2LL;
	}
	return x;
}*/

bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i <=sqrt(n); i++)
        if (n % i == 0)
            return false;

    return true;
}

int lcm(int a, int b)
{
    return (a / __gcd(a, b)) * b;
}
//-------------------------IMPORTANT FUNCTIONS END---------------------
// a^b=a+b-2*(a&b)
// for xor same hai to 0 different hai to 1
//gcd(a,b)=gcd(a,b-a)
//gcd(a,b,c)=gcd(a,gcd(b,c))=gcd(gcd(a,b),c)=gcd(a,b-a,c)=gcd(a,c,b-a)=gcd(a,c-a,b-a)
// tin tout concept can be used to find the ancestors of node
// if an array size increases from n to n+1 no.of subarray's increases by n+1
// ceil use karna hai to ceill(a,b) kar
// TLE ya MLE aye to ek bar long long hatake try kar
int func(int x,int y,int h,int w,int arr[17][17],int a1,int b1){
    int sum=0;

    if(y>h){
        y=1;
        x++;
    }
    if(x>w)return 1;
    if(arr[x][y]==1){
        sum=0;
        sum+=func(x,y+1,h,w,arr,a1,b1);
        return sum;
    }
    if((x+1)<=w and a1>0){
        int cpy[17][17];
        loop(i,0,17)loop(j,0,17)cpy[i][j]=arr[i][j];
        cpy[x][y]=1;
        cpy[x+1][y]=1;
        //a1--;
        sum+=func(x,y+1,h,w,cpy,a1-1,b1);
    }
    if(y+1<=h and a1>0){
         int cpy[17][17];
        loop(i,0,17)loop(j,0,17)cpy[i][j]=arr[i][j];
        cpy[x][y]=1;
        cpy[x][y+1]=1;
       // a1--;
        sum+=func(x,y+1,h,w,cpy,a1-1,b1);
    }
    if(b1>0){
          int cpy[17][17];
        loop(i,0,17)loop(j,0,17)cpy[i][j]=arr[i][j];
        cpy[x][y]=1;

        sum+=func(x,y+1,h,w,cpy,a1,b1-1);
    }

    return sum;
}
void solve(){
   int h,w,a1,b1;
   cin>>h>>w>>a1>>b1;
   int arr[17][17];
   memset(arr,0,sizeof(arr));
   cout<<func(1,1,h,w,arr,a1,b1);
}
 signed  main()
{
 fast

// cout<<fixed<<setprecision(15);

    //test
    solve();

}


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

#define ll long long

#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define fill(a,b) memset(a,b,sizeof(a))

#define f first
#define s second
#define pb push_back

#define inf 1e17
#define ninf -1*1e17
#define mod 1000000007
#define N 500005
#define Ns 5005
#define hsum 600000
string s;
ll n,m,o,x,y,z,d,k,l,r;
ll a[N];

ll dp[102][hsum];
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

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

	   // ll ans=0;
	    cin>>n>>k>>m;

	    dp[0][0]=1;

	    for(int i=0;i<=n;i++){
	        for(int j=0;j<=hsum;j++){
	            ll cnt=0;
	            if(j-i>=0){
	                cnt=(cnt+dp[i][j-i])%m;
	            }
	            if(i-1>=0){
	                cnt=(cnt+dp[i-1][j])%m;
	            }
	            if(i-1>=0 && (j-(k+1)*i) >=0){
	                cnt=(cnt-dp[i-1][j-(k+1)*i]+m)%m;
	            }
	            dp[i][j]=cnt;
	        }
	    }

	    for(int i=1;i<=n;i++){

	        ll ans=0;
	        for(int j=1;j<=hsum;j++){
	            if(i-1>=0 && n-i >=0)
	             ans=(ans+(dp[i-1][j]*dp[n-i][j])%m)%m;
	        }
	        ans=(ans*(k+1))%m;
	        ans=(ans-1+m)%m;
	        cout<<ans<<"\n";
	    }

	    //cout<<ans<<"\n";

	}
	return 0;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define N 111
#define NN 401000
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
int n, K, P;
int ans[N], lmt[N];
int f[2][NN], g[2][NN], sum[NN];
inline void Try(int mid) {
	memset(f, 0, sizeof(f));
	memset(g, 0, sizeof(g));
	memset(sum, 0, sizeof(sum));
	int up = min(lmt[mid - 1], lmt[n - mid]);
	int nw = 0; f[nw][0] = 1;
	for (int i = 1; i < mid; ++i) {
		nw ^= 1;
		int d = mid - i;
//		ll del = 0;
		for (int j = 0; j <= up; ++j) {
			if (j - d >= 0)	sum[j] = (sum[j - d] + f[nw ^ 1][j]) % P;
			else	sum[j] = f[nw ^ 1][j];
		}
		for (int j = 0; j <= up; ++j) {
			if (j - (K+1) * d < 0)	f[nw][j] = sum[j];
			else	f[nw][j] = (sum[j] - sum[j - (K+1) * d] + P) % P;
		}
	}
	if (nw)	memcpy(f[0], f[1], sizeof(f[1]));
	nw = 0; g[nw][0] = 1;
	for (int i = mid + 1; i <= n; ++i) {
		nw ^= 1;
		int d = i - mid;
		for (int j = 0; j <= up; ++j) {
			if (j - d >= 0)	sum[j] = (sum[j - d] + g[nw ^ 1][j]) % P;
			else	sum[j] = g[nw ^ 1][j];
		}
		for (int j = 0; j <= up; ++j) {
			if (j - (K+1) * d < 0)	g[nw][j] = sum[j];
			else	g[nw][j] = (sum[j] - sum[j - (K+1) * d] + P) % P;
		}
	}
	if (nw)	memcpy(g[0], g[1], sizeof(g[1]));
	for (int j = 0; j <= up; ++j) if (f[0][j] && g[0][j]) {
		ans[mid] = (ans[mid] + 1ll * f[0][j] * g[0][j] % P * (K + 1)) % P;
	}
}
int main() {
	read(n), read(K), read(P);
	for (int i = 1; i <= n; ++i)	lmt[i] = lmt[i - 1] + K * i;
	for (int i = 1; i <= (n + 1) >> 1; ++i)	Try(i);
	for (int i = 1; i <= n; ++i) if (!ans[i])	ans[i] = ans[n - i + 1];
	for (int i= 1; i <= n; ++i) {
		printf("%d\n", ((ans[i] - 1 + P) % P + P) % P);
	}
	return 0;
}

/*
3 1 998244353
//1 3 1

10 8 861271909

100 100 7
*/


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

int main() {
	ll a,b,c;
	cin>>a>>b>>c;

	ll x = max(a,max(b,c));

	if(a == x) a = -1;
	else if(b == x) b = -1;
	else if(c == x) c = -1;

	x += max(a,max(b,c));
	cout<<x<<"\n";
}

#include<bits/stdc++.h>
using namespace std;
// #define int  long long int
#define ld   long double
#define F    first
#define S    second
#define P    pair<int,int>
#define pb   push_back
#define mod  1000000007
#define endl '\n'
const int N = 1e5 + 5; //change it when n7eeded
void solve() {
    int a[3];
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }

    sort(a, a + 3);
    cout << a[1] + a[2] << endl;
}
int32_t main() {
    ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    // int t; cin >> t; while (t--)
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long arr[300010];
long long arr2[300010];
int main()
{

    long long a,b,c,d,e,i,j;
    cin >> a >> b;

    long long k=0,chk=0;
    for(i=0;i<a;i++)
    {
        cin >> d;
        arr[d]++;
        chk=max(d,chk);
        k=max(arr[d],k);

    }
    for(i=0;i<=chk;i++){
            if(i==0)
       arr2[i]=min(arr[i],b);
      else{
        arr2[i]=min(arr[i],arr2[i-1]);
      }
      if(arr2[i]==0)
        break;

    }
    long long past=0,sum=0;
    for(i=chk;i>=0;i--){
            long long present=arr2[i];
            sum=sum+(present-past)*(i+1);
            past=present;

    }
    cout << sum << endl;

}

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<complex>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
#define removeduplicates(vec) vec.erase( unique( vec.begin(), vec.end() ), vec.end() )
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	ll n,k;
	cin>>n>>k;
	int a[n];
	int mp[n+1]={0};
	int maxi=0;
	rep(i,n){
		cin>>a[i];
		mp[a[i]]++;
		maxi=max(maxi,a[i]);
	}
	ll ans=0;
	mp[maxi+1]=0;
	for(ll x=0;x<=n;x++){
		ll f=mp[x];
		ll can=min(f,k);
		ans+=(k-can)*x;
		k=can;
	}
	cout<<ans;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}


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

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

  if(s[0] == s[1] && s[0] == s[2]){
    cout << "Won" << endl;
  }else{
    cout << "Lost" << endl;
  }
}

#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  set<char> var(begin(s),end(s));
  if(var.size()==1){
    cout<<"Won";}
  else{
    cout<<"Lost";}}


#include <bits/stdc++.h>
#ifdef DEBUG_BUILD
# include "debugger.hpp"
#else
# define debug(...)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using pll = std::pair<ll, ll>;
template <class T> using vec = std::vector<T>;
template <class T> using vec2 = std::vector<vec<T>>;
template <class T> using vec3 = std::vector<vec2<T>>;
#define rep(i, N) for (ll i = 0; i < (N); i++)
#define rrep(i, N) for (ll i = (N) - 1; i >= 0; i--)
#define range(i, A, B) for (ll i = (A); i < (B); i++)
constexpr int MOD = 1000000007;
constexpr ll INFL = std::numeric_limits<ll>::max();
template <class T> bool chmax(T &a, const T b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T b) { if (a > b) { a = b; return true; } return false; }

ll pow10(ll n) {
    ll r = 1;
    rep(i, n) {
        r *= 10;
    }
    return r;
}

ll score(const string& s, ll n) {
    vec<ll> count(10);
    rep(i, 4) {
        count[s[i] - '0']++;
    }
    count[n]++;
    ll point = 0;
    rep(i, 10) {
        point += i * pow10(count[i]);
    }
    return point;
}

void Main()
{
    ll K;
    string S, T;
    cin >> K >> S >> T;

    vec<ll> remc(10, K);
    remc[0] = 0;
    rep(i, 5) {
        remc[S[i] - '0']--;
        remc[T[i] - '0']--;
    }

    ll ret = 0;
    for (ll send = 1; send <= 9; send++) {
        if (remc[send] == 0)
            continue;
        debug(send);

        const ll ss = remc[send];
        debug(ss);

        remc[send]--;
        for (ll tend = 1; tend <= 9; tend++) {
            if (remc[tend] == 0)
                continue;
            debug(tend);

            const ll ts = remc[tend];
            const ll sc = score(S, send);
            const ll tc = score(T, tend);
            debug(sc, tc);

            if (sc > tc) {
                ret += ss * ts;
            }
        }
        remc[send]++;

        debug(ret);
    }

    cout << (ld)ret / ((9*K-8)*(9*K-9)) << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(10);
    Main();
    std::cout << std::flush;
    return 0;
}

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

int main(){

long long k;
cin>>k;
long long count1[10]={0};
long long count2[10]={0};
long long count3[10]={0};
for(long long i=1;i<=9;i++){
  count3[i]=k;
}
string s;
string t;
cin>>s;
cin>>t;
for(long long i=0;i<4;i++){
  count1[s[i]-'0']++;
  count3[s[i]-'0']--;
}
for(long long i=0;i<4;i++){
  count2[t[i]-'0']++;
  count3[t[i]-'0']--;
}
long long sum1=0;
long long sum2=0;
long long temp=(9*k-8)*(9*k-9);
long long sum3=0;
for(long long i=1;i<=9;i++){
  sum1+=i*pow(10,count1[i]);
  sum2+=i*pow(10,count2[i]);
}

for(long long i=1;i<=9;i++){
  for(long long j=1;j<=9;j++){
    if(i==j){
      if((sum1-i*pow(10,count1[i])+i*pow(10,count1[i]+1))>(sum2-j*pow(10,count2[j])+j*pow(10,count2[j]+1))){
        sum3+=(count3[i])*(count3[i]-1);

      }
    }
    else{
      if((sum1-i*pow(10,count1[i])+i*pow(10,count1[i]+1))>(sum2-j*pow(10,count2[j])+j*pow(10,count2[j]+1))){
        sum3+=(count3[i])*(count3[j]);

      }
    }
  }
}

double ans=(double)((double)sum3/temp);
printf("%.16f", ans);
return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

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

using namespace std;
using namespace __gnu_pbds;

#define LL long long
#define int long long
#define ull unsigned long long
#define fi first
#define se second
#define pll pair<LL, LL>
#define pii pair<int, int>
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define SZ(x) ((int)(x.size()))
#define LC (id<<1)
#define RC (id<<1|1)

constexpr int N = 1e3+9;
constexpr int M = 1e9+7;
#ifdef int
constexpr int INF = 0x3f3f3f3f3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcfcfcfcfcf;
#else
constexpr int INF = 0x3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcf;
#endif

int n;
char aa, ab, ba, bb;

int fact[N], inv[N];
int qpow(int a, int b){
    int c = 1;
    while(b){
        if(b & 1) c = c * a % M;
        a = a * a % M;
        b >>= 1;
    }
    return c;
}
int C(int n,int m){
    if(n < 0 || m > n) return 0;
    return fact[n] * inv[m] % M * inv[n-m] % M;
}
void init(){
    fact[0] = 1;
    for (int i = 1; i < N; i++) fact[i] = fact[i-1] * i % M;
    inv[N-1] = qpow(fact[N-1], M - 2);
    for(int i= N-2; i >= 0; i--) inv[i] = inv[i+1] * (i+1) % M;
}
void add(int& x, int y) {
    x %= M, y %= M;
    x = (x + M + y) % M;
}
int Lucas(int n, int m) {
    if(n < 0 || m > n) return 0;
    if (m == 0) return 1;
    return (C(n % M, m % M) * Lucas(n / M, m / M)) % M;
}

// 想清楚计数的依据

signed main() {
    fastio;
    init();
    cin >> n >> aa >> ab >> ba >> bb;
    if (n <= 3) {
        cout << 1 << "\n";
        return 0;
    }
    if (ab == 'A') {
        if (aa == 'A') {
            cout << 1 << "\n";
        } else {
            if (ba == 'A') {
                int ans = 0;
                for (int innerB = 0; innerB*2+2 <= n; innerB++) {
                    add(ans, C(n-1-innerB-1, innerB));
                }
                cout << ans << "\n";
            } else {
                cout << qpow(2, n-3) << "\n";
            }
        }
    } else {
        if (bb == 'B') {
            cout << 1 << "\n";
        } else {
            if (ba == 'B') {
                int ans = 0;
                for (int innerB = 0; innerB*2+2 <= n; innerB++) {
                    add(ans, C(n-1-innerB-1, innerB));
                }
                cout << ans << "\n";
            } else {
                cout << qpow(2, n-3) << "\n";
            }
        }
    }
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin >> a>>b>>c>>d;
    cout << max(a,b)-min(c,d);
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
string p[520];
signed main(){
	int mx = 0;
	int h,w;
	cin >> h >> w;
	int ans = 1;
	for(int i = 0;i < h;i++){
		cin >> p[i];
	}

	bool able = true;
	for(int i = 0;i < w;i++){
		int sti = i;
		int stj = 0;
		bool c = true;
		int cnt = 0;
		map<char,int> mp;
		while(sti >= 0 && stj < h){
			if(p[stj][sti] != '.'){
				if(mp[p[stj][sti]] == 0){
					cnt += 1;
					mp[p[stj][sti]] = 1;
					if(cnt == 2)able = false;
				}
				c = false;
			}
			sti--;
			stj++;
		}
		if(c) ans = (ans * 2ll)% 998244353;
	}
	for(int i = 1;i < h;i++){
		int sti = w - 1;
		int stj = i;
		bool c = true;
		int cnt = 0;
		map<char,int> mp;
		while(sti >= 0 && stj < h){
			if(p[stj][sti] != '.'){
				if(mp[p[stj][sti]] == 0){
					cnt += 1;
					mp[p[stj][sti]] = 1;
					if(cnt == 2)able = false;
				}
				c = false;
			}
			sti--;
			stj++;
		}
		if(c) ans = (ans * 2ll)% 998244353;
	}
	if(able == true)cout << ans << endl;
	else cout << 0 << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define reg register
#define For(i,a,b) for(reg int i=a;i<=b;++i)
#define Down(i,a,b) for(reg int i=a;i>=b;--i)
#define ull unsigned long long
#define ll long long
inline int max(int x,int y){return x>y?x:y;}
inline int min(int x,int y){return x<y?x:y;}
inline int gcd(int n,int m){return m?gcd(m,n%m):n;}
inline int lcm(int x,int y){return x/gcd(x,y)*y;}
inline void swap(int &x,int &y){int t=x; x=y; y=t; return ;}
namespace yspm{
	inline int read(){
	    int res=0,f=1; char k;
	    while(!isdigit(k=getchar())) if(k=='-') f=-1;
	    while(isdigit(k)) res=res*10+k-'0',k=getchar();
	    return res*f;
    }
    const int N=510;
    char s[N<<1][N<<1];
    int n,m;
	signed main(){
	    n=read(); m=read(); For(i,1,n) scanf("%s",s[i]+1);
	    for(reg int i=1;i<=m+n;++i) for(reg int j=1;j<=m+n;++j) if(s[i][j]==0) s[i][j]='.';
	    int ans=1;
	    if(s[n][m]=='.') ans*=2;
	    for(reg int S=2;S<n+m;++S){
	        bool ad=1; char dif='.';
	        for(reg int j=1;j<S;++j){
	            if(s[S-j][j]!='.'){
	                ad=0;
	                if(dif=='.') dif=s[S-j][j];
	                else if(s[S-j][j]!=dif) puts("0"),exit(0);
                }
	        } if(ad) ans=ans*2%998244353;
	    } cout<<ans<<endl;
		return 0;
    }
}signed main(){return yspm::main();}
//Use The Time To Enrich This Selfclosing Youth


#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;

#define int         long long
#define ull         unsigned long long
#define ll          long long
#define M           998244353
#define pb          push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp          make_pair
#define lb          lower_bound
#define ub          upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for (int i=begin;i<end;i++)
#define repd(i, begin, end) for (int i=end-1;i>=begin;i--)
#define ini(a,n,b)  for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)     __builtin_popcountll(a)
#define hell        1000000007
#define re          resize
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update >
const int INF=1e18;
const int N=3e5+5;

int powm(int a,int b,int mod)
{
  int res=1;
  while(b)
  {
    if(b&1)
    res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
  }

  return res;
}

int pow(int a,int b)
{
  int res=1;
  while(b)
  {
    if(b&1)
    res=(res*a);
      a=(a*a);
      b>>=1;
  }

  return res;
}

vi par(N,1),siz(N,1);

void init(int n)
{
   for(int i=1;i<=n;i++) par[i]=i;
}
int find(int x)
{
   if(par[x]==x) return x;
   return par[x]=find(par[x]);
}
void merge(int x,int y)
{
   x=find(x);
   y=find(y);
   if(x==y) return;
   if(siz[x]<siz[y]) swap(x,y);
   par[y]=x;
   siz[x]+=siz[y];
}

signed main(void)
{ios
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);freopen("answer.txt", "w", stdout);
    #endif

    int tests=1;
    // cin>>tests;
    while(tests--)
    {
      int n;
      cin>>n;
      vi a(n+1);
      rep(i,1,n+1) cin>>a[i];
      int ans=0;
      vi vis(n+1,0);
      init(n);

      rep(i,1,n+1)
      {
         merge(i,a[i]);
      }

      rep(i,1,n+1)
      {
         if(par[i]==i) ans++;
      }
      ans=powm(2,ans,M);
      ans=(ans-1+M)%M;
      cout<<ans<<endl;
    }

}

#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;

template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
    if (a > b) a = b;
}

template <typename T>
struct BIT {
    int n;
    vector<T> dat;

    BIT(int n) : n(n), dat(n + 1, 0) {}

    T sum(int idx) {  // 1-indexed
        T res(0);
        for (int i = idx; i > 0; i -= i & -i) res += dat[i];
        return res;
    }

    T sum(int l, int r) {  // 0-indexed
        return sum(r) - sum(l);
    }

    void add(int idx, T x) {  // 0-indexed
        idx++;
        for (int i = idx; i <= n; i += i & -i) dat[i] += x;
    }

    int lower_bound(T x) {
        if (x <= 0) return T(0);
        int res = 0, r = 1;
        while (r < n) r <<= 1;
        for (; r > 0; r >>= 1) {
            if (res + r <= n && dat[res + r] < x) {
                x -= dat[res + r];
                res += r;
            }
        }
        return res + 1;
    }

    void print() {
        for (int i = 0; i < n; i++) cout << sum(i, i + 1) << " ";
        cout << endl;
    }
};

signed main() {
    int h, w, m;
    cin >> h >> w >> m;
    int mnx[w], mny[h];
    fill(mnx, mnx + w, h);
    fill(mny, mny + h, w);
    vector<int> vy[h];
    int x, y;
    rep(i, m) {
        cin >> x >> y;
        x--;
        y--;
        chmin(mnx[y], x);
        chmin(mny[x], y);
        vy[x].emplace_back(y);
    }
    ll ans = 0;
    rep(y, w) {
        if (mnx[y] == 0) break;
        ans += mnx[y];
    }
    BIT<int> bit(w);
    rep(x, h) {
        if (mny[x] == 0) break;
        ans += bit.sum(0, mny[x]);
        if (x == 0) {
            for (int y = mny[x]; y < w; y++) {
                bit.add(y, 1);
            }
            continue;
        }
        for (int y : vy[x]) {
            if (bit.sum(y, y + 1) == 0) bit.add(y, 1);
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, n) for (int i = (int)(l); i < (int)(n); i++)
#define drep(i, n, l) for (int i = (int)(n); i > (int)(l); i--)
#define INF INT_MAX
#define INFF (pow(2,64))
#define def (200007)
#define MOD (1000000007)
typedef int64_t intt;
typedef vector<int> veci;
typedef vector<vector<int>> Veci;
typedef vector<int64_t> vecit;
typedef vector<vector<int64_t>> Vecit;
typedef vector<vector<double>> Vecd;
typedef vector<double> vecd;
typedef pair<intt, intt> P;
typedef unordered_set<int> uset;
typedef unordered_set<intt> usett;

vector<vector<vector<double>>>dp;
int A,B,C;

double dfs(int a,int b,int c){
  if(dp[a][b][c]!=-1)return dp[a][b][c];
  if(a==100 || b==100 || c==100)return 0;
  double sum=0;
  sum+=(dfs(a+1,b,c)+1)*a/(double)(a+b+c)+(dfs(a,b+1,c)+1)*b/(double)(a+b+c)+(dfs(a,b,c+1)+1)*c/(double)(a+b+c);
  dp[a][b][c]=sum;
  return sum;
}

int main(){
  cin>>A>>B>>C;
  dp.resize(101);
  rep(i,0,101){
    dp[i].resize(101);
  }
  rep(i,0,101){
    rep(j,0,101){
      dp[i][j].assign(101,-1);
    }
  }
  dfs(A,B,C);
  cout<<fixed<<setprecision(10);
  cout<<dp[A][B][C]<<endl;

}

#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using ll = int64_t;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>
#define vv(T) vector<vector<T>>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T> ostream& operator<<(ostream& o, const set<T>& v) {
  for (auto e : v) {
    o << e << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  vi cs(3);
  cin >> cs;

  vector<vector<vector<ld>>> ca(100, vv(ld)(100, v(ld)(100,-1)));
  auto dfs = [&](auto dfs, vi& cs, int sum)->ld {
    if (cs[0] >= 100||cs[1]>=100||cs[2]>=100) {
      return 0;
    }
    if (ca[cs[0]][cs[1]][cs[2]] >= 0) {
      return ca[cs[0]][cs[1]][cs[2]];
    }
    ld re = 0;
    F0R(i, 3) {
      if (cs[i]) {
        cs[i]++;
        re += (dfs(dfs, cs, sum + 1) + 1) * (cs[i]-1) / sum;
        cs[i]--;
      }
    }

    return ca[cs[0]][cs[1]][cs[2]] = re;
  };
  cout << std::fixed << std::setprecision(15);
  cout << dfs(dfs, cs, cs[0]+cs[1]+cs[2]);
}
#endif


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CFairElevator {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> a(n), b(n);

      rep(i, n) {
        cin >> a[i] >> b[i];
      }

      vector<bool> ok(n+1);
      ok[0] = true;

      for(int k=0; k<n; k++) {
        if (!ok[k]) continue;

        for(int j=k+1; j<=n; j++) {
          int left = k*2;
          int right = j*2;
          int diff = j-k;
          // (left , right]
          vector<int> us(2*n+1);
          bool flag = true;
          rep(i, n) {
            if (a[i] != -1) {
              if (us[a[i]]) {
                flag = false;
                break;
              } else {
                us[a[i]] = true;
              }
            }
            if (b[i] != -1) {
              if (us[b[i]]) {
                flag = false;
                break;
              } else {
                us[b[i]] = true;
              }
            }
            if (a[i] == -1 && b[i] == -1) continue;

            if (a[i] == -1 && b[i] > left && b[i] <= right) {
              int pos = b[i] - diff;
              if (pos <= left || us[pos]) {
                flag = false;
                break;
              } else {
                us[pos] = true;
              }
            }
            if (b[i] == -1 && a[i] > left && a[i] <= right) {
              int pos = a[i] + diff;
              if (pos > right || us[pos]) {
                flag = false;
                break;
              } else {
                us[pos] = true;
              }
            }
            if (a[i] == -1 || b[i] == -1) continue;
            if (b[i] <= left) continue;
            if (a[i] > right) continue;

            if (a[i] > left && b[i] <= right) {
              if (b[i] - a[i] != diff) {
                flag = false;
                break;
              }
            } else {
              flag = false;
              break;
            }
          }

          if (flag) {
            ok[j] = true;
            if (j==n) {
              cout << "Yes" << endl;
              return;
            }
          }
        }
      }

      cout << "No" << endl;

    }
};

signed main() {
  CFairElevator solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}
int n;
vector<int> A,B,in,out;
map<int,int> mp;

bool Recc(int p,int l){
  static bool mm[201][101];
  static bool vs[201][101];
  if(vs[p][l])return mm[p][l];
  vs[p][l] = 1;
  bool f = true;
  for(int i = 0; i < l && f; ++i){
    if(p+i+l >= 2*n){f = false;break;}
    f &= (in[p+i]<0 || out[p+i+l]<0) || in[p+i] == out[p+i+l];
    f &= out[p+i]<0 && in[p+i+l]<0;
    if((mp.count(in[p+i])&&mp[in[p+i]] != l) || (mp.count(out[p+i+l])&&mp[out[p+i+l]] != l))f = false;
  }
  return mm[p][l] = f;
}

bool Rec(int p){
  if(p >= 2*n)return true;
  static bool rmm[201];
  static bool rvs[201];
  if(rvs[p])return rmm[p];
  rvs[p] = 1;
  bool f = false;
  for(int i = 1; i < 101; ++i){
    bool g = Recc(p,i);
    if(!g)continue;
    f = Rec(p+i*2);
    if(f)break;
  }
  return rmm[p] = f;
}

int main(){
  cin >> n;
  B = A = vector<int>(n);
  in = out = vector<int>(n+n,-1);
  bool fff = true;
  bitset<1000> cnt;
  for(int i = 0; i < n; ++i){
    cin >> A[i] >> B[i];A[i]--;B[i]--;
    if(A[i]>=0){
      if(cnt[A[i]])fff = false;
      cnt[A[i]] = 1;
    }
    if(B[i]>=0){
      if(cnt[B[i]])fff = false;
      cnt[B[i]] = 1;
    }
    if(B[i]>=0&&A[i]>=0&&A[i] >= B[i])fff = false;
    if(A[i] >= 0)in[A[i]] = i;
    if(B[i] >= 0)out[B[i]] = i;
    if(A[i] >= 0 && B[i] >= 0)mp[i] = B[i] - A[i];
  }
  // for(int i = 0; i < n+n; ++i){
  //   debug(in[i]);
  //   debug(out[i]);
  // }
  cout << (fff&&Rec(0) ? "Yes" : "No") << endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pl = pair<ll, ll>;
using Vs = vector<string>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
    ll h,w,n,m;
    cin >> h >> w >> n >> m;
    VVl aka(h,Vl(w)),lit(h,Vl(w));
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        x--;y--;
        aka[x][y]+=2;
    }
    rep(i,m){
        ll x,y;
        cin >> x >> y;
        x--;y--;
        aka[x][y]--;
    }
    rep(i,h)rep(j,w){

        if(aka[i][j]>0){
            while(j>0){
                if(aka[i][j-1]==-1)break;
                j--;

            }
            while(j<w){
            if(aka[i][j]==-1){
                //j++;
                break;
            }
            lit[i][j]++;
            j++;
            }

        }
        //cout << j << endl;
    }
    rep(j,w)rep(i,h){
        if(aka[i][j]>0){
            while(i>0){
                if(aka[i-1][j]==-1)break;
                i--;

            }
            while(i<h){
                if(aka[i][j]==-1){
                    //i++;
                    break;
                }
                lit[i][j]++;
                i++;

            }
            //cout << i << endl;
        }
    }
    ll ans=0;
    rep(i,h)rep(j,w){
        if(lit[i][j]>=1&&aka[i][j]>=0) ans++;
        //cout << lit[i][j] << endl;
    }
    cout << ans << endl;
}

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

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<long long>      vll;
typedef vector<pair<int, int>> vpi;

#define pb            push_back
#define pf            push_front
#define all(x)        begin(x), end(x)
#define sz(x)         (int)(x).size()
#define ff            first
#define ss            second
#define mp            make_pair
#define lb            lower_bound
#define ub            upper_bound
#define Tcase()       int tcc; cin >> tcc; while(tcc--)
#define FOR(i, a, b)  for(int i = (a); i < (b); i++)
#define F0R(i, a)     FOR(i, 0, a)

const ll  MOD   = 998244353;
const ll  INF   = 9e18;
const int MX    = 2e5 + 5;
const ld  PI    = acos((ld) -1);
const int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int getXOR(int BITree[], int index){
	int ans = 0;
	index += 1;
	while(index > 0){
		ans ^= BITree[index];
		index -= index & (-index);
	}
	return ans;
}

void updateBIT(int BITree[], int n, int index, int val){
	index = index + 1;
	while (index <= n){
		BITree[index] ^= val;
		index += index & (-index);
	}
}

int* constructBITree(int arr[], int n){
	int* BITree = new int[n + 1];
	for (int i = 1; i <= n; i++)
		BITree[i] = 0;
	for (int i = 0; i < n; i++)
		updateBIT(BITree, n, i, arr[i]);

	return BITree;
}

int rangeXor(int BITree[], int l, int r){
	return getXOR(BITree, r) ^ getXOR(BITree, l - 1);
}

int main(){

	int n, Q;
	cin >> n >> Q;
	int A[n + 1];
	FOR(i, 0, n) cin >> A[i];

	int q[Q][3];
	F0R(i, Q) cin >> q[i][0] >> q[i][1] >> q[i][2];

	int* BITree = constructBITree(A, n);

	for(int i = 0; i < Q; i++){
		int id = q[i][0];

		if(id == 2){
			int L = q[i][1];
			int R = q[i][2];
			cout << rangeXor(BITree, L - 1, R - 1) << "\n";
		}
		else{
			int idx = q[i][1];
			int val = q[i][2];
			A[idx - 1] ^= val;
			updateBIT(BITree, n, idx - 1, val);
		}
	}
}