// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

#define double unsigned ll

enum{N=104};

struct P{
	double x,y;
	bool operator==(const P&e)const{ return x==e.x&&y==e.y; }
	bool operator<(const P&e)const{ if( x!=e.x ) return x<e.x; return y<e.y; }
};
il P operator+(const P&a,const P&b){ return (P){a.x+b.x,a.y+b.y}; }
il P operator-(const P&a,const P&b){ return (P){a.x-b.x,a.y-b.y}; }
il P operator*(const P&a,const double b){ return (P){a.x*b,a.y*b}; }
il double dot(const P&a,const P&b){ return a.x*b.x+a.y*b.y; }
il double cross(const P&a,const P&b){ return a.x*b.y-a.y*b.x; }
il double dist(const P&a,const P&b){ return sqrt(dot(a-b,a-b)); }

P d0[N],d1[N];

int main(){
	int n = ci();
	if( n==1 ){ cout<<"Yes"<<endl; return 0; }
	rep(i,1,n) d0[i] = (P){(double)((ll)ci()),(double)((ll)ci())};
	rep(i,1,n) d1[i] = (P){(double)((ll)ci()),(double)((ll)ci())};
	P a0 = d0[2]-d0[1];
	P a1 = (P){a0.y,-a0.x};
	double x1 = 0, x2 = 0, x3 = 0;
	rep(i,1,n){
		double x = dot(d0[i]-d0[1],a0)*(double)(1e9+7)+dot(d0[i]-d0[1],a1);
		x1 += x;
		x2 += x*x*x*x;
		x3 += x*x*x;
	}
//	printf("x123 %llu %llu %llu\n",x1,x2,x3);
	rep(i,1,n){
		rep(j,1,n) if( i!=j ){
			a0 = d1[j]-d1[i];
			a1 = (P){a0.y,-a0.x};
			double y1 = 0, y2 = 0, y3 = 0;
			rep(k,1,n){
				double x = dot(d1[k]-d1[i],a0)*(double)(1e9+7)+dot(d1[k]-d1[i],a1);
				y1 += x;
				y2 += x*x*x*x;
				y3 += x*x*x;
			}
//			printf("%d %d : \n",i,j);
//			printf("y123 %llu %llu %llu\n",y1,y2,y3);
			if( x1==y1 && x2==y2 && x3==y3 ){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
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);
}
/*-------------------------------------------*/

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

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    vector<int> ans, used(n);

    FOR(i, 1, n) {
        int j = i;
        while(j > 0 && p[j - 1] > p[j]) {
            swap(p[j - 1], p[j]);
            if(used[j]) {
                cout << -1 << endl;
                return 0;
            }
            ans.push_back(j);
            used[j] = 1;
            j--;
        }
    }

    if((int)ans.size() != n - 1) {
        cout << -1 << endl;
        return 0;
    }

    rep(i, n - 1) cout << ans[i] << endl;

    return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define per1(i,n) for(int i=(n);i>=1;i--)
#define repk(i,a,b) for(int i=(a);i<=(b);i++)
#define perk(i,a,b) for(int i=(a);i>=(b);i--)
#define rep0(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp make_pair
#define g(x) cout<<#x<<'='<<x<<endl
#define nextp next_permutation
#define pq priority_queue
#define fi first
#define se second
typedef long long ll;
using namespace std;
const ll mod1=998244353;
const ll mod2=1000000007;
//long long , 特判
//ios_base::sync_with_stdio(false);加快cin
long long f(long long a)
{
	long long res=1;
	for(int i=1;i<=a;++i)
	{
		res=res*i%mod2;
	}
	return res;
}
long long qkpw(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%mod2;
		a=a*a%mod2;
		b>>=1;
	}
	return res;
}
long long inv(long long a)
{
	return qkpw(a,mod2-2);
}
long long c(long long n,long long m)
{
	if(n<m) return 0;
	return f(n)*inv(f(m)*f(n-m)%mod2)%mod2;
}
long long n,m,k;
int main()
{
	cin>>n>>m>>k;
	if(n>m+k) cout<<0<<endl;
	else cout<<(c(n+m,n)-c(n+m,k+m+1)+mod2)%mod2<<endl;
	return 0;
}

#include <cctype>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <ios>
#include <iostream>
#include <iterator>
#include <string_view>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <climits>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <regex>
#include <set>
#include <bitset>
#include <list>

const int64_t infl = 1LL << 60;
const int64_t cc = pow(10, 9) + 7;
bool sort_pair(std::pair<int64_t, char> origin,
               std::pair<int64_t, int64_t> another) {
  return origin.first < another.first;
}
bool sort_pair2(std::pair<int64_t, char> origin,
               std::pair<int64_t, int64_t> another) {
  return origin.second < another.second;
}

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

//繰り返し二乗法
int64_t RepeatSquaring( int64_t n, int64_t p, int64_t mod )
{
    if( p == 0 )
    {
        return 1;
    }

    if( p % 2 == 0 )
    {
        int64_t t = RepeatSquaring( n, p / 2, mod );
        return t * t % mod;
    }

    return n * RepeatSquaring( n, p - 1, mod ) % mod;
}

//フェルマーの小定理を利用するのでmodが素数の時のみ
int64_t waru_mod( int64_t a, int64_t b, int64_t mod )
{
    b = RepeatSquaring( b, mod - 2, mod ) % mod;
    return  ( a * b ) % mod;
}

//コンビネーションをmodで割った余りを産出
int64_t nCk( int64_t n, int64_t k, int64_t mod )
{
    int64_t ans_x = 1;
    int64_t ans_y = 1;

    for( int i = n; i > n - k; i-- )
    {
        ans_x *= i;
        ans_x %= mod;
    }

    for( int i = 1; i <= k; i++ )
    {
        ans_y *= i;
        ans_y %= mod;
    }

    return waru_mod( ans_x, ans_y, mod );
}

int main()
{
    int64_t q,k,h,w,d,m,n;
    std::cin>> n;
    std::cin>> m;
    std::cin>> k;

    if( k + m < n )
    {
        std::cout<< 0;
    }
    else
    {
        q = nCk( n + m, n, cc );

        if( n - k - 1 < 0 )
        {
            h = 0;
        }
        else
        {
            h = nCk( n + m, n - k - 1, cc );
        }

        q -= h;
        q %= cc;

        if( q < 0 ) q += cc;

        std::cout<< q;
    }
}


#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// #pragma GCC optimize("O2")
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef multiset <ll> mms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define deb(x) cout << #x << " " << x << endl;
#define ff first
#define ss second
#define pb(v) push_back(v)
#define lb(v) lower_bound(v)
#define ub(v) upper_bound(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b) {
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s) {
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v) {
	forl(i,v.size()) cout<<v[i]<<" ";
	cout<<"\n";
}
void pa(ll *v, ll size) {
	forl(i,size) cout<<v[i]<<" ";
	cout<<"\n";
}
void removeDups(mv &v) {
	sort(all(v));
	mv::iterator it = unique(v.begin(), v.end());
	v.resize(distance(v.begin(), it));
}
inline ld kthRoot(ld n, ll k) {
	return pow(k, (1.0 / k) * (log(n) / log(k)));
}
ll power(ll x, ll y, ll p) {
	ll res=1;
	x=x%p;
	while(y>0) {
		if(y&1) res = (res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x, ll mod) {
	if(x>=mod) x%=mod;
}

ll mod = 1e9 + 7;

void thisIsMain() {
	ll n, s, d;
	cin>>n>>s>>d;
	bool f = 0;
	forl(i,n) {
		ll x, y;
		cin>>x>>y;
		if(x < s && y > d) f = 1;
	}
	if(f) cout<<"Yes\n" ;else cout<<"No\n";
}

int main(void)
{
	fastio
	ll t = 1;
	// cin>>t;
	while(t--) thisIsMain();
	return 0;
}

#include<iostream>
#include<cmath>
#define ll long long
using namespace std;
const double eps = 1e-8;

int main() {
	long double a, b, c, d;
	cin >> a >> b >> c >> d;
	if (d*c-b < eps) cout << -1;
	else cout << ceil(a/(d*c-b));
	return 0;
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>

using namespace std;

int main() {
	/*(P-1)*(P-2)^(N-1)を出力すればよい。*/

	long long N, P;
	cin >> N >> P;

	long long ans = P - 1;
	long long b = P - 2;
	N = N - 1;
	while (N > 0) {
		if (N % 2 == 1) {
			ans *= b;
			ans %= 1000000007;
		}
		b = b * b % 1000000007;
		N = N / 2;
	}

	cout << ans;
}

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

long long MOD = 1000000007;

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

int main() {
    long long n,p;
    cin>>n>>p;

    cout<<(modpow(p-2,n-1,MOD)*(p-1))%MOD;
	return 0;
}


//#include <atcoder/all>
//using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define bit(n) (1LL<<(n))
#define FIX(d) fixed << setprecision(d)
using P = pair<int, int>;
using LP = pair<ll, ll>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const ll LINF = (1LL<<60);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int v,t,s,d;
  cin >> v >> t >> s >> d;
  if(v*t<=d && d<=v*s) cout << "No\n";
  else cout << "Yes\n";

  return 0;
}

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

bool can_go(int x, int y, vector<vector<char>> s) {
    if(s[x][y] == '.') return true;
    else return false;
}

int main() {
    int h, w, x, y;
    cin >> h >> w >> x >> y;
    x--; y--;
    vector<vector<char>> s(h, vector<char> (w));
    rep(i, h) {
        rep(j, w) cin >> s[i][j];
    }

    int ans = 1;
    int s_x = x;
    int s_y = y;

    // turn right
    while (1){
        y++;
        if(y < w) {
            if(can_go(x, y, s)) ans++;
            else break;
        }
        else break;
    }
    x = s_x;
    y = s_y;
    // turn left
    while (1){
        y--;
        if(-1 < y) {
            if(can_go(x, y, s)) ans++;
            else break;
        }
        else break;
    }
    x = s_x;
    y = s_y;
    // up
    while (1){
        x--;
        if(-1 < x) {
            if(can_go(x, y, s)) ans++;
            else break;
        }
        else break;
    }
    x = s_x;
    y = s_y;
    // down
    while (1){
        x++;
        if(x < h) {
            if(can_go(x, y, s)) ans++;
            else break;
        }
        else break;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#ifdef TEST
#define getchar_unlocked _getchar_nolock
#endif
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int A, B, C;
ld dp[105][105][105], top, bot;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> A >> B >> C;
	dp[A][B][C] = 1;
	for (int i = A; i <= 100; i++)
		for (int j = B; j <= 100; j++)
			for (int k = C; k <= 100; k++) {
				if (i == A && j == B && k == C) continue;
				vector<int> tmp;
				if (i == 100) tmp.pb(1);
				if (j == 100) tmp.pb(2);
				if (k == 100) tmp.pb(3);
				if (tmp.size() > 1) continue;
				else if (tmp.size() == 0) {
					if (i > 0) dp[i][j][k] += dp[i - 1][j][k] * (i - 1) / (i - 1 + j + k);
					if (j > 0) dp[i][j][k] += dp[i][j - 1][k] * (j - 1) / (i - 1 + j + k);
					if (k > 0) dp[i][j][k] += dp[i][j][k - 1] * (k - 1) / (i - 1 + j + k);
				} else {
					if (tmp[0] == 1 && i > 0) dp[i][j][k] += dp[i - 1][j][k] * (i - 1) / (i - 1 + j + k);
					else if (tmp[0] == 2 && j > 0) dp[i][j][k] += dp[i][j - 1][k] * (j - 1) / (i - 1 + j + k);
					else if (tmp[0] == 3 && k > 0) dp[i][j][k] += dp[i][j][k - 1] * (k - 1) / (i - 1 + j + k);
				}
				//cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << '\n';
				if (tmp.size() == 1) top += (i - A + j - B + k - C) * dp[i][j][k], bot += dp[i][j][k];
			}
	cout << fixed << setprecision(10) << top / bot << '\n';
}

#include<bits/stdc++.h>
using namespace std;
const int N=201000;
const long long mod=1e9+7;
int n,K,Cnt;
int Num[N];
long long Ans;
string st;
bool vis[N];
long long Mul[N];
long long G[N][21][21];
long long F[N][21];
long long Pow(long long x,long long y){
	long long sum=1;
	for(;y;y>>=1,x=x*x%mod)if(y&1)sum=sum*x%mod;
	return sum;
}
int tran(char ch){
	if(ch>='0'&&ch<='9')return ch-'0';
	else return ch-'A'+10;
}

long long Fac[N],IFac[N];
long long C(int x,int y){
	if(x<0||y<0||x<y)return 0;
	return Fac[x]*IFac[x-y]%mod*IFac[y]%mod;
}
void Init(void){
	Mul[0]=1;for(int i=1;i<=n;i++)Mul[i]=Mul[i-1]*K%mod;
	Fac[0]=1;for(int i=1;i<=20;i++)Fac[i]=Fac[i-1]*i%mod;
	IFac[20]=Pow(Fac[20],mod-2);for(int i=19;i>=0;i--)IFac[i]=IFac[i+1]*(i+1)%mod;
	for(int i=1;i<=20;i++)G[0][i][0]=1;
	for(int now=1;now<=20;now++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=now;j++)G[i][now][j]=(G[i-1][now][j]*j%mod+G[i-1][now][j-1]*(now-j+1)%mod);
	F[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=K;j++)F[i][j]=G[i][j][j];
	return;
}
void update(int Pos)
{
	long long t=0;
	if(Pos==0){if(Cnt==K)++Ans;return;}
	for(int i=0;i<Num[Pos];i++){
		if(Pos==n&&i==0)continue;
		if(vis[i]){
			for(int j=K-Cnt;j<=K;j++)Ans=(Ans+C(16-Cnt,K-Cnt)*C(Cnt,j-(K-Cnt))%mod*F[Pos-1][j])%mod;
		}
		else {
			for(int j=K-Cnt-1;j<=K;j++)Ans=(Ans+C(16-Cnt-1,K-Cnt-1)*C(Cnt+1,j-(K-Cnt)+1)%mod*F[Pos-1][j])%mod;
		}
	}return;
}
int main()
{
	cin>>st>>K;n=st.size();
	for(int i=n-1;i>=0;i--)Num[n-i]=tran(st[i]);
	Init();
	for(int i=1;i<=n-1;i++){
		Ans=(Ans+C(15,K-1)*(F[i-1][K-1]+F[i-1][K])%mod*15%mod)%mod;
	}
	update(n);
	for(int i=n;i>=1;i--){
		if(!vis[Num[i]])vis[Num[i]]=1,++Cnt;
		if(Cnt>K)break;
		update(i-1);
	}
	cout<<Ans;
	return 0;
}


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

long long dist(long long  r1,long long  c1,long long  r2,long long  c2){
  return abs(r1-r2)+abs(c1-c2);
}

int main(){
  long long r1,c1,r2,c2,x1,y1,x2,y2;
  string s;
  cin >> r1 >> c1 >> r2 >> c2;
  int ct = 0;

  while(dist(r1,c1,r2,c2)>0){
    ct++;
    if (r1+c1 == r2+c2 || r1-c1 == r2-c2 || dist(r1,c1,r2,c2)<=3){
      r1 = r2;
      c1 = c2;
    }
    else {
      x1 = (c1 - r1 + c2 + r2)/2;
      y1 = x1 - c1 + r1;
      x2 = (c1 + r1 + c2 - r2)/2;
      y2 = -x2 + c1 + r1;
      if (dist(x1,y1,c2,r2)<dist(x2,y2,c2,r2)){
        c1 = x1;
        r1 = y1;
      }
      else {
        c1 = x2;
        r1 = y2;
      }
    }
  }

  cout << ct << endl;

  return 0;
}

/*
“The only way that we can live is if we grow.
 The only way we can grow is if we change.
The only way we can change is if we learn.
 The only way we can learn is if we are exposed.
 And the only way that we are exposed is if we throw ourselves into the open.”
 ***************************************   ************************   **********************************
*/
#include <bits/stdc++.h>
using namespace std;

//---------------------mishra ka idea------------------
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define sz(x)	    (int)(x).size()
#define ull       unsigned long long
//------------------------mishra ka idea-------------------

//-------------------------alsi hu mai-----------------------
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define hell        998244353
#define output(x) cout << (x ? "YES" : "NO")<<endl;
#define Output(x) cout << (x ? "Yes" : "No")<<endl;
//-------------------------alsi hu mai-----------------------

//--------------------het se uthaya---------------------
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)

template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}

//--------------------het se uthaya-------------------------------------------------------------------

int gcd(int a, int b) {if(a>b)swap(a,b) ;  if (a == 0)  return b; return gcd(b % a, a); }
int rint(int  l , int r){return rand()%(r-l+1) + l ;}

//---------------------------aab code dekho bahut template dekh liya---------------------------------

signed main()
{
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int i,j,x,a,b,c,d,r1,c1,r2,c2,d1,d2;
   cin>>r1>>c1>>r2>>c2;
   if(r1==r2 && c1==c2){
   	cout<<0<<endl;
   	return 0;
   }
   d1=abs(r1-r2);
   d2=abs(c1-c2);
   if(d1+d2<=3){
   	cout<<1<<endl;
   	return 0;
   }
   int ans=0;
   if(abs(d1-d2)==0){
   	cout<<1<<endl;
   	return 0;
   }
   if(abs(d1-d2)<=3){
   	cout<<2<<endl;
   	return 0;
   }
   if(d1%2 != d2%2)ans++;
   cout<<ans+2<<endl;

    return 0;
}


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

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

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}
int num[524310];
int kazu[524310];
const int ma = (1 << 19) - 1;
int query(ll n) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return kazu[n2]++;
		n2 = n2 * 2 % 524309;
	}
	num[n2] = n + 1;
	kazu[n2] = 1;
	return 0;
}

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

	int N = getint();

	ll are = N * ll(N - 1) / 2;

	rep(i, N) are -= query(getint());
	printf("%lld\n", are);

	Would you please return 0;
}

