#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i=a; i<=b; i++)
#define repd(i, a, b) for(int i=a; i>=b; i--)
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define fr first
#define sc second
#define vb vector<bool>

typedef long long ll;
typedef unsigned long long ull;

/*struct cmp {
    bool operator()(const pair<int, pii> &p1, const pair<int, pii> &p2) {
        return p1.fr > p2.fr;
    }
};*/

void google(){
	static int tc=1;
	cout<<"Case #"<<tc<<": ";
	tc++;
}

ll n,q;

void solve(int tc = 1) {
	vll v(n);
	for(int i=0;i<n;i++) cin>>v[i];

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

	for(int i=0;i<q;i++){
		ll k;
		cin>>k;

		ll l=1,r=2e18;
		ll ans=2e18;
		while(l<=r){
			ll mid=(l+r)/2;

			ll id=lower_bound(v.begin(),v.end(),mid+1)-v.begin();

			ll val=mid-id;

			// cout<<mid<<" "<<val<<endl;

			if(val==k){
				ans=min(ans,mid);
				r=mid-1;
			}
			else if(val>k){
				r=mid-1;
			}
			else{
				l=mid+1;
			}
		}

		cout<<ans<<endl;
	}
}

int main() {
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << setprecision(16) << fixed;
    int t = 1;
    // cin >> t;
    int tc=0;

    while (t--) {
    	cin>>n>>q;
        tc++;
        solve(tc);
    }
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const ll MAX = 1e18 + 1;

int main() {
    int n, q; cin >> n >> q;
    vll a(n + 2);
    for (int i = 1; i <= n; i++) cin >> a[i];
    a[0] = 0;
    a[n + 1] = inf_l;
    vll cnt(n + 1, 0);
    rep(i,n+1) {
        cnt[i] = a[i + 1] - a[i] - 1;
    }
    rep(i,n) cnt[i + 1] += cnt[i];
    // debug(cnt);
    rep(i,q) {
        ll k; cin >> k;
        int id = lower_bound(all(cnt), k) - cnt.begin();
        cout << a[id + 1] + (k - cnt[id]) - 1 << endl;
        // debug(id);
    }
}


#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
using namespace std;

int main(){
  int a,b;
  cin >> a;
  if(a%100 == 0) b = a/100;
  else b = (a+100)/100;

  cout << b << endl;
}

#include<cstdio>
#include<iostream>

using namespace std;

int main(){

    int x;
    scanf("%d", &x);
    printf("%d", (x+99)/100);
    return 0;
}


/*Look at Abhinav man, so inspirational*/
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define forn(i,x,n) for(ll i=x;i<n;i++)
#define pb push_back
#define int             long long
#define mp make_pair
#define debug(x) cout<<x<<"\n";
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mod 1000000007
#define endl '\n'

int n,m,k,a,b,c,d,x,y,z,q,e,v;
string s;
int ans;
int arr[1000000];
int brr[1000000];
int crr[1000000];
char vec[100000];
int nCr(int n, int r)
{

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

	// if our approach is correct p = ans and k =1
	return p;
}

int32_t main()
{
     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   //std::cout << fixed<< std::setprecision(9) << '\n';

   int  t;
    t=1;
    //cin>>t;
    while(t--)
    {
	cin >> a >> b >> k;
	int n=a+b;
	for(int i=0;i<n;i++)
	{
		 if(a==0)
		 {
		 	 cout<<'b';
		 	 b--;
		 	 continue;
		 }
		else if(b==0)
		 {
		 	 cout<<'a';
		 	 a--;
		 	 continue;
		 }
		   d=nCr(a+b-1,a-1);
		   if(d<k)
		   {
		   	k-=d;
		   	cout<<'b';
		   	b--;

		   }
		   else
		   {
		   	cout<<'a';
		   	a--;
		   }

	}

}
}

#include<bits/stdc++.h>
using namespace std;
const int toSreachDirX[4]={-1,0,1,0};
const int toSreachDirY[4]={0,1,0,-1};
const string toSreachDir="URDL";
int Term=0;
const int Height=30;
const int Width=30;
unordered_map<char,int>Direction2Index={{'U',0},{'R',1},{'D',2},{'L',3}};
struct road{
  array<pair<int,int>,4>dist;
  road(){
    dist[0]={5000,0};
    dist[1]={5000,0};
    dist[2]={5000,0};
    dist[3]={5000,0};
  }
  pair<int,int>get(char s){
    switch (s){
      case 'U':
      return dist[0];
      case 'R':
      return dist[1];
      case 'D':
      return dist[2];
      case 'L':
      return dist[3];
      default:
      return pair<int,int>({1e8,0});
    }
  }
};
string solve(vector<vector<road>> &mati,int sx,int sy,int gx,int gy){
  string operate="";
  vector<vector<int>>dist(30,vector<int>(30,1e9));
  vector<vector<char>>op(30,vector<char>(30,'/'));
  dist[sx][sy]=0;
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>dijk;
  dijk.push({0,sx*30+sy});
  while(dijk.size()){
    auto [d,vn]=dijk.top();
    dijk.pop();
    int vx=vn/30,vy=vn%30;
    if(d>dist[vx][vy])continue;
    for(int i=0;i<4;i++){
      if(vx+toSreachDirX[i]>=0 && vx+toSreachDirX[i]<30 && vy+toSreachDirY[i]>=0 && vy+toSreachDirY[i]<30){
        if(dist[vx+toSreachDirX[i]][vy+toSreachDirY[i]]>d+mati[vx][vy].get(toSreachDir[i]).first){
          dist[vx+toSreachDirX[i]][vy+toSreachDirY[i]]=d+mati[vx][vy].get(toSreachDir[i]).first;
          dijk.push({dist[vx+toSreachDirX[i]][vy+toSreachDirY[i]],(vx+toSreachDirX[i])*30+vy+toSreachDirY[i]});
          op[vx+toSreachDirX[i]][vy+toSreachDirY[i]]=toSreachDir[i];
        }
      }
    }
  }
  while(gx!=sx||gy!=sy){
    operate+=op[gx][gy];
    switch(op[gx][gy]){
      case 'U':
      gx++;break;
      case 'D':
      gx--;break;
      case 'R':
      gy--;break;
      case 'L':
      gy++;break;
    }
  }
  reverse(operate.begin(),operate.end());
  return operate;
}
string solve2(vector<vector<road>> &mati,int sx,int sy,int gx,int gy){
  string ret="";
  for(int i=0;i<sx-gx;i++){
    ret+='U';
  }
  for(int i=0;i<gx-sx;i++){
    ret+='D';
  }
  for(int i=0;i<sy-gy;i++){
    ret+='L';
  }
  for(int i=0;i<gy-sy;i++){
    ret+='R';
  }
  return ret;
}
void evoluate(vector<vector<road>> &mati,double dist,string &op,int sx,int sy){
  int len=op.size();
  for(int i=0;i<len;i++){
    auto t=mati[sx][sy].dist[Direction2Index[op[i]]];
    mati[sx][sy].dist[Direction2Index[op[i]]].first=(t.first*t.second+dist/len*2)/(t.second+2);
    mati[sx][sy].dist[Direction2Index[op[i]]].second++;
    sx+=toSreachDirX[Direction2Index[op[i]]];
    sy+=toSreachDirY[Direction2Index[op[i]]];
  }
}
int main(){
  vector<vector<road>> mati(30,vector<road>(30));
  double dist=0;
  int sx,sy,gx,gy;
  for(int i=0;i<1000;i++){
    Term++;
    cin>>sx>>sy>>gx>>gy;
    string t="";
    if(Term<250)t=solve2(mati,sx,sy,gx,gy);
    else t=solve(mati,sx,sy,gx,gy);
    cout<<t<<endl;
    cin>>dist;
    evoluate(mati,dist,t,sx,sy);
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll Gcd(ll a, ll b) { return b ? Gcd(b, a % b) : a; }
ll Lcm(ll a, ll b) { return a / Gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main(){
	int n;
	cin >> n;
	double x0, y0, xh, yh;
	cin >> x0 >> y0 >> xh >> yh;
	double xmid = (x0 + xh) / 2;
	double ymid = (y0 + yh) / 2;
	double degtmp = 2 * pi / (double)n;
	double r = sqrt(pow(xh - x0, 2) + pow(yh - y0, 2)) / 2;
	double deg0 = atan2(y0 - ymid, x0 - xmid);
	double deg = deg0 + degtmp;
	cout << fixed << setprecision(8) << xmid + r * cos(deg) << " " << ymid + r * sin(deg) << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define Db double
#define For(i,x,y)for(i=x;i<=(y);i++)
struct dls
{
	int val,id;
}b[N];
int a[N],h[N],n,m;
bool cmp(dls _,dls __)
{
	return 1LL*_.val*n-1LL*a[_.id]*m>1LL*__.val*n-1LL*a[__.id]*m;
}
int main()
{
	int k,i,tot=0;
	scanf("%d%d%d",&k,&n,&m);
	For(i,1,k)
	{
		scanf("%d",&a[i]);
		b[i].val=ceil(Db(a[i])/Db(n)*Db(m));
		tot+=b[i].val;
		b[i].id=i;
	}
	sort(b+1,b+k+1,cmp);
	For(i,1,tot-m)b[i].val--;
	For(i,1,k)h[b[i].id]=b[i].val;
	For(i,1,k)printf("%d ",h[i]);
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()

#define int long long
const int MOD=998244353;

int dp[15][1000001];
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}
int Factorial[5000000],Finverse[5000000];
inline void Cinit(){
  Factorial[0]=1;
  for(int i=1;i<5e6;i++)Factorial[i]=(Factorial[i-1]*i)%MOD;
  Finverse[4999999]=pw(Factorial[4999999],MOD-2);
  for(int i=4999998;i>=0;i--)Finverse[i]=(i+1)*Finverse[i+1]%MOD;
}

int memo[5001][5001];
int nCk(int n,int k){
  if(n<k)return 0;if(k<0)return 0;
  if(!Factorial[0])Cinit();
  if(~memo[n][k])return memo[n][k];
  int res=Factorial[n];
  (res*=Finverse[k])%=MOD;
  (res*=Finverse[n-k])%=MOD;
  return memo[n][k]=res;
}

signed main(){
  memset(memo,-1,sizeof(memo));
  int n,m;cin>>n>>m;
  dp[0][0]=1;
  for(int i=0;i<14;i++){
    for(int j=0;j<1000000;j++){
      if(((m>>i)&1)^(j&1))continue;
      if(dp[i][j]==0)continue;
      int s=j/2;//上に繰り上がる予約
      for(int k=0;2*k<=n;k++){//k新たに繰り上げる
        //n個のうち2k個が1
        (dp[i+1][s+k]+=dp[i][j]*nCk(n,2*k)%MOD)%=MOD;
      }
    }
  }
  cout<<dp[14][0]<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define M 5005
#define K 13
#define MOD 998244353

int comb[M][M];
int dp[K][M];

int main()
{
    for(int i = 0; i < M; i++) comb[i][0] = 1;
    for(int i = 1; i < M; i++)
    {
        for(int j = 1; j <= i; j++) comb[i][j] = (comb[i-1][j]+comb[i-1][j-1])%MOD;
    }

    int n, m;
    scanf("%d %d", &n, &m);

    for(int j = 0; j <= min(n, m); j += 2) dp[0][j] = comb[n][j];
    for(int i = 1; i < K; i++)
    {
        for(int j = 0; j <= m; j++)
        {
            for(int k = 0; k <= n && (1<<i)*k <= j; k += 2)
            {
                dp[i][j] += 1LL*comb[n][k]*dp[i-1][j-(1<<i)*k]%MOD;
                if(dp[i][j] >= MOD) dp[i][j] -= MOD;
            }
        }
    }

    int ans = dp[K-1][m];
    printf("%d\n", ans);

    return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int a,b;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b;
	if(a==b)cout<<a;
	else cout<<3-a-b;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long;    //个人习惯
int main()
{
	stack <char> fox;    //定义
    int n;               //定义
    string s;            //定义
	cin >> n;            //输入
	cin >> s;            //输入
	for(int i = 0; i < s.length(); i++)
	{
		if(fox.size() < 2)
		{
			fox.push(s[i]);
			continue;
		}
		char foox = fox.top();
	    fox.pop();
	    if(fox.top() == 'f' && foox == 'o' && s[i] == 'x')
	    {
		    fox.pop();     //弹出
		    continue;
	    }
	    fox.push(foox);
	    fox.push(s[i]);
	}

	cout << fox.size();    //输出
	return 0;
}


#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

std::vector<std::vector<int>> nx_init(const std::string &s, const char basis = 'a', const int sigma = 26) {
  int n = s.size();
  std::vector<std::vector<int>> nx(n, std::vector<int>(sigma, n));
  nx[n - 1][s[n - 1] - basis] = n - 1;
  for (int i = n - 2; i >= 0; --i) {
    for (int j = 0; j < sigma; ++j) nx[i][j] = nx[i + 1][j];
    nx[i][s[i] - basis] = i;
  }
  return nx;
}

void solve() {
  int n; cin >> n;
  string s[3]; REP(i, 3) cin >> s[i];
  vector<vector<int>> nx[3];
  REP(i, 3) nx[i] = nx_init(s[i] + s[i], '0', 2);
  REP(i, 2) REP(j, 2) REP(l, 2) {
    string ans = string(n, '0' + i) + to_string(j) + string(n, '0' + l);
    bool valid = true;
    REP(x, 3) {
      bool ok = true;
      int pos = 0;
      for (char c : ans) {
        if (pos >= n * 4) {
          ok = false;
          break;
        }
        pos = nx[x][pos][c - '0'];
        if (pos >= n * 4) {
          ok = false;
          break;
        }
        ++pos;
      }
      valid &= ok;
    }
    if (valid) {
      cout << ans << '\n';
      return;
    }
  }
  REP(i, 2) REP(j, 2) REP(l, 2) {
    string ans = to_string(j) + string(n, '0' + i) + string(n, '0' + l);
    swap(ans[n - 1], ans[n]);
    bool valid = true;
    REP(x, 3) {
      bool ok = true;
      int pos = 0;
      for (char c : ans) {
        if (pos >= n * 4) {
          ok = false;
          break;
        }
        pos = nx[x][pos][c - '0'];
        if (pos >= n * 4) {
          ok = false;
          break;
        }
        ++pos;
      }
      valid &= ok;
    }
    if (valid) {
      cout << ans << '\n';
      return;
    }
  }
  REP(i, 2) REP(j, 2) REP(l, 2) {
    string ans = string(n, '0' + i) + string(n, '0' + l) + to_string(j);
    swap(ans[n - 1], ans[n]);
    bool valid = true;
    REP(x, 3) {
      bool ok = true;
      int pos = 0;
      for (char c : ans) {
        if (pos >= n * 4) {
          ok = false;
          break;
        }
        pos = nx[x][pos][c - '0'];
        if (pos >= n * 4) {
          ok = false;
          break;
        }
        ++pos;
      }
      valid &= ok;
    }
    if (valid) {
      cout << ans << '\n';
      return;
    }
  }
  // cout << n << endl;
  // REP(i, 3) cout << s[i] << endl;
  assert(false);
}

int main() {
  int t; cin >> t;
  while (t--) solve();
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int,int> > x,y;
vector<int> ans;
map<pair<int,int>,int > ma;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int u,v;
        cin>>u>>v;
        x.push_back({u,i});
        y.push_back({v,i});
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    int a=x.size();
    int b=y.size();
    for(int i=a-1;i>=a-3;i--)
    {
        ans.push_back(abs(x[0].first-x[i].first));
        ma[{x[0].second,x[i].second}]=1;
    }
    for(int i=0;i<3;i++)
    {
        if(ma[{x[i].second,x[x.size()-1].second}]==0)
            {
                ans.push_back(abs(x[i].first-x[x.size()-1].first));
                ma[{x[i].second,x[x.size()-1].second}]=1;
            }
    }
    for(int i=b-1;i>=b-3;i--)
    {
        if(ma[{y[0].second,y[i].second}]==0)
            {
                ans.push_back(abs(y[0].first-y[i].first));
                ma[{y[0].second,y[i].second}]=1;
            }
    }
    for(int i=0;i<3;i++)
    {
        if(ma[{y[i].second,y[x.size()-1].second}]==0)
            {
                ans.push_back(abs(y[i].first-y[x.size()-1].first));
                ma[{x[i].second,x[x.size()-1].second}]=1;
            }
    }
    sort(ans.begin(),ans.end());
    cout<<ans[ans.size()-2];
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    stack<char> s;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == 'f') s.push('f');
        else if(S[i] == 'o'){
            if(s.empty() || s.top() != 'f'){
                while(!s.empty()) s.pop();
            }
            else if(s.top() == 'f') s.push('o');
        }
        else if(S[i] == 'x'){
            if(s.empty() || s.top() != 'o'){
                while(!s.empty()) s.pop();
            }
            else if(s.top() == 'o'){
                s.pop();
                s.pop();
                cnt += 3;
            }
        }
        else{
            while(!s.empty()) s.pop();
        }
    }
    cout << N - cnt << endl;
}

#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
typedef pair<int,int> pii;
#define fast   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;
//priority_queue<pii, vector<pii>, greater<pii> > pq;

inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){
    return pwr(n, mod - 2);
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
int toDigit(char ch)
{
    return (ch - '0');
}

long modPow(long a, long x, long p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

long modInverse(long a, long p) {

    return modPow(a, p-2, p);
}

int nCrModpDP(int n, int r, int p)
{
    int C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;
    for (int i = 1; i <= n; i++)
    {

        for (int j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}
int nCrModpLucas(int n, int r, int p)
{
  if (r==0)
      return 1;
   int ni = n%p, ri = r%p;

   return (nCrModpLucas(n/p, r/p, p) *
           nCrModpDP(ni, ri, p)) % p;
}

ll fact(int f){
    ll ans=1;
    for(int i=1;i<=f;++i){
        ans=mul(i,ans);
    }
    return ans;
}
void solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    stack<int> f;
    stack<int> o;
    stack<int> x;
    int a=0;
    int fi,oi,xi;
     fi=oi=xi=0;
    rep(i,n){
        if(s[i]=='f') f.push(i-oi);
        else if(s[i]=='o') o.push(i-oi);
        else if(s[i]=='x'){
            x.push(i-oi);
            if(!f.empty()&&!o.empty()){
                if(f.top()+1==o.top()&&o.top()+1==x.top()){
                a++;
                f.pop();o.pop();x.pop();
                oi+=3;
                }
            }
        }
    }
    cout<<n-a*3<<'\n';
}
int main(){
    int t=1;

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


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

int main()
{
    long long N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> sumVec(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> A.at(i);
        if (i == 0)
        {
            sumVec.at(i) = A.at(i);
        }
        else
        {
            sumVec.at(i) = sumVec.at(i - 1) + A.at(i);
        }
    }
    // 1+2 + 2+1+2
    // 1+max, 2+1+max,3+2+1+max

    // 2 1 1 3
    // 1 + 4 + 4
    long long maxValue = 0;
    long long addedMaxValue = 0;
    long long sum = 0;
    long long sumsums = 0;
    for (long long i = 0; i < A.size(); i++)
    {
        sumsums += sumVec.at(i);
        if (maxValue < A.at(i))
        {
            maxValue = A.at(i);
        }
        auto sum = sumsums + maxValue * (i + 1);
        cout << sum << endl;
    }
}


//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int n, a[105], b[105], cnt[205];
bool dp[105];

int main(){
	cin >> n;
	repn(i, n){
		cin >> a[i] >> b[i];
		if(a[i] >= 1) cnt[a[i]]++;
		if(b[i] >= 1) cnt[b[i]]++;
	}
	rep(i, 205){
		if(cnt[i] > 1){
			cout << "No" << '\n';
			return 0;
		}
	}
	dp[0] = 1;
	for(int i=0;i<n;i++){
		if(dp[i] == 0) continue;
		for(int j=i+1;j<=n;j++){
			//[i+1, j]
			int use = 0, blank = 0;
			bool fail = 0;
			repn(k, n){
				if(a[k] == -1 && b[k] == -1){
					blank ++;
				}
				else if(a[k] != -1 && b[k] != -1){
					if(i*2+1 <= a[k] && a[k] <= j*2){
						use++;
						if(a[k]+j-i != b[k]) fail = 1;
					}
					else if(b[k] <= i*2) use++;
				}
				else if(a[k] == -1){
					if(i*2+1 <= b[k] && b[k] <= j*2){
						use++;
						if(i+j+1 <= b[k] && b[k] <= j*2 && cnt[b[k]-(j-i)] == 0);
						else fail = 1;
					}
					else if(b[k] <= i*2) use++;
				}
				else{
					if(i*2+1 <= a[k] && a[k] <= j*2){
						use++;
						if(i*2+1 <= a[k] && a[k] <= i+j && cnt[a[k]+(j-i)] == 0);
						else fail = 1;
					}
					else if(a[k] <= i*2) use++;
				}
			}
			//cout << i << " " << j << " " << use << " " << blank << endl;
			if(use > j) fail = 1;
			if(j-use > blank) fail = 1;
			if(!fail){
				dp[j] = 1;
			}
		}
	}
	cout << (dp[n]?"Yes":"No") << '\n';
}

#include <iostream>
#include <cstdio>
#define N 202
#define int long long
using namespace std;
const int mod=998244353;
const int G=3;
int read()
{
	char c=getchar();
	int w=0,f=1;
	while(c<'0'||c>'9'){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w*f;
}
int n,i,j,a[N],b[N],cnta[N],cntb[N],f[N][N],g[N],r[N],f1[N],g1[N];
bool judge(int l,int r)
{
	int len=(r-l+1)/2+1;
	for(int i=1;i<=n;i++){
		if(a[i]!=-1&&b[i]!=-1){
			if(l<=a[i]&&b[i]<=r&&b[i]-a[i]+1!=len) return 0;
			if(a[i]<l&&b[i]>=l) return 0;
			if(a[i]<=r&&b[i]>r) return 0;
		}
		else{
			if(a[i]!=-1&&l<=a[i]&&a[i]<=r&&cntb[a[i]+len-1]) return 0;
			if(b[i]!=-1&&l<=b[i]&&b[i]<=r&&cnta[b[i]-len+1]) return 0;
			if(a[i]!=-1&&b[i]!=-1) continue;
		}
	}
	for(int i=l;i+len-1<=r;++i){
		if(cntb[i]||cnta[i+len-1]) return 0;
	}
	return 1;
}
int poww(int a,int b)
{
	int ans=1,base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod;
		b>>=1;
	}
	return ans;
}
void NTT(int *a,int n,int inv)
{
	for(int i=0;i<n;i++){
		if(i<r[i]) swap(a[i],a[r[i]]);
	}
	for(int l=2;l<=n;l<<=1){
		int mid=l/2;
		int cur=poww(G,(mod-1)/l);
		if(inv==-1) cur=poww(cur,mod-2);
		for(int i=0;i<n;i+=l){
			int omg=1;
			for(int j=0;j<mid;j++,omg=omg*cur%mod){
				int tmp=omg*a[i+j+mid]%mod;
				a[i+j+mid]=(a[i+j]-tmp+mod)%mod;
				a[i+j]=(a[i+j]+tmp)%mod;
			}
		}
	}
	if(inv==-1){
		for(int i=0;i<n;i++) a[i]=a[i]*poww(n,mod-2)%mod;
	}
}
void getinv(int *f,int *g,int n)
{
	if(n==1){
		g[0]=poww(f[0],mod-2);
		return;
	}
	getinv(f,g,n/2);
	for(int i=0;i<n;i++) f1[i]=f[i];
	for(int i=0;i<n;i++) g1[i]=g[i];
	int m=2*n,lim=0;
	while((1<<lim)<m) lim++;
	for(int i=0;i<m;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(lim-1));
	NTT(f1,m,1);NTT(g1,m,1);
	for(int i=0;i<m;i++) g1[i]=f1[i]*g1[i]%mod*g1[i]%mod;
	NTT(g1,m,-1);
	for(int i=0;i<n;i++) g[i]=(2*g[i]%mod-g1[i]+mod)%mod;
}
signed main()
{
	n=read();
	for(i=1;i<=n;++i){
		a[i]=read(),b[i]=read();
		if(a[i]!=-1) cnta[a[i]]++;
		if(b[i]!=-1) cntb[b[i]]++;
	}
	for(i=1;i<=2*n;++i){
		if(cnta[i]+cntb[i]>1){
			puts("No");
			return 0;
		}
	}
	for(i=1;i<=n;++i){
		if(a[i]!=-1&&b[i]!=-1&&a[i]>b[i]){
			puts("No");
			return 0;
		}
	}
	for(i=1;i<=n*2;i+=2){
		for(j=i+1;j<=n<<1;j+=2) f[i][j]=judge(i,j);
	}
	for(i=1;i<=100;i++)
	g[0]=1;
	for(i=2;i<=2*n;i+=2){
		for(j=0;j<i;j+=2){
			if(f[j+1][i]) g[i]|=g[j];
		}
	}
	if(g[n*2]!=0) puts("Yes");
	else puts("No");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> V;
#define F(N,S,E) for(int N=(int)(S);N<=(int)(E);N++)
#define R(N,S,E) for(int N=(int)(S);N>=(int)(E);N--)
#define D(N,E) for(int N=0;N<(int)(E);N++)
LL read(){LL x;scanf("%lld",&x);return x;}

int main(){
	int n=read();
	int mx=-1;
	LL sum=0;
	LL sum2=0;
	F(i,1,n){
		int a=read();
		mx=max(mx,a);
		sum+=a;
		sum2+=sum;
		printf("%lld\n",(LL)mx*i+sum2);
	}
	return 0;
}

#include <iostream>
using namespace std;
typedef long long ll;

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

    int res = 0;
    int res_index = 2;
    for(int i = 2; i <= 1000; ++i){

        int score = 0;
        for (int j = 0; j < N; ++j){
            if (A[j] % i == 0) score++;
        }

        if (score >= res){
            res = score;
            res_index = i;
        }
    }

    cout << res_index << endl;
    return 0;
}


//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,avx512f")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#include <memory>
#include <random>
#include <functional>
#include <complex>
#include <immintrin.h>
#ifdef DEBUG
#include "./CompetitiveProgrammingCpp/debug_VC.hpp"
#include "./CompetitiveProgrammingCpp/Timer.hpp"
#include "./CompetitiveProgrammingCpp/sample.hpp"
#else
#define dump(...)
#endif

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
template<class T>
inline auto sort(T& t) { std::sort(ALL(t)); }
template<class T>
inline auto rsort(T& t) { std::sort((t).rbegin(), (t).rend()); }
template<class T>
inline auto unique(T& t) { (t).erase(unique((t).begin(), (t).end()), (t).end()); }
template<class T, class S>
inline auto chmax(T& t, const S& s) { if (s > t) { t = s; return true; } return false; }
template<class T, class S>
inline auto chmin(T& t, const S& s) { if (s < t) { t = s; return true; } return false; }
inline auto BR() { std::cout << "\n"; }

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std {
template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } };
}

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

//=============================================================================================

signed main() {
	ll n, q;
	cin >> n >> q;
	VL a(n);
	cin >> a;

	VL v(n);
	RREP(i, n) {
		v[i] = a[i] - i;
	}
	dump(v);

	REP(_, q) {
		ll k;
		cin >> k;
		auto it = std::upper_bound(ALL(v), k) - v.begin();
		--it;
		if (it == -1) {
			cout << k << endl;
		} else {
			cout << a[it] + k - v[it] + 1 << endl;
		}
	}
}

/**
 * File              : B.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 12.01.2020
 * Last Modified Date: 12.01.2020
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */

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

int main() {
    int n, k, m;
    cin >> n >> k >> m;
    int total = 0;
    for (int i = 0; i < n - 1; i++) {
        int tmp;
        cin >> tmp;
        total += tmp;
    }
    int need = m*(n) - total;
    if (need > k) {
        cout << -1;
    } else {
        cout << max(0, need);
    }

    return 0;
}


//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const unsigned int mod = 1000000007;
//const unsigned int mod = 998244353;

struct mint {
  unsigned int x;
  mint():x(0) {}
  mint(int64_t x_) {
    int64_t v = int64_t(x_ % mod);
    if(v < 0) v += mod;
    x = (unsigned int)v;
  }
  static mint row(int v) {
    mint v_;
    v_.x = v;
    return v_;
  }
  mint operator-() const { return mint(-int64_t(x));}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    uint64_t z = x;
    z *= a.x;
    x = (unsigned int)(z % mod);
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  friend bool operator==(const mint &a, const mint &b) {return a.x == b.x;}
  friend bool operator!=(const mint &a, const mint &b) {return a.x != b.x;}
  mint &operator++() {
    x++;
    if(x == mod) x = 0;
    return *this;
  }
  mint &operator--() {
    if(x == 0) x = mod;
    x--;
    return *this;
  }
  mint operator++(int) {
    mint result = *this;
    ++*this;
    return result;
  }
  mint operator--(int) {
    mint result = *this;
    --*this;
    return result;
  }
  mint pow(int64_t t) const {
    mint x_ = *this, r = 1;
    while(t) {
      if(t&1) r *= x_;
      x_ *= x_;
      t >>= 1;
    }
    return r;
  }
  //for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

string to_string(mint a) {
  return to_string(a.x);
}

//head

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  char aa, ab, ba, bb;
  cin >> aa >> ab >> ba >> bb;
  mint ans;
  if(ab == 'A') {
    if(aa == 'A') ans = 1;
    else {
      if(ba == 'A') {
        mint a, b;
        a = 1;
        rep(i, n-1) {
          swap(a, b);
          a += b;
        }
        ans = b;
      }
      else {
        ans = mint(2).pow(max(n-3, 0));
      }
    }
  }
  else {
    if(bb == 'B') ans = 1;
    else {
      if(ba == 'B') {
        mint a, b;
        a = 1;
        rep(i, n-1) {
          swap(a, b);
          a += b;
        }
        ans = b;
      }
      else {
        ans = mint(2).pow(max(n-3, 0));
      }
    }
  }
  cout << ans << endl;
}

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(...) begin(__VA_ARGS__) , end(__VA_ARGS__)

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <int> vi;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll nax = 2e5+6969, INF = 2e9+6969, mod = 1e9+7;

ll n;
char c[4];

ll Pow(ll a, ll b)
{
	ll w = 1;
	while(b)
	{
		if(b&1) w = (w*a) % mod;
		a = (a*a) % mod;
		b >>= 1;
	}
	return w;
}
ll F(ll a)
{
	ll f[nax];
	f[0] = f[1] = 1;
	for(int i=2;i<=a;++i) f[i] = (f[i-1] + f[i-2]) % mod;
	return f[a];
}

int main()
{
	//  cout << F(577) << "\n";
	cin >> n;
	for(int i=0;i<4;++i) cin >> c[i];
	if(n <= 3) puts("1");
	else
	{
		if(c[1] == 'B')
		{
			if(c[3] == 'B') puts("1");
			else
			{
				if(c[2] == 'A') cout << Pow(2LL, n-3) << "\n";
				else cout << F(n-2) << "\n";
			}
		}
		else
		{
			if(c[0] == 'A') puts("1");
			else
			{
				if(c[2] == 'B') cout << Pow(2LL, n-3) << "\n";
				else cout << F(n-2) << "\n";
			}
		}
	}
	return 0;
}


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

int main() {
  long long N;
  cin >> N;
  vector<pair<long long, long long>> A;
  long long ans = 0;

  for (long long i=0; i<(pow(2,N)); i++) {
    long long x;
    cin >> x;
    A.push_back( make_pair(i+1, x) );
  }

  vector<pair<long long, long long>> B = A;

  while (B.size() > 2) {
    vector<pair<long long, long long>> C;

    for (long long i=0; i<B.size(); i+=2) {
      if (B.at(i).second > B.at(i+1).second)
        C.push_back(B.at(i));
      else
        C.push_back(B.at(i+1));
    }
    B = C;
    C.clear();
  }

  if (B.at(0).second > B.at(1).second)
    cout << B.at(1).first << endl;
  else
    cout << B.at(0).first << endl;

  return 0;
}

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
#define rprintf(fmt, begin, end) do { const auto end_rp = (end); auto it_rp = (begin); for (bool sp_rp=0; it_rp!=end_rp; ++it_rp) { if (sp_rp) putchar(' '); else sp_rp = true; printf(fmt, *it_rp); } putchar('\n'); } while(0)

int N;
char buf[200011];

void MAIN() {
    scanf("%d", &N);
    scanf("%s", buf);
    scanf("%s", buf);
    scanf("%s", buf);

    putchar('0');
    REP (i, N) putchar('1');
    REP (i, N) putchar('0');
    puts("");

}

int main() {
    int TC = 1;
    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <iomanip>

#include <fstream>

using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll f(char c){
    ll k=c-'0';
    if(0<=k && k<=9){
        return k;
    }
    ll l=c-'A';
    return 10+l;
}

int main(){fastio
    string N;cin>>N;
    ll K;cin>>K;
    ll n;n=(ll)N.size();
    ll dp[2][n][17];
    ll bol[n][16];rep(i,0,n-1)rep(j,0,15)bol[i][j]=0;
    rep(i,0,n-1){
        if(i>0){
            rep(j,0,15){
                bol[i][j]=bol[i-1][j];
            }
        }
        bol[i][f(N[i])]=1;
    }
    /*
    rep(i,0,15){
        rep(j,0,n-1){
            cout<<bol[j][i]<<' ';
        }
        cout<<endl;
    }
    cout<<endl;
     */

    rep(i,0,n-1){
        rep(j,1,15){
            bol[i][j] = bol[i][j-1]+bol[i][j];
        }
    }
    /*
    rep(j,0,15){
        rep(i,0,n-1){
            cout<<bol[i][j]<<' ';
        }
        cout<<endl;
    }
    cout<<endl;
    */

    //bol[i][j]=0~jのうちN[i]までで現れたものの個数
    rep(i,0,n-1){
        rep(j,0,16){
            if(j==bol[i][15]){
                dp[0][i][j]=1;
            }else{
                dp[0][i][j]=0;
            }
            if(i==0){
                if(j==0){
                    dp[1][i][j]=1;
                }else if(j==1){
                    dp[1][i][j]=f(N[i])-1;
                }else{
                    dp[1][i][j]=0;
                }
            }else{
                if(j==0){
                    dp[1][i][j]=1;
                }else{
                    if(f(N[i]) == 0){
                        if(j==1){
                            dp[1][i][j] = mod(dp[1][i-1][j-1]*(16-j)+dp[1][i-1][j]*j);
                        }else{
                            dp[1][i][j] = mod(dp[1][i-1][j-1]*(17-j)+dp[1][i-1][j]*j);
                        }

                    }else{
                        if(j==1){
                            dp[1][i][j] = mod(dp[1][i-1][j-1]*(16-j)+dp[1][i-1][j]*j);
                        }else{
                            dp[1][i][j] = mod(dp[1][i-1][j-1]*(17-j)+dp[1][i-1][j]*j);
                        }

                        dp[1][i][j] += dp[0][i-1][j]*(bol[i-1][f(N[i])-1]);
                        dp[1][i][j] = mod(dp[1][i][j]);
                        dp[1][i][j] += dp[0][i-1][j-1]*(f(N[i])-bol[i-1][f(N[i])-1]);
                        dp[1][i][j] = mod(dp[1][i][j]);
                    }
                }
            }
        }
    }
    ll ans=0;
    ans += dp[0][n-1][K];
    ans = mod(ans);
    ans += dp[1][n-1][K];
    ans = mod(ans);
    cout<<ans<<endl;

    /*
    rep(i,0,15){
        rep(j,0,n-1){
            cout<<bol[j][i]<<' ';
        }
        cout<<endl;
    }
    cout<<endl;

    rep(k,0,1){
        cout<<"k: "<<k<<endl;
        rep(j,0,15){
            rep(i,0,n-1){
                cout<<dp[k][i][j]<<' ';
            }
            cout<<endl;
        }
        cout<<endl;
    }
    */

    return 0;

}

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

#define all(x) (x).begin(), (x).end()
#define ll long long
const ll mod = 1e9 + 7;

int ri(){
	int n;
	scanf("%d", &n);
	return n;
}
void solve(){
	int n = ri();
	int a[n];
	for(auto &i : a) i = ri();

	int res = INT_MAX;
	for(int i=0; i < (1 << (n-1)); i++){
		int ored = 0, xored = 0;
		for(int j=0; j<=n; j++){
			if(j < n) ored |= a[j];
			if(j == n || (i >> j & 1)) xored ^= ored, ored = 0;
		}
		res = min(res, xored);
	}

	cout << res << "\n" ;
}

int main(){

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


#include <bits/stdc++.h>

using namespace std;

long long get(long long x) {
  string s = bitset<100>(x).to_string();
  int ans = 0;
  int cur = 0;
  for (int i = 0; i < 100; i++)
    if (s[i] == '1') cur++;
  	else {
      ans += min(cur, 2);
      cur = 0;
    }
  ans += min(cur, 2);
  return ans;
}

long long get(long long x, long long y, int jumps) {
  x <<= jumps;
  long long diff = x - y;
  if (diff < 0) diff = -diff;
  long long rem = diff >> jumps;
  return min(rem + get(diff - (rem << jumps)),
          rem + 1 + get(((rem + 1) << jumps) - diff));
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long x, y;
  cin >> x >> y;
  long long ans = max(x, y) - min(x, y);
  for (int i = 0; (x << i) <= (y << 2); i++)
    ans = min(ans, i + get(x, y, i));
  cout << ans << '\n';
  return 0;
}

#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <algorithm>
#include <iostream>
using namespace std;
#define f(x,y,z) for(int x=y;x<=z;++x)
#define d(x,y,z) for(int x=y;x>=z;--x)
typedef long long ll;
ll n, ans = 1, a[100001];
const int mod = 1e9+7;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    f(i,1,n) cin >> a[i];
    sort(a+1, a+n+1);
    d(i,n,2) a[i] -= a[i-1];
    f(i,1,n) ans = ans*(a[i]+1)%mod;
    cout << ans << '\n';
}


#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library
const int MOD = 998244353;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
    bool operator==(const mint a) const {
        return x == a.x;
    }
    bool operator!=(const mint a) const {
        return x != a.x;
    }
    friend ostream& operator<<(ostream& os, const mint& value) {
        os << value.x;
        return os;
    }
    friend istream& operator>>(istream& is, mint& value) {
        ll t;
        is >> t;
        value = mint(t);
        return is;
    }
};

#pragma endregion library

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vv<char> cs(h, vector<char>(w, '#'));
    rep(i, k) {
        int h, w;
        char c;
        cin >> h >> w >> c;
        h--;
        w--;
        cs[h][w] = c;
    }
    mint three = 3, p = three.pow(h * w - k);
    mint div3 = (mint)1 / 3;
    vv<mint> dp(h, vector<mint>(w));
    dp[0][0] = p;
    rep(i, h) rep(j, w) {
        if (cs[i][j] == '#') {
            if (i < h - 1) {
                dp[i + 1][j] += dp[i][j] * 2 * div3;
            }
            if (j < w - 1) {
                dp[i][j + 1] += dp[i][j] * 2 * div3;
            }
        }
        if (cs[i][j] == 'X') {
            if (i < h - 1) {
                dp[i + 1][j] += dp[i][j];
            }
            if (j < w - 1) {
                dp[i][j + 1] += dp[i][j];
            }
        }
        if (cs[i][j] == 'R') {
            if (j < w - 1) {
                dp[i][j + 1] += dp[i][j];
            }
        }
        if (cs[i][j] == 'D') {
            if (i < h - 1) {
                dp[i + 1][j] += dp[i][j];
            }
        }
    }
    cout << dp[h - 1][w - 1] << '\n';
}

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

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

int dp[2001];
char S[4002000], c;

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

	int H = 0, W = 0;
	while ((c = getchar()) >= '0') H = H * 10 + c - '0';
	while ((c = getchar()) >= '0') W = W * 10 + c - '0';
	fread(S, 1, H * (W + 1), stdin);

	auto s = S + (H - 1) * (W + 1);
	dp[W - 1] = 44 - s[W - 1];
	for (int j = W - 2; j >= 0; j--) {
		dp[j] = 44 - s[j] - dp[j + 1];
	}

	for (int i = H - 2; i >= 0; i--) {
		s = S + i * (W + 1);
		dp[W - 1] = 44 - s[W - 1] - dp[W - 1];

		for (int j = W - 2; j >= 0; j--) {
			dp[j] = 44 - s[j] - max(dp[j], dp[j + 1]);
		}
	}

	if (S[0] == '+') dp[0]--;
	else dp[0]++;

	if (dp[0] < 0) co("Takahashi");
	else if (dp[0] > 0) co("Aoki");
	else co("Draw");

	Would you please return 0;
}


#ifdef _DEBUG
    #define dout(x) clog << "Line " << __LINE__ << ": " << #x << "=" << (x) << el
#else
    #pragma GCC optimize("Ofast,unroll-loops")
    #pragma GCC target("avx,avx2,fma")
    #define dout(x)
#endif

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

#define MP(a, b) make_pair(a, b)
#define PB(x) push_back(x)
#define EB(args...) emplace_back(args)
#define F first
#define S second
#define die exit(0)

template<typename T>
using vc = vector<T>;
template<typename T>
using uset = unordered_set<T>;
template<typename A, typename B>
using umap = unordered_map<A, B>;
template<typename T, typename Comp = less<T>>
using pq = priority_queue<T, vc<T>, Comp>;
template<typename T>
using minpq = pq<T, greater<T>>;

using db = double;
using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using tri = tuple<int, int, int>;
using vi = vc<int>;
using vii = vc<pii>;
using str = string;

constexpr char el = '\n';
constexpr char sp = ' ';
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3fLL;
// ---------------------------------------------------------------------

int a[10];
int n, k;

int g1(int x){
    for(int& x: a)
        x = 0;

    while(x>0){
        ++a[x%10];
        x/=10;
    }
    int ans = 0;
    for(int i = 9; i >= 0; --i)
        while(a[i]--){
            ans *= 10;
            ans += i;
        }

    return ans;
}

int g2(int x){
    for(int& x: a)
        x = 0;
    while(x>0){
        ++a[x%10];
        x/=10;
    }
    int ans = 0;
    for(int i = 1; i < 10; ++i)
        while(a[i]--){
            ans *= 10;
            ans += i;
        }

    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed; clog << fixed;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin >> n >> k;
    while(k--)
        n = g1(n) - g2(n);

    cout << n;
}

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

std::pair<std::vector<int>,bool> fct(std::vector<int>z) {
	std::vector<int> a(z.begin(), z.end());
	std::sort(a.rbegin(), a.rend());
	std::vector<int> b(a.rbegin(), a.rend());
	int taille = a.size();
	std::vector<int>ans(taille);
	bool ok = true;
	for (int i = (taille - 1); i >= 0; i--) {
		if (a[i] < b[i]) {
			ans[i] = 10 + a[i] - b[i];
			if (ans[i] != z[i])ok = false;
			if (i >= 1)b[i - 1]++;
		}
		else {
			ans[i] = a[i] - b[i]; if (z[i] != ans[i])ok = false;
		}
	}
	int index = ans.size()-1;
	for (int i = 0; i < ans.size(); i++) {
		if (ans[i] != 0) {
			index = i;
			break;
		}
	}
	std::vector<int> aa;
	for (int i = index; i < ans.size(); i++)aa.emplace_back(ans[i]);

	return make_pair(aa,ok);
}

int main() {
	//int t;
	//std::cin >> t;
	//while (t--) {
		int n, k;
		std::cin >> n >> k;
			if (k == 0) {
				std::cout << n;
				return 0;
			}
		std::vector<int> a;
		int tmp = n;
		while (tmp) {
			a.emplace_back(tmp % 10);
			tmp /= 10;
		}
		//aa.resize(a.size() / 2);
		while (k--) {
			std::pair<std::vector<int>, bool> response = fct(a);
			a.resize(response.first.size());
			a = response.first;
			if (response.second == true) {
				break;
			}
			//for (auto x : a)std::cout << x;
			//std::cout << "\n";
		}
		 for (auto x : a)std::cout << x;
		//std::cout << "\n";
	//}
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define md(a, b)		((a) % b + b) % b
#define mod(a)			md(a, MOD)
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define forn(i, n)			for(int i = 0; i < n; i++)
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
//int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef long long 		ll;
typedef long double ld;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1000000007;
const int MOD1 = 998244353;
const double EPS = 1e-9;
const double PI = acos(-1);

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("qwe.txt", "w", stdout);
	int n, m;
	cin>>n>>m;
	string s[n];
	int con = 0;
	fore(i, 0, n)
	{
		cin>>s[i];
		fore(j, 0, m - 1)
		{
			con += s[i][j] == '.' && s[i][j + 1] == '.';
			if(i > 0)
				con += s[i][j] =='.' && s[i - 1][j] == '.';
		}
		if(i > 0) con += s[i][m - 1] == '.' && s[i - 1][m - 1] == '.';
	}
	cout<<con<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

vector<int> dx = {0, 0, -1, 1}, dy = {1, -1, 0, 0};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') continue;
      for (int k = 0; k < 4; k++) {
        int x = j + dx[k];
        int y = i + dy[k];
        if (x < 0 || w <= x || y < 0 || h <= y) continue;
        if (s[y][x] == '.') ans++;
      }
    }
  }
  cout << ans / 2 << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//const ll INF = numeric_limits<ll>::max() / 4;
//const int INF = numeric_limits<int>::max() / 4;

map<int,set<pair<int,int> > > M; // (moji, (k,d)) dは、その文字の位
vector<bool> F(10,true);
ll X[3];
ll Z[3]; // 最大digit

bool loop(map<int,set<pair<int,int> > >::iterator it, ll x0, ll x1, ll x2){
	if(it == M.end()){
		if(x0 + x1 == x2){
			X[0] = x0;
			X[1] = x1;
			X[2] = x2;
			return true;
		}
		return false;
	}
	auto nt = it;
	nt++;
	for(ll i = 0; i < 10; i++){
		if(!F[i]) continue;
		F[i] = false;
		ll y[3];
		y[0] = x0, y[1] = x1, y[2] = x2;
		bool f = true;
		for(auto jt = it->second.begin(); jt != it->second.end(); jt++){
			if(i == 0 && jt->second == Z[jt->first]) f = false;
			y[jt->first] += i * jt->second;
		}
		if(f){
			if(loop(nt, y[0], y[1], y[2])) return true;
		}
		F[i] = true;
	}
	return false;
}

int main() {
	// ll N;
	string S0, S1, S2;
	cin >> S0 >> S1 >> S2;
	ll d = 1;
	for(int i = S0.length() - 1; 0 <= i; i--){
		int s = S0[i];
		M[s].insert(make_pair(0,d));
		Z[0] = d;
		d *= 10;
	}
	d = 1;
	for(int i = S1.length() - 1; 0 <= i; i--){
		int s = S1[i];
		M[s].insert(make_pair(1,d));
		Z[1] = d;
		d *= 10;
	}
	d = 1;
	for(int i = S2.length() - 1; 0 <= i; i--){
		int s = S2[i];
		M[s].insert(make_pair(2,d));
		Z[2] = d;
		d *= 10;
	}

	int m = M.size();
	if(m > 10){
		cout << "UNSOLVABLE" << endl;
		return 0;
	}

	if(loop(M.begin(),0,0,0)){
		cout << X[0] << endl;
		cout << X[1] << endl;
		cout << X[2] << endl;
		return 0;
	}
	cout << "UNSOLVABLE" << endl;
	return(0);
}

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

#ifdef LOCAL
#include "/debug.h"
#else
#define db(...)
#endif

#define all(v) v.begin(), v.end()
#define pb push_back
using ll = long long;
const int NAX = 2e5 + 5, MOD = 1000000007;

string solveCase(int n, const vector<string> &a)
{
    // TODO: edit here
    vector<int> exist(26);
    vector<char> ss;
    for (auto &x : a)
        for (auto &y : x)
        {
            exist[y - 'a'] = 1;
            ss.pb(y);
        }
    int cnt = count(all(exist), 1);

    sort(all(ss));
    ss.erase(unique(all(ss)), ss.end());

    vector<char> perms;
    for (size_t i = 0; i < 10; i++)
        perms.pb('0' + i);

    if (cnt > 10 || ss.size() > 10)
        return "UNSOLVABLE";

    cnt = 0;
    do
    {
        map<char, char> mp;
        for (size_t i = 0; i < ss.size(); i++)
            mp[ss[i]] = perms[i];
        auto b = a;
        db(mp);
        auto check = [&]() -> bool {
            for (auto &x : b)
                for (auto &y : x)
                    y = mp[y];
            vector<long long> nums(3);
            for (size_t i = 0; i < b.size(); i++)
            {
                for (auto &x : b[i])
                {
                    if ('0' <= x && x <= '9')
                        nums[i] = nums[i] * 10 + x - '0';
                    else
                        return false;
                }
                if (b[i][0] == '0')
                    return false;
            }
            return nums[0] && nums[1] && nums[2] && nums[0] + nums[1] == nums[2];
        };
        if (check())
        {
            string ret;
            for (auto &x : b)
            {
                for (auto &y : x)
                {
                    ret += y;
                }
                ret += "\n";
            }
            ret.pop_back();
            return ret;
        }
    } while (next_permutation(all(perms)));
    return "UNSOLVABLE";
}

// generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator)
int main()
{
#ifndef LOCAL
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    constexpr char endl = '\n';
    // failed to analyze input format
    // TODO: edit here
    int n = 3;
    // cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    auto ans = solveCase(n, a);
    // failed to analyze output format
    // TODO: edit here
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pre(i,a,b) for(int i=a;i>=b;i--)
#define N 20
using namespace std;
char c[N];int k;
int u[N],v[N],s[N],t[N],a[N],b[N];
int Pow(int x,int y){
	int now=1;
	for(;y;y>>=1,x=x*x)if(y&1)now=now*x;
	return now;
}
bool check(){
	long long ans=0;
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	rep(i,1,5)a[s[i]]++,b[t[i]]++;
	rep(i,1,9)ans+=i*Pow(10,a[i])-i*Pow(10,b[i]);
	return ans>0;
}
int main(){
	scanf("%d",&k);
	scanf("%s",c+1);
	rep(i,1,4)s[i]=c[i]-'0';
	scanf("%s",c+1);
	rep(i,1,4)t[i]=c[i]-'0';
	rep(i,1,4)u[s[i]]++,u[t[i]]++;
	double ans=0;
	for(s[5]=1;s[5]<=9;s[5]++)for(t[5]=1;t[5]<=9;t[5]++)if(check()){
		ans+=1.00*(k-u[s[5]])/(9*k-8)*(k-u[t[5]]-(t[5]==s[5]))/(9*k-9);
	}
	printf("%lf\n",ans);
	return 0;
}

//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
template<typename T>void rearrange(vector<ll>&ord, vector<T>&v){
  auto tmp = v;
  for(int i=0;i<tmp.size();i++)v[i] = tmp[ord[i]];
}
template<typename Head, typename... Tail>void rearrange(vector<ll>&ord,Head&& head, Tail&&... tail){
  rearrange(ord, head);
  rearrange(ord, tail...);
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int popcount(ll x){return __builtin_popcountll(x);};
int poplow(ll x){return __builtin_ctzll(x);};
int pophigh(ll x){return 63 - __builtin_clzll(x);};

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  ll k=1<<n;
  ll m=k-1;
  //vector<string>ret(m,string(k,'B'));
  vector<string>ret(1,"AB");
  rep(i,1,n){
    vector<string>nret((1<<i+1)-1,string(1<<i+1,'B'));
    rep(j,0,ret.size()){
      rep(o,0,ret[j].size()){
        if(ret[j][o]=='A'){
          nret[j][o]='A';
          nret[j][o|1<<i]='A';
          nret[j+ret.size()][o]='A';
        }
        if(ret[j][o]=='B'){
          nret[j+ret.size()][o|1<<i]='A';
        }
      }
    }
    /*rep(j,ret.size(),nret.size()){
      ll dif=j-(ll)ret.size();
      //rep(o,0,1<<i)nret[j][(dif+o)%(1<<i+1)]='A';
      rep(o,0,1<<i)nret[j][o]='A';
      swap(nret[j][dif],nret[j][dif+(1<<i)]);
    }*/
    rep(o,0,1<<i)nret.back()[o]='A';
    ret=nret;
  }
  cout<<m<<endl;
  debug(ret,m,k);
  /*ll pos=3;
  vector<ll>cnt(k);
  rep(i,0,m)rep(j,0,k){
    if(ret[i][j]==ret[i][pos])cnt[j]++;
  }
  debug(cnt,k);*/
  return 0;
}


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

int main(){
    int N;
    ll A,B;
    ll ans=0;

    cin>>N;
    rep(i,N){
        cin>>A>>B;
        ans+=B*(B+1)/2-A*(A-1)/2;
    }
    cout<<ans;
    return 0;
}

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

struct ad{
    int left, up, right, down;
};

int time_start;
int Num;
std::vector<ad> ads;
std::vector<std::pair<ad,int>> ads_start;

void in(){
    std::cin >> Num;
    ads.resize(Num);
    ads_start.resize(Num);
    rep(i,0,Num-1){
        std:: cin >> ads[i].left >> ads[i].up;
        ads[i].right = ads[i].left + 1;
        ads[i].down = ads[i].up + 1;
        ads_start[i].first = ads[i];
        std::cin >> ads_start[i].second;
    }
}

void make_randomcase(){

}

bool is_collision(int N){
    if(ads[N].left<0||ads[N].up<0||ads[N].right>10000||ads[N].down>10000) return true;
    rep(i,0,Num-1){
        if(i==N) continue;
        if( std::max(ads[i].left,ads[N].left) < std::min(ads[i].right,ads[N].right) && std::max(ads[i].up,ads[N].up) < std::min(ads[i].down,ads[N].down) ){
            return true;
        }
    }
    return false;
}

int score(){
    long double point=0;
    rep(i,0,Num-1){
        point+=1.0-pow(1-1.0*std::min(ads_start[i].second,(ads[i].right-ads[i].left)*(ads[i].down-ads[i].up))/std::max(ads_start[i].second,(ads[i].right-ads[i].left)*(ads[i].down-ads[i].up)),2);
    }
    point *= 1e9;
    point /= Num;
    return round(point);
}

//ランダムに広げる（広げて得をして、なおかつできるものだけ広げる）

void solve(){
    std::vector<std::vector<int>> delta(4,std::vector<int> (4,0));
    delta[0][0] = delta[1][1] = -1;
    delta[2][2] = delta[3][3] = 1;
    std::vector<ad> best_ads(Num);
    int bestscore = score();
    rep(_,0,44){
        rep(i,0,Num-1){
            ads[i] = ads_start[i].first;
        }
        time_start = clock();
        while(clock() - time_start < 100000){
            int select = random()%Num;
            int direction = random()%4;
            int stretch = ( 10 - (clock() - time_start) / 10000 ) * ( random()%10 + 1 );
            ads[select].left += stretch * delta[direction][0];
            ads[select].up += stretch * delta[direction][1];
            ads[select].right += stretch * delta[direction][2];
            ads[select].down += stretch * delta[direction][3];
            if(is_collision(select)||(ads[select].right-ads[select].left)*(ads[select].down-ads[select].up)>ads_start[select].second*std::min((long)10, 7 + ( clock() - time_start ) / 20000) / 10){
                ads[select].left -= stretch * delta[direction][0];
                ads[select].up -= stretch * delta[direction][1];
                ads[select].right -= stretch * delta[direction][2];
                ads[select].down -= stretch * delta[direction][3];
            }
        }
        if(bestscore < score()){
            bestscore = score();
            best_ads = ads;
        }
    }
    ads = best_ads;
}

void out(){
    rep(i,0,Num-1){
        std::cout << ads[i].left << ' ' << ads[i].up << ' ' << ads[i].right << ' ' << ads[i].down << '\n';
    }
}

int main() {
    srand((unsigned int)time(NULL));
    time_start = std::clock();
    in();
    solve();
    out();
    std::cerr << score() << std::endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,b) for(int i=0;i<b;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
main()
{
	fast
	int n,k;
	cin>>n>>k;
	int o=0,e=0;
	loop(i,n){
		string str;
		cin>>str;
		int cnt=0;
		loop(i,k){
			if(str[i]=='1') 	cnt++;
		}
		if(cnt%2==1) 	o++;
		else			e++;
	}
	cout<<(ll)o*(ll)e;
	cerr<<"time taken: "<<(float)clock()/CLOCKS_PER_SEC<<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

int n, m;

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

	cin >> n >> m;

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

	ll a = 0, b = 0;
	for(int x=0;x<n;x++){
		int cnt = 0;
		for(int y=0;y<m;y++){
			if(data[x][y] == '1') cnt++;
		}
		if(cnt&1) a++;
		else b++;
	}

	cout << a*b << "\n";
    return 0;
}

// Santai
// Pikirin dengan benar-benar


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

int gcd(int a,int b){
  int g=max(a,b),l=min(a,b),n=l;
  while(g%l!=0){
    n=g%l;
    g=l;
    l=n;
  }
  return l;
}

int main(){
  int n;
  cin>>n;
  vector<int64_t>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int ans=a[0];
  for(int i=0;i<n;i++){
    ans=gcd(ans,a[i]);
  }
  cout<<ans<<endl;
}

#include <iostream>
#include <cstdio>
using namespace std;
int n,a,now;
int gcd(int x,int y)
{
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
int main()
{
	scanf("%d%d",&n,&now);
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&a);
		now=gcd(now,a);
	}
	printf("%d",now);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int n,d;

inline ll calc(int x)
{
	if(x<2 || x>2*n) return 0;

	int l = max(x-n, 1), r = min(x-1, n);

	return r<l? 0: r-l+1;
}

int main(void)
{
	scanf("%d%d",&n,&d);

	ll ans = 0;
	for(int i=2; i<=2*n; ++i)
		ans += calc(i) * calc(i-d);

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

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

ll a[300005], b[300005];

int main(){

    int n;
    cin >> n;
    ll res = 0;
    for(int i = 0; i < n; i ++ )    cin >> a[i], res += a[i] * a[i] * (n - 1);

    for(int i = n - 1; i >= 0; i -- ){
        b[i] = b[i + 1] + a[i];
    }
    ll ans = 0;
    for(int i = 0; i < n; i ++ ){
        ans += b[i + 1] * a[i];
    }
    ans *= 2;
    cout << res - ans << endl;
    return 0;
}


#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
typedef long long LL;
const int N=1007;
int n,m,c,a,vH[N],vL[N];
char G[N][N];
void flyL(int);
void flyH(int u) {
	if(vH[u]) return;
	vH[u]=c;
	For(v,1,m) if(G[u][v]=='#') flyL(v);
}
void flyL(int u) {
	if(vL[u]) return;
	vL[u]=c;
	For(v,1,n) if(G[v][u]=='#') flyH(v);
}
int main() {
	scanf("%d%d",&n,&m);
	For(i,1,n) scanf("%s",G[i]+1);
	G[1][1]=G[n][1]=G[1][m]=G[n][m]='#';
	For(i,1,n) if(!vH[i]) ++c,flyH(i);
	For(i,1,n) vH[i]=0;
	For(i,1,m) vL[i]=0;
	a=c,c=0;
	For(i,1,m) if(!vL[i]) ++c,flyL(i);
	printf("%d",min(c-1,a-1));
	return 0;
}

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

using namespace std;
//using namespace atcoder;

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

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

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

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

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

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

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

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

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

// edit

struct UnionFind {
    vector<int> par, sz;
    vector<map<int, int>> cnum;

    UnionFind(int n) : par(n), sz(n, 1), cnum(n) {
        for (int i = 0; i < n; ++i) par[i] = i;
    }

    void cls(int x, int s) {
        cnum[x][s] = 1;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sz[x] < sz[y]) swap(x, y);
        par[y] = x;
        sz[x] += sz[y];
        sz[y] = 0;

        for (auto kv : move(cnum[y])) {
            cnum[x][kv.first] += kv.second;
        }

    }

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

    int size(int x) {
        return sz[root(x)];
    }
};

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

    UnionFind uf(N);

    for (int i = 0; i < N; ++i) {
        int c;
        cin >> c;
        c--;
        uf.cls(i, c);
    }

    while (Q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            uf.merge(a, b);
        } else {
            int x, y;
            cin >> x >> y;
            x--;
            y--;
            ll ans = uf.cnum[uf.root(x)][y];
            cout << ans << endl;
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();

    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;

int main(){
  intt N,M,T;cin>>N>>M>>T;
  intt rest=N;
  intt pre_date=0;
  int judge=1;
  rep(i,0,M){
    int a,b;cin>>a>>b;
    if(i==0){
      rest-=a;
    }else rest-=a-pre_date;
    if(rest<=0)judge=0;
    rest+=b-a;
    if(rest>N)rest=N;
    pre_date=b;
  }
  rest-=T-pre_date;
  if(rest<=0)judge=0;
  if(judge)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int a[maxn],b[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    int sum,num,en;
    cin>>sum>>num>>en;
    int ls=0,x=sum;
    for(int i=1;i<=num;i++)
    {
    	cin>>a[i]>>b[i];
    	sum-=(a[i]-ls);
    	if(sum<=0)
    	{
    		cout<<"No"<<endl;
    		return 0;
		}
		ls=b[i];
		sum+=(b[i]-a[i]);
		sum=min(x,sum);
	}
	sum-=en-ls;
	if(sum<=0)
	{
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define REP(i,a,b) for(long long int i=a;i<b;i++)
#define REPR(i,a,b) for(long long int i=a;i>=b;i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define MAX LLONG_MAX
const int mxn=2e5+5;
#define INF 1e18
//----------------------------------------------------------------------------------------
//lower_bound returns an iterator pointing to the first ele. which has a value not less than ‘val
#define LB(arr,n) ll c=0;it=lower_bound(arr.begin(),arr.end(),n);if(it==arr.end()){c=1;}
//define it and if c==1 means not found
#define LB1(arr,n) ll idx=it-arr.begin();if(arr[idx]==n){ idx=idx;}else{idx=idx-1;}
// here idx holds the index( 0 based) of found element
//-----------------------------------------------------------------------------------------
//upper_bound returns an iterator pointing to the first ele. which has a value greater than ‘val’.
#define UB(arr,n) ll c=0;it=upper_bound(arr.begin(),arr.end(),n);if(it==arr.end()){c=1;}
#define UB1(arr,n) ll idx=it-arr.begin();
//-----------------------------------------------------------------------------------------

ll power(ll a,ll b,ll m) { ll ans=1; while(b) { if(b&1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return (ans+m)%m; }

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

ll modInverse(ll a, ll m) { ll g = __gcd(a, m); return power(a, m-2, m); }

bool cmp(pair<int ,int > &a,pair<int ,int > & b){
    if(a.second!=b.second){
        return a.first<b.first;
    }
    else{
        return a.second<b.second;
    }
}
//prime factors of 10^18
vector<long long int> genfactors(long long int n){
    vector<long long int> res;
    long long int val = 2;
    for(long long int i = 2; i*i <= n ; ++i){
        while(n%i == 0){
            res.push_back(i);
            n/=i;
        }
    }
    if(n > 1) res.push_back(n);
    return res;
}
//--------------------------------------------------------------------------------------------

void solve(){
	ll n,k,m;
	ll a,b,c;
	cin>>a>>b>>c;
	if(c==0){
		if(a<=b)cout<<"Aoki"<<endl;
		else cout<<"Takahashi"<<endl;
	}
	else {
		if(a>=b)cout<<"Takahashi"<<endl;
		else cout<<"Aoki"<<endl;
	}

}
int main()
{
    fastIO;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        solve();

	}
    return 0;
}

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(firstsecond) '(' << first< ',' << second< ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-8;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

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

using Graph = vector<vector<pair<ll,ll>>>;

const unsigned long long int cycle_per_sec = 2800000000;

unsigned long long int getCycle(){
    unsigned int low, high;
    __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
    return ((unsigned long long int)low) | ((unsigned long long int)high << 32);
}

double getTime (unsigned long long int begin_cycle) {
    return (double)(getCycle() - begin_cycle) / cycle_per_sec;
}

auto start_cycle = getCycle();
random_device seed_gen;
mt19937_64 rnd(seed_gen());

ll range_rand(ll a,ll b){
    uniform_int_distribution<ll> dist_res(a,b);
    return dist_res(rnd);
}

// MOD確認

constexpr long double start_temp = 100,end_temp = 30,TIME_LIMIT = 2.0;

ll dx[4]{-1,0,1,0};
ll dy[4]{0,-1,0,1};
char D[4]{'L','U','R','D'};

ll N = 50,SX,SY;
ll feild[60][60];
ll point[2510];
ll done[2510];

string ans_command = "";
ll ans_score = 0;

bool in_range(ll x,ll y){
    return (0 <= y && y < N && 0 <= x && x < N);
}

void dfs(ll now_y,ll now_x,ll now_score,string now_command){
    ll now_tile = feild[now_y][now_x];
    ll p = point[now_tile];
    done[now_tile] = 1;
    now_score += p;
    if(!in_range(now_y,now_x)){
        cout << "BAD" << endl;
    }
    if(now_score > ans_score){
        ans_score = now_score;
        ans_command = now_command;
    }
    if(getTime(start_cycle) > TIME_LIMIT) return;
    rep(i,4){
        ll next_y = now_y + dy[i],next_x = now_x + dx[i];
        ll next_tile = feild[next_y][next_x];
        if(!in_range(next_y,next_x) || done[next_tile]) continue;
        string next_command = now_command + D[i];
        dfs(next_y,next_x,now_score,next_command);
    }
    done[now_tile] = 0;
    now_score -= p;
    return ;
}

int main(){
    cin >> SY >> SX;
    rep(i,N) rep(j,N) cin >> feild[i][j];
    rep(i,N) rep(j,N){
        ll p;
        cin >> p;
        point[feild[i][j]] += p;
    }
    start_cycle = getCycle();
    dfs(SY,SX,0,"");
    cout << ans_command << endl;
}


#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

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

	cin >> N;
	vector<int>v(N * 2);
	for (auto& i : v)cin >> i;
	priority_queue<int, vector<int>, greater<int>>PQ;
	for (int i = N, j = N - 1; i < 2 * N; i++, j--) {
		PQ.push(v[i]);
		PQ.push(v[j]);
		PQ.pop();
	}
	long long int ans = 0;
	while (!PQ.empty()) {
		ans += PQ.top();
		PQ.pop();
	}
	cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
void read (int &x) {
    char ch = getchar(); x = 0; while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 2e5 + 5;
int n; pair<int, int> a[N * 2];
struct tree {
    int c[N << 2], tag[N << 2];
    #define ls (p << 1)
    #define rs (p << 1 | 1)
    void push_down (int p) {
        c[ls] += tag[p], c[rs] += tag[p];
        tag[ls] += tag[p], tag[rs] += tag[p]; tag[p] = 0;
    }
    void modify (int p, int l, int r, int ql, int qr, int v) {
         if (ql <= l && r <= qr) {
             c[p] += v, tag[p] += v; return;
         }
         int mid (l + r >> 1); push_down (p);
         if (ql <= mid) modify (ls, l, mid, ql, qr, v);
         if (qr > mid) modify (rs, mid + 1, r, ql, qr, v);
         c[p] = min (c[ls], c[rs]);
    }
    int query (int p, int l, int r, int ql, int qr) {
        if (ql <= l && r <= qr) return c[p];
        int mid (l + r >> 1), s = 1e9; push_down (p);
        if (ql <= mid) s = query (ls, l, mid, ql, qr);
        if (qr > mid) s = min (s, query (rs, mid + 1, r, ql, qr));
        return s;
    }
} qwq;
signed main() {
    read (n); int c = 0;
    for (int i = n, x; i >= 1; --i)
        read (x), a[++c] = {x, i};
    for (int i = 1, x; i <= n; ++i)
        read (x), a[++c] = {x, i};
    sort (a + 1, a + c + 1);
    for (int i = 1; i <= n; ++i) qwq.modify (1, 1, n, i, i, i);
    long long res = 0;
    for (int i = c, s = n; i >= 1 && s; --i) {
        int x = a[i].first, y = a[i].second;
        if (qwq.query (1, 1, n, y, n) >= 1) {
            --s, res += x, qwq.modify (1, 1, n, y, n, -1);
        }
    }
    return printf ("%lld\n", res), 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<vector<ll>>adj(200010);
ll vis[200010];
vector<ll>ans;
map<ll,ll>mp;
ll c[200010];
void dfs(ll u)
{
    vis[u]=1;
    mp[c[u]]++;
    for(auto it=adj[u].begin();it!=adj[u].end();it++)
    {
        if(!vis[*it])
        {
            if(mp[c[*it]]==0)
                 ans.push_back(*it);
            dfs(*it);
        }
    }
    mp[c[u]]--;

}
int main()
{
    ll n;
    cin>>n;
    ll i;
    for(i=1;i<=n;i++)
    {
        cin>>c[i];
    }
    for(ll i=0;i<n-1;i++)
    {
        ll x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(1);
    ans.push_back(1);
    sort(ans.begin(),ans.end());
    for(i=0;i<ans.size();i++)
        cout<<ans[i]<<endl;
}

#include "bits/stdc++.h"

using namespace std;

#define pb push_back

#define ice(i, a, b) for (int (i) = (a); (i) < (b); ++(i))

vector<vector<int>> adj(100001);
vector<int> color(100001);
vector<bool> good(100001);

void dfs(int n, multiset<int>& s, int m = -1) {
    if (!s.count(color[n])) {
        good[n] = true;
    }
    s.insert(color[n]);
    for (int p : adj[n]) {
        if (p != m) {
            dfs(p, s, n);
        }
    }
    s.erase(s.find(color[n]));
}

void solve() {
    int n; cin >> n;
    ice (i, 0, n) {
        cin >> color[i];
    }
    ice (i, 0, n - 1) {
        int a, b; cin >> a >> b; a--; b--;
        adj[a].pb(b); adj[b].pb(a);
    }
    multiset<int> s;
    dfs(0, s);
    ice (i, 0, n) {
        if (good[i]) {
            cout << i + 1 << '\n';
        }
    }
}

int main() {
    solve();
}


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

// modpow
template<class T> T modpow(T b,T p,T m){
  T rt = 1; b %= m;
  while(p>0){
    if(p&1) rt = (rt*b)%m;
    b = (b*b)%m; p>>=1;
  }
  return rt;
}

// small mod combination
// # f,g を次のようにする
// - f[i] : i が何回 MOD で割れるか. これを f_pre とする
// - g[i] : i の MOD で割れない部分の MOD での余り. これを g_pre とする
// # その後, f,g を次のようにする
// - f[i] : i! が何回 MOD で割れるか
//   * f[i] = f_pre[1]+...+f_pre[i] 累積和
// - g[i] : i! が MOD で割れない部分の MOD での余り
//   * g[i] = g_pre[1]*...*g_pre[i] 累積積(mod)
const int64_t MOD = 3;
const int64_t fMAX = 400007;
int64_t f[fMAX+1],g[fMAX+1],g_inv[fMAX+1];

void init(){
  for(int64_t i=1,tmp;i<=fMAX;i++){
    tmp = i;
    while(tmp%3==0){
      tmp /= 3; f[i]++;
    }
    g[i] = tmp%3;
  }
  g[0]=1;
  for(int64_t i=1;i<=fMAX;i++)
    f[i] += f[i-1];
  for(int64_t i=1;i<=fMAX;i++)
    g[i] = g[i]*g[i-1]%MOD;
  for(int64_t i=0;i<=fMAX;i++)
    g_inv[i] = modpow(g[i],MOD-2,MOD);
  return;
}

int64_t modcomb_s(int64_t n,int64_t r,int64_t m){
  if(f[n]-f[r]-f[n-r]>0) return 0;
  return g[n]*g_inv[r]*g_inv[n-r]%m;
}

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

  int64_t n; cin >> n;
  string s; cin >> s;

  init();
  vector<int64_t> a(n);
  for(int64_t i=0;i<n;i++){
    if(s[i]=='B') a[i] = 0;
    else if(s[i]=='R') a[i] = 1;
    else if(s[i]=='W') a[i] = 2;
  }
  int64_t ans=0;
  for(int64_t i=0;i<n;i++){
    ans += a[i] * modcomb_s(n-1,i,MOD);
    ans %= MOD;
  }

  ans = ans * modpow((int64_t)2,n-1,MOD) % MOD;

  string ans_s;
  if(ans==0) ans_s='B';
  else if(ans==1) ans_s='R';
  else if(ans==2) ans_s='W';

  cout << ans_s << "\n";

  return 0;
}

// KNOW NOTHING!
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define sz(x) (int)x.size()
#define szs(x) (int)x.length()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef queue<int> qin;
typedef deque<ll> dqll;
typedef deque<int> dqint;
typedef priority_queue<ll> pqll;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
ll mpwr(ll b,ll p){ll res=1;while(p){if(p&1) {res=(res*b)%MOD; p--;}else{b=(b*b)%MOD; p>>=1;}}return res;}
int msb (int n) {return 31-__builtin_clz(n);}
ll msbl (ll n) {return 63-__builtin_clzll(n);}
int lsb (int n) {return __builtin_ctz(n);}
ll  lsbl (ll n) {return __builtin_ctzll(n);}
int setbit (int n) {return __builtin_popcount(n);}
ll setbitl (ll n) {return __builtin_popcountll(n);}
int main()
{
/*
freopen ("input.txt","r","stdin");
freopen ("output.txt","w","stdout");
*/
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
int h,w; cin>>h>>w;
int x, y; cin>>x>>y;
vector<string> v (h);
F (i,0,h,1) cin>>v[i];
--x; --y;
int cnt=0;
DF (i,y,0,1) {
	if (v[x][i]=='#') break;
	else ++cnt;
}
F (i,y+1,w,1) {
	if (v[x][i]=='#') break;
	else ++cnt;
}
DF (i,x-1,0,1) {
	if (v[i][y]=='#') break;
	else ++cnt;
}
F (i,x+1,h,1) {
	if (v[i][y]=='#') break;
	else ++cnt;
}
cout<<cnt;
return 0;
}
/* What we know is a drop , but what we don't know is an ocean !*/


#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <bitset>

using namespace std;
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define rep2(i,n,i2,n2) for (ll i = 0; i < (n) ; i++) for (ll i2 = 0; i2 < (n2) ; i2++)
#define incRepFT(i,s,n) for (ll i = (s); i <= (n) ; i++)
#define decRepFT(i,s,n) for (ll i = (s); i >= (n) ; i--)

#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vstr vector<string>
#define vvstr vector<vector<string>>
typedef pair<ll,ll> P;

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

// for(char c : S)

//min({a1, a2, ..., an})
//max({a1, a2, ..., an})
//swap(a, b)
//S.substr(si)
// sort <--> reverse
//count(v.begin(), v.end(), x)
// char t - 'a'
// char t - '0'

//xを2進数にした時の1の数
//__builtin_popcount(x)
//__builtin_popcountll(x)

ll A;
ll B;
ll C;
ll D;
ll N;
ll M;
ll K;
ll T;
ll H;
ll W;
ll X;
ll Y;
ll Z;

string S;

ll ltmp;
string stmp;
double dtmp;

ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}
P d_move[4] = {
    P(0 , 1),P(0 , -1),P(1 , 0),P(-1 , 0)//,P(1 , 1),P(1 , -1),P(-1 , 1),P(-1 , -1)
};
//for(P drc : d_move)

double double_hosei = 1000000; //求められる精度分補正をかけておく
int main(){

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

    cin >> N;
    ll ans = 0;
    for( ll v1 = 1 ; v1 <=N ; v1++ ){
        S = to_string(v1);
        ll keta = pow(10,S.size());
        ltmp = v1 * keta + v1;
        if(ltmp>N) break;
        ans++;
    }
    cout << ans << endl;

}

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

ll f(ll x){
    string s = to_string(x);
    return stoll(s+s);
}

int main(){
    ll n;
    cin >> n;
    ll x = 1;
    // n以下までループする
    while(f(x) <= n) ++x;
    ll ans = x-1;
    cout << ans <<endl;
    return 0;
}


#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
#include <unordered_map>

//  using declaration, alias
using llong = long long;
using ldouble = long double;

// constant
constexpr auto INF_LL = 0x7FFFFFFFFFFFFFFFLL;
// constexpr auto MOD = 0LL;

namespace io {
  template <class T = llong> auto in() {T a;std::cin >> a;return a;}
  template <class T = llong> auto in(int n) {std::vector<T> v(n); for (auto& vi : v) vi = in<T>(); return v;}
  template <class T = llong> auto in(int n, int m) {std::vector<std::vector<T>> v(n, std::vector<T>(m)); for (auto& vi : v) for (auto& vij : vi) vij = in<T>(); return v;}
  template <size_t... S, class... T> void in_var(std::index_sequence<S...>, std::tuple<T...>& t) {std::initializer_list<int>{(std::get<S>(t) = in<T>(), 0)...};}
  template <size_t... S, class... T> void in_vec(std::index_sequence<S...>, std::tuple<std::vector<T>...>& t) {std::initializer_list<int>{(std::get<S>(t).emplace_back(in<T>()), 0)...};}
  template <class T, class U, class... V> auto in() {std::tuple<T, U, V...> t; in_var(std::index_sequence_for<T, U, V...>(), t); return t;}
  template <class T, class U, class... V> auto in(int n) {std::tuple<std::vector<T>, std::vector<U>, std::vector<V>...> t; for (auto i = 0; i < n; i++) in_vec(std::index_sequence_for<T, U, V...>(), t); return t;}
  template <int N, class T = llong, class... U> auto in() {if constexpr (N > 1) return in<N - 1, T, T, U...>(); else return in<T, U...>();}
  template <int N, class T = llong, class... U> auto in(int n) {if constexpr (N > 1) return in<N - 1, T, T, U...>(n); else return in<T, U...>(n);}
  template <class T> void out(T a) {std::cout << a << "\n";}
  template <class T, class... U> void out(T a, U... b) {std::cout << a << " "; out(b...);}
}

void dfs(llong node, llong node_b, std::vector<llong>& color, std::unordered_map<llong, std::vector<llong>>& graph, std::vector<llong>& count, std::vector<llong>& result) {
  if (count[color[node - 1] - 1] == 0) result.emplace_back(node);
  count[color[node - 1] - 1]++;
  for (auto to : graph[node]) {
    if (to != node_b) dfs(to, node, color, graph, count, result);
  }
  count[color[node - 1] - 1]--;
}

int main() {
  // input
  auto N = io::in();
  auto C = io::in(N);
  auto [A, B] = io::in<2>(N - 1);

  // solve
  std::unordered_map<llong, std::vector<llong>> graph;
  for (auto i = 0LL; i < N - 1; i++) {
    graph[A[i]].emplace_back(B[i]);
    graph[B[i]].emplace_back(A[i]);
  }
  std::vector<llong> count(100000, 0LL);
  std::vector<llong> result;
  dfs(1, 0, C, graph, count, result);
  std::sort(result.begin(), result.end());

  // output
  for (auto r : result) io::out(r);
}

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A, class B> inline void chmod(A &a, const B b) { a = a%b; return; }

void dfs(int node);

int n, c[100000], a, b, pal[100000], pass[100000];
vector<int> vec[100000];

int main() {
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> c[i];
    c[i]--;
  }
  for (int i=0; i<n-1; i++) {
    cin >> a >> b;
    a--, b--;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }

  dfs(0);
  for (int i=0; i<n; i++) {
    if (c[i] > -1) {
      cout << i+1 << endl;
    }
  }
  return (0);
}

void dfs(int node) {
  if ( pass[node] == 0 ) {
    pass[node] = 1;
    pal[c[node]]++;
    for (int i=0; i<vec[node].size(); i++) {
      dfs(vec[node][i]);
    }
    pal[c[node]]--;
    if ( pal[c[node]] > 0 ) {
      c[node] = -1;
    }
  }
  return;
}


#include <bits/stdc++.h>
#define ALL(s) (s).begin(),(s).end()
using namespace std;
using ll=long long;
ll M=1000000007LL;
int main(void)
{
    ll h,w,ans=0; cin>>h>>w; vector<string> s(h);
    for(ll i=0;i<h;i++) cin>>s[i];
    for(ll i=0;i<h;i++)
    {
        for(ll j=0;j<w-1;j++)
        {
            if(s[i][j]==s[i][j+1]&&s[i][j]=='.') ans++;
        }
    }
    for(ll i=0;i<w;i++)
    {
        for(ll j=0;j<h-1;j++)
        {
            if(s[j][i]==s[j+1][i]&&s[j][i]=='.') ans++;
        }
    }
    cout<<ans<<endl;
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;

ll symb(char a) {
    if (a == 'A') return 0;
    if (a == 'T') return 1;
    if (a == 'C') return 2;
    if (a == 'G') return 3;
}

int main()
{
    fastInp;

    string s;
    ll n;
    cin >> n >> s;

    ll ans = 0;
    for (int i = 0; i < s.size(); i++) {
        vector<ll> k(4);
        for (int j = i; j < s.size(); j++) {
            k[symb(s[j])]++;
            if (k[0] == k[1] && k[2] == k[3]) ans++;
        }
    }

    cout << ans;

    return 0;
}