#include <bits/stdc++.h>
#define spd ios::sync_with_stdio(false),cin.tie(0)
#define mod 1000000007;
#define pie acos(-1)
#define eps 1e-9
#define fr(i,a,b) for(i = a; i < b; i++)
#define Fr(i,a,b) for(i = a; i >= b; i--)
#define rst(a,b) memset(a,b,sizeof(a))
#define in1(a) cin >> a
#define in2(a,b) cin >> a >> b
#define in3(a,b,c) cin >> a >> b >> c
#define in4(a,b,c,d) cin >> a >> b >> c >> d
#define sinp(a) getline(cin, a)
#define tout(a,b) cout << "Case " << ++b << ": " << a << endl
#define dprint(x,y,z)  cout << setprecision(x) << fixed << y << " " << z << endl
#define srt(a,n) sort(a, a + n)
#define rev(a,n) sort(a, a + n, greater<ll>())
#define pb(a) push_back(a)
#define len(a) a.length()
#define bs(a,b) binary_search(a.begin(), a.end(), b)
#define lob(a,b) lower_bound(a.begin(), a.end(), b)
#define upb(a,b) upper_bound(a.begin(), a.end(), b)

using namespace std;
using ull = unsigned long long;
using ll = long long;
using db = double;
using ss = string;

unordered_map<ll,ll> freq;

int main() {
    spd; //ll t,tst = 0; in1(t);
    //while(t--) {
        ll n,i, sum = 0; in1(n);
        vector<ll> vec(n);
        fr(i,0,n) {
            in1(vec[i]);
            if(freq[vec[i]]) sum += n - i - 1 - freq[vec[i]];
            else sum += n - i - 1;
            freq[vec[i]]++;
        }
        cout << sum << endl;
    //}
}


#include <bits/stdc++.h>
using namespace std;
int n;
bool validDec(int value){
    bool ret = true;
    while(value>0){
        if(value%10==7){
            ret = false;
            break;
        }
        value /= 10;
    }
    return ret;
}
bool validOct(int value){
    bool ret = true;
    while(value>0){
        if(value%8==7){
            ret = false;
            break;
        }
        value /= 8;
    }
    return ret;
}
int main(){
    cin >> n;
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        if(validDec(i)&&validOct(i))ans++;
    }
    cout << ans << endl;
    return 0;
}

#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"

using namespace std;
using namespace __gnu_pbds;

#define pb              push_back
#define vi              vector<int>
#define ll              long long int
#define us              unsigned long long int
#define dig(n)          floor(log10(n)) + 1
#define all(x)          (x).begin(),(x).end()
#define zrobits(x)      __builtin_ctzll(x)
#define setbits(x)      __builtin_popcountll(x)
#define f(i, a, b)      for (int i = a; i < b; i++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define uniq(v)         (v).erase(unique(all(v)),(v).end())
#define CP()            ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int32_t MOD = 1e9 + 7;
const int32_t mod = 998244353;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update>indexed_set;

bool fx(int n){
	string s;
	string $s=to_string(n);
	while(n){
		s=to_string(n%8)+s;
		n/=8;
	}
	s+=$s;
	for(auto x:s){
		if((x-'0')==7)
			return false;
	}
	return true;
}

auto main() -> int {
  CP()
  ll t;
  t=1;
  // cin>>t;
  while (t--) {
  	int n;
  	cin>>n;
  	int ans(0);
  	for(int i=1;i<=n;i++){
  		(fx(i))?ans++:n=n;
  	}
  	cout<<ans<<endl;
  }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1000000007;

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

    int leftmax = 0, rightmax = 0;
    for (int i = 0; i < (1 << n)/2; i++){
        leftmax = max(leftmax, a[i]);
    }
    for (int i = (1 << n)/2; i < (1 << n); i++){
        rightmax = max(rightmax, a[i]);
    }

    int ans = min(leftmax, rightmax);
    for (int i = 0; i < (1 << n); i++){
        if (a[i] == ans){
            cout << i+1 << "\n";
            break;
        }
    }
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (b), _a = (a); i >= _a; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = (n) - 1; i >= 0; i--)
#define debug(x) cout<<"debug : "<<x<<endl
#define debug2(x,y) cout<<"debug : "<<x<<" | "<<y<<endl
#define debug3(x,y,z) cout<<"debug : "<<x<<" | "<<y<<" | "<<z<<endl
#define debug4(x,y,z,w) cout<<"debug : "<<x<<" | "<<y<<" | "<<z<<" | "<<w<<endl
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define sz(x) ((long long)x.size())
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define mp make_pair
#define ff first
#define ss second
#define M 1000000007          // 1e9+7
#define INF 1e9    // 1e9

typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<int> vint;
typedef vector<string> vs;
typedef vector<vi> vvi;

bool cus(pair<int,int> a, pair<int,int> b){
    if(a.ff<b.ff)
        return true;
    if(a.ff>b.ff)
        return false;
    return a.ss<b.ss;
}

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

void solve(){
    ll n;
    cin >> n;
    ll val = pow(2, n);
    vii a;

    ll x;
    rep(i, val){
        cin >> x;
        a.pb({x, i});
    }

    while(a.size() > 2){
        vii tmp;
        for(ll i = 0; i < a.size(); i+=2) tmp.pb(max(a[i], a[i+1]));
        a.clear();
        rep(i, tmp.size()) a.pb(tmp[i]);
    }

    ii ans = min(a[0], a[1]);
    cout << ans.ss+1 << endl;
}

int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<setprecision(11);

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

    return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<set>
#include<cstdlib>
#include<cmath>
#include<numeric>//fill
#include<iomanip>
#include<functional>//https://cpprefjp.github.io/reference/functional/function.html
#include<cstdlib>//https://cpprefjp.github.io/reference/cstdlib.html
#include<queue>
#include<deque>
#include<cassert>
#include<stack>
#include <iterator>     // std::back_inserter
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
const double PI = acos(-1);
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n)for(ll i=0;i<(n);i++)
#define repp(x,arr) for(auto& x:arr)
#define repp2(x,y,arr) for(auto& [x,y]:arr)
#define all(a) (a.begin()),(a.end())
const ll MOD = 1e9 + 7;
const ll inf = (ll)1e18+6;

// デフォルトは整数部も含めた桁数指定
//cout <<setprecision();
ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}
double dl[4] = { 0,0,0.1,0.1 };
double dr[4] = { 0,-0.1,0,-0.1 };
int main() {
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<pair<double, double>>s(N), t(N);
	map<pair<double, double>,bool>m;
	rep(i, N) {
		cin >> t[i].first >> t[i].second;

	}
	rep(i, N) {
		cin >>s[i].first >> s[i].second;
		m[s[i]] = true;
	}

	if (N == 1) {
		cout << "Yes";
		return 0;
	}
	double a, b,a2,b2;
	a = s[0].first, b = s[0].second;
	a2 = s[1].first, b2 = s[1].second;
	double p1;
	p1 = atan((b2 - b) / (a2 - a));
	bool ans = false;
	//cout << "指標は" << a << " " << b << endl;
	rep(i, N) {
		double q, r,c, d;
		c = t[i].first, d = t[i].second;
		for (int j = 0; j < N; j++) {
			if(j==i)continue;
			double c2, d2,p,p2;
			c2 = t[j].first;
			d2 = t[j].second;
			c2 -= c;
			d2 -= d;
			p = p1-atan(d2 / c2);
			p2 = p + PI;
			{
				double A1, B1, x, y, x2, y2;
				A1 = t[j].first - c;
				B1 = t[j].second - d;
				x = A1 * cos(p) - B1 * sin(p);
				y = A1 * sin(p) + B1 * cos(p);
				x2 = A1 * cos(p2) - B1 * sin(p2);
				y2 = A1 * sin(p2) + B1 * cos(p2);
				x += a;
				y += b;
				x = round(x);
				y = round(y);
				x2 += a;
				y2 += b;
				x2 = round(x2);
				y2 = round(y2);
				if (x==a2&&y==b2) {
					p = p;

				}
				else if (x2 == a2 && y2 == b2) {
					p = p2;
				}
				else {
					continue;
				}

			}
			rep(k, N) {
				double A1, B1,x,y,x2,y2;
				A1 = t[k].first - c;
				B1 = t[k].second - d;
				x = A1 * cos(p) - B1 * sin(p);
				y = A1 * sin(p) + B1 * cos(p);
				//x2 = A1 * cos(p2) - B1 * sin(p2);
				y2 = A1 * sin(p2) + B1 * cos(p2);
				//cout << x << " " << y << endl;
				//cout << x2 << " " << y2 << endl;
				x += a;
				y+= b;
				x = round(x);
				y = round(y);
				if (m[{x,y}] == false) {
				//cout << "break"<<endl;
					break;
				}
				if (k == N - 1)ans = true;

			}
		}

	}
	if (ans)cout << "Yes";
	else cout << "No";
}

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

int main()
{

    long long int n,f=0;
    cin>>n;
    string s,ans;
    map<string,long long int>m;
    vector<string>v;
    for(int i=0; i<n; i++)
    {
        cin>>s;
        if(s[0]=='!')
        {m[s]=1;}
        else v.push_back(s);

    }
    for(int i=0;i<v.size();i++){
        ans=v[i];
        ans='!'+v[i];
        if(m[ans]==1){
            cout<<v[i]<<endl;
            f=1; break;
        }

    }

        if(f==0)cout<<"satisfiable"<<endl;

}


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

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

#define MOD 1000000007LL

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

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

int main(void) {
    ll N;
    string S;
    cin >> N >> S;
    ll ans = 0;
    rep(i, N) {
        map<char, ll> m;
        rep2(j, i, N) {
            m[S[j]]++;
            if(m['A'] == m['T'] && m['C'] == m['G']) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N;
ll A[401000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    ll ans = 0;
    for(int i = 0; i < 2 * N; i++) {
        cin >> A[i];
        ans += A[i];
    }
    priority_queue<ll, vector<ll>, greater<ll>> que;
    for(int i = 0; i < N; i++) {
        que.push(A[N+i]);
        que.push(A[N-1-i]);
        ans -= que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <queue>
using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	vector<int> a(n*2);
	for(int& i: a)
		scanf("%d", &i);
	priority_queue<int> q;
	long long ans=0;
	for(int i = 0;i < n;i ++){
		q.push(a[i]);
		q.push(a[n*2-1-i]);
		ans+=q.top();
		q.pop();
	}
	printf("%lld\n", ans);
}

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

typedef long long ll;

const int mod = 1000000007;
const int Maxn = 100005;

int n;
int a[Maxn];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a, a + n + 1);
	int res = 1;
	for (int i = 1; i <= n; i++)
		res = ll(res) * (a[i] - a[i - 1] + 1) % mod;
	printf("%d\n", res);
    return 0;
}


#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
  FAST/**/

  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<(a*d - b*c);

  return 0;
}

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

int main()
{
  vector<int> A1(2),A2(2);

  for(int i =0; i <2; i++)
  {
    cin >> A1[i];
  }
    for(int i =0; i <2; i++)
  {
    cin >> A2[i];
  }

  int ans = A1[0]*A2[1]-A1[1]*A2[0];

  cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
const int N=205;
const int DS=900;
int n,tot,ran[10];
int x[N],y[N],r[N],a[N],b[N],c[N],d[N],s[N],que[N];
unsigned int Se;
set<pair<int,int> > S;
set<pair<int,int> > :: iterator it;
pair<int,int> aa[N];
bool U(int i){
	a[i]--; bool flag=0;
	for (int j=1; j<=n; j++){
		if (i==j) continue;
		if (max(a[i],a[j])<min(c[i],c[j]) && max(b[i],b[j])<min(d[i],d[j])){ flag=1; break; }
	}
	if (!flag){
		S.erase(make_pair(r[i]-s[i],i));
		s[i]+=d[i]-b[i];
		if (s[i]>=r[i]+DS) que[i]=-1,tot--;
		else S.insert(make_pair(r[i]-s[i],i));
		return 1;
	}
	a[i]++;
	return 0;
}
bool D(int i){
	c[i]++; bool flag=0;
	for (int j=1; j<=n; j++){
		if (i==j) continue;
		if (max(a[i],a[j])<min(c[i],c[j]) && max(b[i],b[j])<min(d[i],d[j])){ flag=1; break; }
	}
	if (!flag){
		S.erase(make_pair(r[i]-s[i],i));
		s[i]+=d[i]-b[i];
		if (s[i]>=r[i]+DS) que[i]=-1,tot--;
		else S.insert(make_pair(r[i]-s[i],i));
		return 1;
	}
	c[i]--;
	return 0;
}
bool L(int i){
	b[i]--; bool flag=0;
	for (int j=1; j<=n; j++){
		if (i==j) continue;
		if (max(a[i],a[j])<min(c[i],c[j]) && max(b[i],b[j])<min(d[i],d[j])){ flag=1; break; }
	}
	if (!flag){
		S.erase(make_pair(r[i]-s[i],i));
		s[i]+=c[i]-a[i];
		if (s[i]>=r[i]+DS) que[i]=-1,tot--;
		else S.insert(make_pair(r[i]-s[i],i));
		return 1;
	}
	b[i]++;
	return 0;
}
bool R(int i){
	d[i]++; bool flag=0;
	for (int j=1; j<=n; j++){
		if (i==j) continue;
		if (max(a[i],a[j])<min(c[i],c[j]) && max(b[i],b[j])<min(d[i],d[j])){ flag=1; break; }
	}
	if (!flag){
		S.erase(make_pair(r[i]-s[i],i));
		s[i]+=c[i]-a[i];
		if (s[i]>=r[i]+DS) que[i]=-1,tot--;
		else S.insert(make_pair(r[i]-s[i],i));
		return 1;
	}
	d[i]--;
	return 0;
}
int main(){
//	freopen("a.out","w",stdout);
	scanf("%d",&n); tot=n;
	srand(303837088);
	for (int i=1; i<=n; i++){
		scanf("%d%d%d",&x[i],&y[i],&r[i]);
		a[i]=x[i],b[i]=y[i],c[i]=x[i]+1,d[i]=y[i]+1; s[i]=1;
		S.insert(make_pair(r[i]-s[i],i));
		aa[i]=make_pair(r[i]-s[i],i);
	}
	sort(aa+1,aa+1+n);
	ran[1]=1,ran[2]=2,ran[3]=3,ran[4]=4;
	for (int i=1; i<=50; i++)
		for (int J=n; J<=n-20; J++){
			int x=aa[J].second;
			if (que[x]==-1) continue;
			random_shuffle(ran+1,ran+5);
			for (int j=1; j<=4; j++){
				if (ran[j]==1 && a[x]>0 && U(x)) break;
				if (ran[j]==2 && c[x]<10000 && D(x)) break;
				if (ran[j]==3 && b[x]>0 && L(x)) break;
				if (ran[j]==4 && d[x]<10000 && R(x)) break;
			}
		}
	for (int i=1; i<=300000; i++){
		if (!tot) break; int x;
		if (rand()%4==1 && !S.empty()){
			it=S.end(); it--;
			x=(*it).second;
		} else {
			x=rand()%n+1;
			while (que[x]==-1) x=rand()%n+1;
		}
		random_shuffle(ran+1,ran+5);
		for (int j=1; j<=4; j++){
			if (ran[j]==1 && a[x]>0 && U(x)) break;
			if (ran[j]==2 && c[x]<10000 && D(x)) break;
			if (ran[j]==3 && b[x]>0 && L(x)) break;
			if (ran[j]==4 && d[x]<10000 && R(x)) break;
		}
	}
	for (int i=1; i<=n; i++) printf("%d %d %d %d\n",a[i],b[i],c[i],d[i]);
	return 0;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,mmx,avx")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<pii> vpii;typedef vector<pll> vpll;
template<typename T> void makeunique(vector<T> &vx) {sort(vx.begin(),vx.end());auto it=unique(vx.begin(),vx.end());vx.resize(std::distance(vx.begin(),it));}

void solve(long long n, std::vector<long long> A, std::vector<long long> B){
	ll sumA=0;
	for (auto &w:A) sumA+=w;
	vll C[2];
	for (int i=0;i<n;i++) {
		C[i%2].PB(B[i]-A[i]);
	}
	for (int k=0;k<2;k++) sort(C[k].begin(),C[k].end(),greater<ll>());
	ll ans=0;
	for (int i=0;i<C[0].size();i++) {
		ll now=C[0][i]+C[1][i];
		if (now>0) ans+=now;
	}
	ll final=ans+sumA;
	printf("%lld\n",final);
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define max(p, q) ((p) > (q) ? (p) : (q))
#define min(p, q) ((p) < (q) ? (p) : (q))
#define ALL(a) (a).begin(), (a).end()
#define INF ((1LL << 62) - (1LL << 31))
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;

string func(string n) {
    int length = n.length();
    bool flag = (3 <= length) ? true : false;
    if (flag) {
        string t = n.substr(length - 3, 3);
        int a = stoi("1" + t);
        flag = (a % 200 == 0) ? true : false;
    }
    string ans = "";
    if (flag) {
        int plus = 0;
        rep(i, 0, length - 2) {
            int tmp = n[i] - '0';
            int pre = (plus + tmp) / 2;
            plus = (tmp % 2 == 0) ? 0 : 10;
            if (i == 0 && pre == 0) {
                continue;
            }
            ans += to_string(pre);
        }
        return ans;
    } else {
        ans = n + "200";
        return ans;
    }
}

int main(void) {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    string n;
    ll k;
    cin >> n >> k;
    rep(i, 0, k) { n = func(n); }
    cout << n << endl;
    return 0;
}

#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i,t, n,j, a[200600], ans;
double temp;
bool cond;
char c;
string s;
int main()
{
    //I am Monim, a tiny creature of Allah
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(i=0;i<n;i++)
        cin >> a[i];
    ans = 0;
    for(i=0;i<n;i++)
        ans+= abs(a[i]);
    cout << ans << endl;
    ans = 0;
    for(i=0;i<n;i++)
        ans+= abs(a[i]*a[i]);
    temp = (double)sqrt(ans);
    cout <<fixed<<setprecision(12)<< temp << endl;
    ans = -10000000000;
    for(i=0;i<n;i++)
        ans = max(ans,abs(a[i]));
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define fir first
#define sec second
#define PB push_back
#define MP make_pair

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i < (int)(n); ++i)

template <class T> void chkmax(T& x, T y) { x = (x > y ? x : y); }
template <class T> void chkmin(T& x, T y) { x = (x < y ? x : y); }

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

const int N = 2e5 + 5;

int n, m, K;
int a[N], last[N];

vi e[N];

struct fenwick {
    int d[N];

    void init(int sz){
        memset(d, 0, sizeof(d));
        rep1(i, sz + 1){
            a[i] = 1;
            modify(i, 1);
        }
    }

    void modify(int x, int val){
        while (x <= m){
            d[x] += val;
            x += (x & -x);
        }
    }

    int query(int x){
        int ret = 0;
        while (x){
            ret += d[x];
            x -= (x & -x);
        }
        return ret;
    }
} fenwick;

int main(){
    scanf("%d%d%d", &n, &m, &K);
    rep1(i, n + 1) last[i] = m;
    fenwick.init(m);
    rep(i, K){
        int x, y; scanf("%d%d", &x, &y);
        e[x].PB(y);
        chkmin(last[x], y - 1);
    }

    LL ret = 0;
    rep1(i, n + 1){
        for (auto j : e[i]) if (a[j]){
           a[j] = 0;
           fenwick.modify(j, -1);
        }
        if (a[1]){
            ret += last[i];
            ret += max(0, fenwick.query(last[1]) - fenwick.query(last[i]));
        } else {
            ret += fenwick.query(last[1]);
        }
    }

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

    return 0;
}

#include<bits/stdc++.h>
#define fi first
#define se second
#define pb(i) push_back(i)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=b;i>=a;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define VI vector<int>
#define VLL vector<ll>
#define MPII map<pair<int,int>,int>
#define mp make_pair
#define PQI priority_queue<int>
#define lowbit(x) x&-x
#define debug(a) cout<<#a<<'='<<a<<'\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10;
const int INF = 0x3f3f3f3f;
const int inf = - INF;
const int mod = 1e9+7;
const double pi = acos(-1.0);
const double eps=1e-5;
const int M = 2e5 + 10;
struct point{
    int x,y;
    bool operator < (point p) const{
        return x == p.x ? y < p.y : x < p.x;
    }
}p[N];
int vis[M],c[M];
int getsum(int x){
    int res = 0;
    while (x){
        res += c[x];
        x -= lowbit(x);
    }
    return res;
}
void update(int x, int y, int n){
    while (x <= n){
        c[x] += y;
        x += lowbit(x);
    }
}
int main()
{
    int h, w, m;
    scanf("%d%d%d",&h, &w, &m);
    int mx = INF, my = INF;
    for (int x, y, i = 1; i<= m; i++){
        scanf("%d%d", &x, &y);
        p[i] = (point){x,y};
        if (y == 1)
            mx = min (mx ,x);
        if (x == 1)
            my = min (my ,y);
    }
    for (int i = mx + 1; i <= h; i++){
        p[++m].x = i;
        p[m].y = 1;
    }
    for (int i = my + 1; i <= w; i++){
        p[++m].x = 1;
        p[m].y = i;
    }
    sort(p + 1, p + 1  + m);
    ll cnt = 0, pos = 1;
    for (int i = 1; i <= m; i++){
        if (!vis[p[i].y]){
            vis[p[i].y] = 1;
            update(p[i].y, 1, w);
        }
        if (i == m || p[i].x != p[i + 1].x){
            cnt += getsum(w) - getsum(p[pos].y - 1);
            pos = i + 1;
        }
    }
    printf("%lld\n", 1ll * h * w - cnt);
    return 0;
}


//μ's forever
#include <bits/stdc++.h>
#define mod 998244353
#define getchar nc
using namespace std;
inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read()
{
    register int x=0,f=1;register char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return x*f;
}
inline void write(register int x)
{
    if(!x)putchar('0');if(x<0)x=-x,putchar('-');
    static int sta[20];register int tot=0;
    while(x)sta[tot++]=x%10,x/=10;
    while(tot)putchar(sta[--tot]+48);
}
int n,k,f[3005][3005];
int main()
{
    n=read(),k=read();
    for(register int i=0;i<=k;++i)
        f[n-k][i]=1;
    for(register int i=n-k-1;i>=0;--i)
        for(register int j=n;j>=0;--j){
            // cerr<<i<<" "<<j<<endl;
            if(j%2==0&&i+(j>>1)<=n)
                f[i][j]=f[i+(j>>1)][j>>1];
            // cerr<<i<<" "<<j<<endl;
            f[i][j]=(0ll+f[i][j]+f[i][j+1])%mod;
        }
    write(f[0][0]);
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define mod 998244353
#define N 55
using namespace std;
int n,a[N][N],lim,f[2][N],sze[N],sm[N];
inline int find(int x,int way)
{
	return f[way][x]==x?x:f[way][x]=find(f[way][x],way);
}
int main()
{
#ifdef lovelyG
Sfile(1);
#endif
	scanf("%d%d",&n,&lim);
	for(int i=1;i<=n;++i)f[0][i]=f[1][i]=i;//0 r 1 c
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=i+1;j<=n;++j)
		{
			bool pt=1;
			for(int k=1;k<=n;++k)
			{
				if(a[i][k]+a[j][k]>lim)
				{
					pt=0;
					break;
				}
			}
			if(pt)
			{
				f[0][find(i,0)]=f[0][find(j,0)];
			}
		}
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=i+1;j<=n;++j)
		{
			bool pt=1;
			for(int k=1;k<=n;++k)
			{
				if(a[k][i]+a[k][j]>lim)
				{
					pt=0;
					break;
				}
			}
			if(pt)
			{
				f[1][find(i,1)]=f[1][find(j,1)];
			}
		}
	}
	int ans=1;sm[0]=1;
	for(int i=1;i<=n;++i)
	sm[i]=1ll*sm[i-1]*i%mod;
	for(int ii=0;ii<=1;++ii)
	{
		memset(sze,0,sizeof sze);
		for(int i=1;i<=n;++i)
		{
			++sze[find(i,ii)];
		}
		for(int i=1;i<=n;++i)
		ans=1ll*ans*sm[sze[i]]%mod;
	}
	printf("%d",ans);
	return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
V<ll> p={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};
int main(){
  ll a,b;
  cin>>a>>b;
  V<ll> dp((1<<20),0);
  dp[0]=1;
  V<ll> tmp={};
  for(ll i=a;i<=b;i++){
        ll v=0;
        for(int j=0;j<20;j++){
            if(i%p[j]==0)v+=(1ll<<j);
        }
        tmp.emplace_back(v);
  }
  int m=tmp.size();
  for(int i=0;i<m;i++){
      for(ll j=0;j<(1<<20);j++){
          if((j&tmp[i])>0)continue;
          dp[j|tmp[i]]+=dp[j];
      }
  }
  ll ans=0;
  for(int i=0;i<(1<<20);i++)ans+=dp[i];
  cout<<ans<<"\n";
}

#include<bits/stdc++.h>
#define f(i,n) for(long long int i = 0 ; i < n;  i++)
#define F first
#define S second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define all(s) s.begin(), s.end()
#define u_s unordered_set
#define u_m unordered_map
#define ll long long int
#define pb push_back
#define pll pair<ll,ll>
#define parr(arr) for(auto x: arr)cout<<x<<" ";cout<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define testcase ll tt; cin>>tt; while(tt--)
using namespace std;

ll solve(){
    ll n; cin>>n;
    vector<array<ll,3>> v;
    f(i,n){
        ll op; cin>>op;
        ll l, r; cin>>l>>r;
        v.pb({op, l, r});
    }
    ll ans = 0;
    map<int,string> m;
    m[1] = "[]";
    m[2] = "[)";
    m[3] = "(]";
    m[4] = "()";
    f(i,n){
        ll opi = v[i][0];
        string opis = m[opi];
        ll si = v[i][1];
        ll ei = v[i][2];
        for(ll j = i+1; j < n; j++){
            ll opj = v[j][0];
            string opjs = m[opj];
            ll sj = v[j][1];
            ll ej = v[j][2];
            bool flag1, flag2;
            if(opjs[0] == '(' || opis[1] == ')'){
                flag1 = (sj >= ei);
            }else{
                flag1 = (sj > ei);
            }
            if(opjs[1] == ')' || opis[0] == '('){
                flag2 = (ej <= si);
            }else{
                flag2 = (ej < si);
            }
            if(!(flag1 || flag2)) ans++;
        }
    }
    return ans;
}

int main() {
    fast;
    cout<<solve();
	return 0;
}


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

const int N=101;

int n,g[N][N],C[N][N],vis[N],to[N];

char s[N][N];

void dfs(int x)
{
    if(vis[x])
        return;
    vis[x]=1;
    for(int i=1;i<=n;i++)
        if(g[x][i])
            dfs(i);
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            g[i][j]=s[i][j]-'0';
    for(int i=1;i<=n;i++)
    {
        fill(vis+1,vis+n+1,0);
        dfs(i);
        for(int j=1;j<=n;j++)
            to[j]+=vis[j];
    }
    double ans=0;
    for(int i=1;i<=n;i++)
        ans+=1.0/to[i];
    printf("%.10lf\n",ans);
}

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

using ll = long long;
using vi = vector<int>;

const int MAX = 2e5+10;
int a[MAX];
int b[MAX];
int c[MAX];
vi e[MAX];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
			cin >> a[i];
			b[a[i]] = 1;
	}
	for(int i=0;i<n/2;i++){
			if( a[i] != a[n-i-1] ){
					e[a[i]].push_back(a[n-i-1]);
					e[a[n-i-1]].push_back(a[i]);
			}
	}
	int cnt = 0;
	int v = 0;
	for(int i=1;i<MAX;i++){
			if( b[i] == 0 ) continue;
			v++;
			if( c[i] ) continue;
			cnt ++;
			c[i] = cnt;
			deque <int> D;
			D.push_back(i);
			c[i] = cnt;
			while( !D.empty() ){
					int x = D.front();
					D.pop_front();
					for(int y: e[x]){
							if( c[y] ) continue;
							D.push_back(y);
							c[y] = c[x];
					}
			}
	}
	cout << v - cnt << endl;
}


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int ri(){
    int n;
    scanf("%d",&n);
    return n;
}

int main(){
    int N;
    cin >> N;
    map<string, int> mp;
    string S[N];
    for (int i = 0;i<N;++i){
        cin >> S[i];
        ++mp[S[i]];
    }
    for (int i = 0; i < N; ++i)
    {
        if(S[i][0]=='!'){
            S[i].erase(0, 1);
            if(mp[S[i]]>=1){
                cout << S[i];
                return 0;
            }
        }
    }
    cout << "satisfiable" << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
template<class T> void chmax(T& a, T b){
    if(a < b){
        a = b;
    }
}
template<class T> void chmin(T& a, T b){
    if(a > b){
        a = b;
    }
}
int main()
{
    int n;
    cin >> n;
    vector<string>s;
    vector<string>ns;
    rep(i,n){
        string k;
        cin >> k;
        if(k[0] == '!'){
            ns.push_back(k);
        }
        else{
            s.push_back(k);
        }
    }
    sort(s.begin(),s.end());
    sort(ns.begin(),ns.end());

    if(s.size() == 0 || ns.size() == 0){
        cout << "satisfiable" << endl;
        return 0;
    }
    rep(i,(int)s.size()){
        int r = ns.size() -1;
        int l = 0;
        while(r - l >0){
            int m = l + (r-l)/2;
            string t = '!' + s[i];
            if(t == ns[m]){
                cout << s[i] << endl;
                return 0;
            }
            else if(t < ns[m]){
                r = m -1;
            }
            else if(t > ns[m]){
                l = m + 1;
            }

        }
        if('!' + s[i] == ns[l]){
            cout << s[i] << endl;
            return 0;
        }

    }

    cout << "satisfiable" << endl;
    return 0;
}


/*
    author:  Maksim1744
    created: 14.11.2020 15:06:23
*/

#include <bits/stdc++.h>

using namespace std;

#define ll   long long
#define ld   long double

#define mp   make_pair
#define pb   push_back
#define eb   emplace_back

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

template<typename T>             vector<T>& operator--            (vector<T>& v){for (auto& i : v) --i;            return  v;}
template<typename T>             vector<T>& operator++            (vector<T>& v){for (auto& i : v) ++i;            return  v;}
template<typename T>             istream& operator>>(istream& is,  vector<T>& v){for (auto& i : v) is >> i;        return is;}
template<typename T>             ostream& operator<<(ostream& os,  vector<T>& v){for (auto& i : v) os << i << ' '; return os;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>& p){os << p.first << ' ' << p.second; return os;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}

#ifdef HOME
#define TAG_LENGTH       25
#define LR_LEFT          left
#define LR_RIGHT         right
#define LR_VALUE         value
#define LR_SECOND_VALUE  mn
#include "C:/C++ libs/print.cpp"
#else
#define showl            42;
#define shows            42;
#define show(...)        42;
#define showm(...)       42;
#define showt(...)       42;
#define printTree(...)   42;
#define printGraph(...)  42;
#define printLRTree(...) 42;
#define printMatrix(...) 42;
#define printWGraph(...) 42;
#define debug     if (false)
#endif

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

    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < n; ++j) {
            if (s[j] == '1') {
                g[j].pb(i);
            }
        }
    }

    ld ans = 0;
    for (int i = 0; i < n; ++i) {
        vector<int> u(n, false);
        function<void(int)> dfs = [&](int v) {
            u[v] = true;
            for (auto k : g[v]) {
                if (!u[k]) {
                    dfs(k);
                }
            }
        };
        dfs(i);
        int sz = sum(u);
        ans += 1.0l / sz;
    }
    cout << setprecision(20) << fixed << ans << '\n';

    return 0;
}

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

#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (ll i = (a); i > (b); --i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define SZ(a) ((ll)size(a))
#define print(x) cout << (x) << endl;
#define printn(x, n)                     \
    rep(i, n) { cout << (x[i]) << " "; } \
    cout << endl;

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;

void solve(long long t, long long N)
{
    ll i;
    i = 1;
    ll tmp,tmp2,tmp3;
    ll prev = 1;
    ll num = 0;
    vl v;
    FOR(i, 1, 101)
    {
        tmp = ((100 + t) * i) / 100;
        if (tmp > prev + 1)
        {
            num++;
            v.push_back(tmp-1);
        }
        prev = tmp;
    }

    tmp=(N-1)/num;
    tmp2=(N-1)%num;
    print((100+t)*tmp+v[tmp2]);
}

int main()
{
    long long t;
    scanf("%lld", &t);
    long long N;
    scanf("%lld", &N);
    solve(t, N);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef _DEBUG
#define show(x)          \
	cerr << #x << " : "; \
	showVal(x)
template <typename T>
void showVal(const T &a) { cerr << a << endl; }
template <typename T>
void showVal(const vector<T> &a) {
	for (const T &v : a) cerr << v << " ";
	cerr << endl;
}
template <typename T>
void showVal(const vector<vector<T>> &a) {
	cerr << endl;
	for (const vector<T> &v : a) showVal(v);
}
#else
#define show(x)
#endif
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	multiset<int> s = {0};
	ll sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		int c = *s.rbegin();
		s.insert(a[i]);
		int b = *s.rbegin();
		if (c < b) ans += (b - c) * i;
		sum += a[i];
		ans += sum + b;
		show(sum);
		show(b);
		cout << ans << endl;
	}
	return 0;
}


#line 2 "/home/defineprogram/Desktop/Library/template/template.cpp"
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<ll,ll>
#define len(s) (ll)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr ll inf = 3e18;
#line 2 "main.cpp"

int H,W;
char c[105][105];
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>H>>W;
    rep(i,H)rep(j,W)cin>>c[i][j];
    int ans=0;
    rep(i,H)rep(j,W-1)if(c[i][j]=='.'&&c[i][j+1]=='.')ans++;
    rep(i,H-1)rep(j,W)if(c[i][j]=='.'&&c[i+1][j]=='.')ans++;
    cout<<ans<<"\n";
}

#include <bits/stdc++.h>

using namespace std;

int n,q;
int c[200001];
int uf[200001];
vector <pair<int,pair<int,int>>> query;
map <int,int> cnt[200001];
int check[200001];

int find(int x)
{
	if(uf[x] < 0)
	{
		return x;
	}
	return uf[x] = find(uf[x]);
}

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

    int total = 0;

    memset(check,0,sizeof(check));
    cin >> n >> q;

    for(int i=1;i<=n;i++)
    {
    	cin >> c[i];
    }

    for(int i=0;i<q;i++)
    {
    	int a,b,c;
    	cin >> a >> b >> c;
    	query.push_back(make_pair(a,make_pair(b,c)));
    	if(a==2)
    	{
    		total++;
    		check[c]++;
    	}
    }

    for(int i=1;i<=n;i++)
    {
    	if(check[c[i]]>0)
    	{
    		cnt[i][c[i]] = 1;
    	}
    }
    memset(uf,-1,sizeof(uf));

    for(int i=0;i<q;i++)
    {
    	if(total==0)
    	{
    		break;
    	}
    	if(query[i].first==1)
    	{
    		int u = query[i].second.first;
    		int v = query[i].second.second;
    		int t;
    		if(u > v)
    		{
    			t = u;
    			u = v;
    			v = t;
    		}
    		//u = uf[u];
    		//v = uf[v];
    		u = find(u);
    		v = find(v);
    		if(u!=v)
    		{
    			uf[v] = u;
    			//cout << u << ' ' << v << '\n';
				for(auto it : cnt[v])
				{
					if(check[it.first]==0)
					{
						continue;
					}
					cnt[u][it.first] += it.second;
				}
				cnt[v].clear();
    		}
    	}
    	else
    	{
    		int x = query[i].second.first;
    		int y = query[i].second.second;
    		long long int g = find(x);
    		long long int res = cnt[g][y];
    		cout << res << '\n';
    		check[y]--;
    		total--;
    	}
    }
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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

const char newl = '\n';
ll const mod = 1e9+7;

int main() {
    int q;
    cin >> q;
    while (q--) {
        ll n,a,b;
        cin >> n >> a >> b;
        ll ans = 0,c = (n-a+1)*(n-b+1)%mod,d = (n-a-b+1)*(n-a-b+2)%mod;
        ans = c*c%mod-(c-d)*(c-d)%mod;
        if (a+b > n) ans = 0;
        cout << (ans+mod)%mod << newl;
    }
}

#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("O3")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

template <unsigned long long mod > class modint{
public:
    ll x;
    constexpr modint(){x = 0;}
    constexpr modint(ll _x) : x((_x < 0 ? ((_x += (LLONG_MAX / mod) * mod) < 0 ? _x + (LLONG_MAX / mod) * mod : _x) : _x)%mod){}
    constexpr modint set_raw(ll _x){
        //_x in [0, mod)
        x = _x;
        return *this;
    }
    constexpr modint operator-(){
        return x == 0 ? 0 : mod - x;
    }
    constexpr modint& operator+=(const modint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr modint operator+(const modint& a) const{
        return modint(*this) += a;
    }
    constexpr modint& operator-=(const modint& a){
        if((x -= a.x) < 0) x += mod;
        return *this;
    }
    constexpr modint operator-(const modint& a) const{
        return modint(*this) -= a;
    }
    constexpr modint& operator*=(const modint& a){
        (x *= a.x)%=mod;
        return *this;
    }
    constexpr modint operator*(const modint& a) const{
        return modint(*this) *= a;
    }
    constexpr modint pow(unsigned long long pw) const{
        modint res(1), comp(*this);
        while(pw){
            if(pw&1) res *= comp;
            comp *= comp;
            pw >>= 1;
        }
        return res;
    }
    //以下、modが素数のときのみ
    constexpr modint inv() const{
        if(x == 2) return (mod + 1) >> 1;
        return modint(*this).pow(mod - 2);
    }
    constexpr modint& operator/=(const modint &a){
        (x *= a.inv().x)%=mod;
        return *this;
    }
    constexpr modint operator/(const modint &a) const{
        return modint(*this) /= a;
    }
};
#define mod2 1000000007
using mint = modint<mod2>;

ostream& operator<<(ostream& os, const mint& a){
    os << a.x;
    return os;
}
using vm = vector<mint>;

int main() {
    cin>>Q;
    rep(_, Q){
        cin>>N>>A>>B;
        if(A < B) swap(A, B);
        ll m = min(B - 1, N - A);
        mint res(0);
        mint da(N - A + 1), db(N - B + 1), d(A - B + 1);
        mint sum = N - A + N - A + 1 - m;
        (sum *= m) *= (mod2 + 1) >> 1;
        res += da * da * (db * db - d * d);
        res -= sum * (d * da + sum) * 4;
        cout<<res<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=35;

int t,n,m;
ll a,b,k;
ll f[N][N];
string finds(ll a,ll b,ll k){
    if(!a) return string(b,'b');
    if(!b) return string(a,'a');
    if(f[a-1][b] >= k) return "a" + finds(a-1,b,k);
    else return "b" + finds(a,b-1,k-f[a-1][b]);
}

int main(){
    cin>>a>>b>>k;
    f[0][0] = 1;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++){
            if(i) f[i][j] += f[i-1][j];
            if(j) f[i][j] += f[i][j-1];
        }

    cout<<finds(a,b,k)<<endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <unistd.h>
#include <stdlib.h>
#include <cassert>

using namespace std;
// using namespace atcoder;

// using mint = long double;
// using mint = modint998244353;
// using mint = modint1000000007;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<ll, vector<ll>> Pd;

const ll INF = 2e18;
const ll fact_table = 3200008;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
//↓,→,↑,←

/*
#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif
*/

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

// const ll mod = 998244353ll;
// const ll mod = 1000000007ll;

// ll mypow(ll a, ll b, ll m = mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= m; b >>= 1;}(x *= a) %= m; b--;} return x;}
vec readvec(ll read) { vec res(read); for (int i = 0; i < read; i++) { cin >> res[i]; } return res;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5], rfact[fact_table + 5];

void c3_init() {
    fact[0] = rfact[0] = 1;
    for (ll i = 1; i <= fact_table; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table], mod - 2, mod);
    for (ll i = fact_table; i >= 1; i--) {
        rfact[i - 1] = rfact[i] * i;
        rfact[i - 1] %= mod;
    }
    return;
}
ll c3(ll n, ll r) {
    return (((fact[n] * rfact[r]) % mod ) * rfact[n - r]) % mod;
}
*/

bool multicase = false;

// ACLにするのを忘れない

ll mod;
ll dp[105][1000405];

void solve() {
    ll n, k;
    cin >> n >> k >> mod;

    dp[0][0] = 1ll;
    for (ll i = 1; i <= n; i++) {
        ll maxi = i * i * k + 100ll;
        for (ll j = 0; j <= maxi; j++) {
            ll value = (j - i >= 0) ? (dp[i][j - i]) : 0ll;
            value += dp[i - 1][j];
            value %= mod;
            if (j >= i * k + i) value += mod - dp[i - 1][j - i * k - i];
            value %= mod;
            dp[i][j] = value;
        }
    }
    for (ll i = 1; i <= n; i++) {
        // answer query i
        ll maxi = 1000000ll;
        ll ans = 0;
        for (ll j = 0; j <= maxi; j++) {
            ans += (dp[n - i][j] * dp[i - 1][j]) % mod;
            ans %= mod;
        }
        ans *= (k + 1ll);
        ans %= mod;
        ans += mod - 1ll;
        ans %= mod;
        p(ans);
    }
    return;
}

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

    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }

    // solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>T dup(T x, T y){return (x+y-1)/y;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}
int keta(ll n) { int ret = 0; while (n>0) { n/=10; ret++; } return ret; }

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) { cerr << head; dump(); }
template <typename Head, typename... Tail> void dump(Head &&head, Tail &&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do { cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

/////////////////////////////////////////////////////////////////////

void solve()
{
  int n; cin>>n;
  ll mi = -LINF;
  ll ma = LINF;
  ll fl = 0;
  rep(i, n) {
    ll a,t; cin>>a>>t;
    if (t == 1) {
      mi += a;
      ma += a;
      fl += a;
    }
    if (t == 2) {
      maxs(mi, a);
      maxs(ma, mi);
    }
    if (t == 3) {
      mins(ma, a);
      mins(mi, ma);
    }
  }
  mi -= fl;
  ma -= fl;
  int q; cin>>q;
  vector<ll> x(q); cin>>x;
  rep(i, q) {
    ll v = x[i];
    mins(v, ma);
    maxs(v, mi);
    cout << v+fl << "\n";
  }

}

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

  return 0;
}

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define INF LONG_MAX/3
//#define DIV 1000000007
//#define DIV 998244353

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

ll H, W;
string A[2005];

bool vv[2005][2005];
pair<ll, ll> memo[2005][2005];

//ここに飛んできたやつを先手とする
//先手が取れる点数, 後て
pair<ll, ll> dfs(ll y, ll x) {
	if(vv[y][x]) return memo[y][x];
	if(y == H - 1 && x == W-1) {
		if(y == 0 && x == 0) {
			return make_pair(0, 0);
		} else if(A[y][x] == '+') {
			return make_pair(1, 0);
		} else {
			return make_pair(-1, 0);
		}
	}
	pair<ll, ll> ret;
	if(y == H-1) {
		auto tmp = dfs(y, x+1);
		ret = make_pair(tmp.second, tmp.first);
	} else if(x == W-1) {
		auto tmp = dfs(y+1, x);
		ret = make_pair(tmp.second, tmp.first);
	} else {
		auto tmp0 = dfs(y, x+1);
		auto tmp1 = dfs(y+1, x);
		if(tmp0.first - tmp0.second> tmp1.first - tmp1.second) {
			ret = make_pair(tmp0.second, tmp0.first);
		} else {
			ret = make_pair(tmp1.second, tmp1.first);
		}
	}

	if(y != 0 || x != 0) {
		if(A[y][x] == '+') {
			ret.first++;
		} else {
			ret.first--;
		}
	}
	vv[y][x] = true;
	memo[y][x] = ret;
	return ret;
}

int main(){
	cin >> H >> W;
	rep(i, H) cin >> A[i];
	auto item = dfs(0, 0);
	if(item.first == item.second) {
		cout << "Draw" << endl;
	} else if(item.first > item.second) {
		cout << "Aoki" << endl;
	} else {
		cout << "Takahashi" << endl;
	}
}


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

int main() {
    long n, temp = 0;
    string s;
    stack<char> st;
    cin >> n >> s;
    if(n >= 3) {
        st.push(s.at(0));
        st.push(s.at(1));
        rep(i, n - 2) {
            if(st.size() < 2) {
                st.push(s.at(i + 2));
                continue;
            }
            char a = st.top();
            st.pop();
            char b = st.top();
            st.pop();
            if(b == 'f' && a == 'o' && s.at(i + 2) == 'x') {
                temp += 3;
            } else {
                st.push(b);
                st.push(a);
                st.push(s.at(i + 2));
            }
        }
    }
    long ans = n - temp;
    cout << ans << endl;
}

#include <iostream>
#include <vector>
#include <time.h>
#include <math.h>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii > vii;
typedef vector<vector<ll> > vvi;
typedef vector<vvi > vvvi;
typedef vector<vector<pair<ll, ll> > > vvii;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,s,e) for(ll i=(s);i<(e);++i)
#define repr(i,s,e) for(ll i=(e);i>(s);--i)
#define io ios::sync_with_stdio(false)
#define prv(v)                                                             \
	do                                                                      \
	{                                                                       \
		for(auto it = (v).begin(); it != (v).end(); ++it) cerr << *it << " "; \
		cerr << endl; \
	} while (0);
#define prm(m)                                           \
	do                                                     \
	{                                                      \
		for (auto it = (m).begin(); it != (m).end(); ++it)   \
			cerr << it->first << " -> " << it->second << endl; \
	} while (0);

const ll MOD = 1e9+7;
const ll INF = 1e14;
const ll TE3 = 1005;
const ll TE5 = 300005;
const string YN[2] = {"NO", "YES"};

using namespace std;

int main()
{
	io;
	ll n;
	string s;
	cin >> n >> s;
	stack<char> u;
	rep(i,0,n) {
		char c = s[i];
		if(u.size()<2) {
			u.push(c);
		} else {
			if(c!='x') {
				u.push(c);
			} else {
				char b = u.top();
				u.pop();
				char a = u.top();
				u.pop();
				if(a == 'f' && b == 'o') {

				} else {
					u.push(a);
					u.push(b);
					u.push(c);
				}
			}
		}
	}
	cout << u.size() << endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define int long long
using namespace std;
const ll INF = 1e18;
const ll MOD = 998244353;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
#ifdef MODULAR
void __print(mint x) {cerr << x;}
#endif
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef XOX
#define deb(x...) cerr << "Line (" << __LINE__ << ") : " << "[" << #x << "] = [", _print(x)
#else
#define deb(x...)
#endif

int32_t main() {
	ios::sync_with_stdio(!cin.tie(NULL));
	int n;
	cin >> n;
	string s;
	cin >> s;
	char ch;
	int ans = 0;
	bool found;
	int a = 0, g = 0, c = 0, t = 0;
	for(int i = 0; i < n; i++) {
		int ptr = 0;
		a = g = c = t = 0;
		for(int j = i; j < n; j++) {
			if(s[j] == 'A')		ch = 'T', a++;
			else if(s[j] == 'G') ch = 'C', g++;
			else if(s[j] == 'C') ch = 'G', c++;
			else if(s[j] == 'T') ch = 'A', t++;
			if(a == t and c == g) ans++;
			deb(i, j, a, t, g, c);
			//found = false;
			//while(ptr < n and !found) {
				//ptr++;
				//if(s[ptr - 1] == ch) found = true;
			//}
			//deb(i, j, ptr, found, ch);
			//if(!found)	break;
			//else	ans++;
		}
	}
	cout << ans;

}


//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
using namespace std;
#define Fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr)
#define ll long long int
#define fo(i, a, b) for (long long int i = a; i <= b; i++)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vl vector<long long int>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long int>>
#define mii map<int, int>
#define umii unordered_map<int, int>
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define newl cout<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e9;
const ll mod = 998244353;
#define MAX 305

ll mini(ll a,ll b){
    if(a>=b)return b;
    return a;
}

ll maxi(ll a,ll b){
    if(a>=b)return a;
    return b;
}

int main(){
	Fio;
    string s;
    cin>>s;
    fo(i,1,s.length()-1)cout<<s[i];
    cout<<s[0];
    return 0;
}

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

int main()
{
	string s;
  	cin >> s;
  	int len = s.size();
  	for(int i = 1; i < len; i++) cout << s[i];
  	cout << s[0] << endl;
  	return 0;
}


#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

//const int MAX=INT_MAX;

//const ll MAX=100000000000;

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

//const ll A=100000000000;

const int INF=1000000000;

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

}

int main(){

    int T;
    cin>>T;

    ll N,S,K;

    for(int t=0;t<T;t++){
        cin>>N>>S>>K;

        ll x=0;
        ll y=0;
        ll g=extgcd(N,-K,x,y);
        if(S%g!=0){
            cout<<-1<<endl;
        }else{
            ll s=S/g;
            ll n=N/g;
            ll k=K/g;
            ll nx=x*s;
            ll ny=y*s;

           // cout<<"ny:"<<ny<<"n:"<<n<<endl;

            ll t;
            if(n>0){
            if(-double(ny)/double(n)<0){
                t=-ny/n;
            }else{
                t=-ny/n+1;
            }
            }else{
                if(-double(ny)/double(n)<0){
                    t=-ny/n-1;
                }else{
                    t=-ny/n;
                }

            }

           // cout<<t<<endl;

           ll ans=n*t+ny;

           // cout<<g<<":"<<s<<":"<<x<<":"<<y<<":"<<ans<<endl;
            cout<<ans<<endl;

        }
    }
}

#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SIZE(x) ll(x.size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<double> x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];

    rep(i, N) {
        repd(j, i + 1, N) {
            repd(k, j + 1, N) {
                double l = (y[j] - y[i]) * (x[k] - x[i]);
                double r = (y[k] - y[i]) * (x[j] - x[i]);
                if (r == l) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
const int MN = 2020;
const ll M = 1e9+7;
inline ll mul(ll a, ll b) {
	return (a*b)%M;
}
ll bp(ll b, ll p) {
	ll ac = 1;
	while(p) {
		if(p&1) {
			ac = mul(ac,b);
		}
		b = mul(b,b);
		p >>= 1;
	}
	return ac;
}
ll prf[MN*MN];
ll fac(ll val) {
	if(val <= 1) {return 1;}
	if(prf[val] != -1) {return prf[val];}
	prf[val] = mul(fac(val-1),val);
	return prf[val];
}
ll inv(ll val) {
	return bp(val,M-2);
}
ll ch(ll n, ll k) {
	ll num = 1;
	for(ll i=0;i<k;i++) {
		num = mul(num,n-i);
	}
	ll dem = fac(k);
	return mul(num,inv(dem));
}
vl w;
int main() {
	memset(prf,-1,sizeof(prf));
	ll n,m;
	cin >> n >> m;
	ll su = 0;
	for(int i=0;i<n;i++) {
		ll a;
		cin >> a;
		w.push_back(a);
		su += a;
	}
	su += n;
	m += n;
	cout << ch(m,su) << '\n';
}

// Problem: D - Binomial Coefficient is Fun
// Contest: AtCoder - AtCoder Regular Contest 110（Sponsored by KAJIMA CORPORATION）
// Time: 2020-12-14 00:33:52

// 私に忍び寄るのをやめてください、ありがとう

#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define int long long
#define mod 1000000007 //998244353
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define x first
#define y second
#define vc vector
#define pb push_back
#define ar array
#define all(a) (a).begin(), (a).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(v,n,x) fill(v,v+n,x);
#define init(c,a) memset(c,a,sizeof(c))
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define inf 9e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
// void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

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

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

int inverse(int x){
    return power(x,mod-2);
}

int const N = 5e6+55;
int fact[N], ifact[N];

void precompute(){
    fact[0] = 1;
    for(int i=1;i<N;i++){
        fact[i] = fact[i-1]*i;
        fact[i] %= mod;
    }
    ifact[N-1] = inverse(fact[N-1]);
    for(int i=N-2;i>=0;i--){
        ifact[i] = (i+1)*ifact[i+1];
        ifact[i] %= mod;
    }
}

ll ncr(ll x,ll y){
	ll now=x,ans=1;
	now%=mod;
	f(i,y){
		ans=ans*now%mod;
		now=(now-1+mod)%mod;
		//if(now<0)return 0;
	}

	ans=ans*ifact[y]%mod;
	return ans;

}

int32_t main()
{

	fast
	cout << fixed << setprecision(12);
	ll n,m;
	cin>>n>>m;
	precompute();
	vll a(n);
	ll s=0;
	f(i,n){
		cin>>a[i];
		s+=a[i];
	}

	cout<<ncr(m+n,s+n);

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
//first second
//memset(dp, -1, sizeof dp);

struct keycompare {
    bool operator()(const pair<ll, ll>& v, const ll& k) {
        return (v.first < k);
    }
    bool operator()(const ll& k, const pair<ll, ll>& v) {
        return (k < v.first);
    }
};

ll mod1=998244353,mod2=1000000007,limit=9223372036854775807;
long double pi=3.1415926535897932;
ll modpow(ll x, ll n, ll m) {

    if(x>m){
        x%=m;
    }
    if (n == 0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
bool isprime(ll n){
    if(n==2)
        return true;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
            return false;
    }
    return true;
}

ll power(ll x,ll n){
    ll x_n=1;
    for(ll i=0;i<n;i++){
        x_n*=x;
    }
    return x_n;
}

ll pre[200005][305];
ll fact[305], inverse[305];
int ncr(int n,int r){
    ll ans=(fact[n]*inverse[r])%mod1;
    ans=(ans*inverse[n-r])%mod1;
    return ans;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    fact[0]=1,inverse[0]=1;
    for(int i=1;i<305;i++){
        fact[i]=(fact[i-1]*i)%mod1;
        inverse[i]=modpow(fact[i],mod1-2,mod1);
    }
    int n,k; cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
        pre[i][0]=1;
    }
    ll tempo[k+1]={0};
    tempo[0]=n;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            pre[i][j]=(pre[i][j-1]*arr[i])%mod1;
            tempo[j]=(tempo[j]+pre[i][j])%mod1;
        }
    }
    int check=modpow(2,mod1-2,mod1);
    for(int x=1;x<=k;x++){
        ll result=0;
        for(int p=0;p<=x;p++){
            ll tempans=(tempo[x-p]*tempo[p])%mod1;
            tempans=(tempans*ncr(x,p))%mod1;
            result=(result+tempans)%mod1;
        }
        result=(result-(modpow(2,x,mod1)*tempo[x]))%mod1;
        result=(result*check)%mod1;
        cout<<(result+mod1)%mod1<<"\n";
    }
    cout<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
#include <cstdint>
#include <string>
#include <sstream>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using P = pair<int,int>;

const int INF=1001001001;
const int mod =998244353;

struct mint {
  ll x;
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
 };
  istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
  ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
  struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
 } c(200005);

int main() {
  ll N,K;
  cin>>N>>K;
  vector<mint>A(N);
  rep(i,N){
    int a;
    cin>>a;
    A[i]=a;
  }
  vector<mint>sum(K+1);
  rep(i,N){
    mint ki=1;
    rep(k,K+1){
      sum[k]=(sum[k]+ki);
      ki=ki*A[i];
    }
  }
  for(int x=1;x<=K;x++){
    mint ans=0;
    rep(k,x+1){
      ans+=c(x,k)*sum[k]*sum[x-k];
    }
    mint p=mint(2).pow(x)*sum[x];
    cout<<(ans-p)/2<<endl;
  }
  return 0;
}


#include<cstdio>
int n;
int w[105];
int dp[105][21000];
int ndp[105][21000];
int mod = 998244353;
int dpbase = 10500;
long long int fct[105];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &w[i]);
	}
	dp[0][dpbase] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			for (int k = dpbase - 100 * i; k <= dpbase + 100 * i; k++) {
				ndp[j][k - w[i]] += dp[j][k];
				ndp[j][k - w[i]] %= mod;
				ndp[j + 1][k + w[i]] += dp[j][k];
				ndp[j + 1][k + w[i]] %= mod;
			}
		}
		for (int j = 0; j <= (i + 1); j++) {
			for (int k = dpbase - 100 * (i + 1); k <= dpbase + 100 * (i + 1); k++) {
				dp[j][k] = ndp[j][k];
				ndp[j][k] = 0;
			}
		}
	}
	fct[0] = 1;
	for (int i = 1; i <= n; i++) {
		fct[i] = fct[i - 1] * i%mod;
	}
	long long int ans = 0;
	for (int i = 0; i <= n; i++) {
		ans += dp[i][dpbase] * fct[i] % mod*fct[n - i] % mod;
		ans %= mod;
	}
	printf("%lld\n", ans);
	return 0;
}

#include<bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define nep(i,r,l) for(int i=r;i>=l;i--)
void sc(int &x){scanf("%d",&x);}
void sc(int &x,int &y){scanf("%d%d",&x,&y);}
void sc(int &x,int &y,int &z){scanf("%d%d%d",&x,&y,&z);}
void sc(ll &x){scanf("%lld",&x);}
void sc(ll &x,ll &y){scanf("%lld%lld",&x,&y);}
void sc(ll &x,ll &y,ll &z){scanf("%lld%lld%lld",&x,&y,&z);}
void sc(char *x){scanf("%s",x);}
void sc(char *x,char *y){scanf("%s%s",x,y);}
void sc(char *x,char *y,char *z){scanf("%s%s%s",x,y,z);}
void out(int x){printf("%d\n",x);}
void out(ll x){printf("%lld\n",x);}
void out(int x,int y){printf("%d %d\n",x,y);}
void out(ll x,ll y){printf("%lld %lld\n",x,y);}
void out(int x,int y,int z){printf("%d %d %d\n",x,y,z);}
void out(ll x,ll y,ll z){printf("%lld %lld %lld\n",x,y,z);}
using namespace std;
const int N=105,mod=998244353;
int n,a[N],dp[N][N*N];
ll f[N];
int main()
{
    f[0]=1;
    rep(i,1,N-1) f[i]=f[i-1]*i%mod;
    sc(n);
    int sum=0;
    rep(i,1,n) sc(a[i]),sum+=a[i];
    if(sum&1) {out(0);return 0;}
    sum/=2;
    dp[0][0]=1;
    int s=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=i-1;j>=0;j--)
        for(int k=s;k>=0;k--)
        dp[j+1][k+a[i]]=(dp[j+1][k+a[i]]+dp[j][k])%mod;
        s+=a[i];
    }
    ll ans=0;
    for(int i=1;i<=n;i++) ans=(ans+dp[i][sum]*f[i]%mod*f[n-i]%mod)%mod;
    out(ans);
}