#include <bits/stdc++.h>
#include <limits>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i,n) for( ll i=0 ; i<n ; i++ )
#define f(i, a, b) for( ll i=a ; i<b ; i++ )
#define vi vector<int>
#define pb push_back
#define MOD 1000000007
ll digits(ll n)
{
    return floor(log10(double(n))) + 1;
}
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result = 1;
    while(n>0)
    {
        if(n % 2 ==1)
        {
            result = ((result%M)*(x%M))%M;
        }
        x  = ((x%M)*(x%M))%M;
        n = n/2;
    }
    return result%M;
}
ll d, x, y;
void extendedEuclid(ll A, ll B)
{
    // for computing modular inverse
    // make b as Mod such that gcd of mod and a is 1
    // also the coeff x here will denote the modular inverse of a
    if(B == 0)
    {
        d = A;
        x = 1;
        y = 0;
    }
    else
    {
        extendedEuclid(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
        // x = y1
        // y = x1 - y1*(a/b);
    }
}
// DP solution for nCr
ll nCrModp(ll n, ll r)
{
    if (r > n - r)
        r = n - r;
    ll C[r + 1];
    memset(C, 0, sizeof(C));

    C[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i,r); j > 0; j--)
        {
            C[j] = (C[j] + C[j - 1]);
        }

    }
    return C[r];
}
ll modInverse(ll A, ll M)
{
    extendedEuclid(A,M);
    return (x%M+M)%M;    //x may be negative
}

// primefactors[a] = primefactors[a/primedivisor[a]] + 1
ll binarySearch(vector<ll>&arr, ll l, ll r, ll x)
{
    while (l <= r)
    {
        int m = l + (r - l) / 2;
        if (arr[m] == x)
            return m;
        if (arr[m] < x)
            l = m + 1;
        else
            r = m - 1;
    }
    return -1;
}
vector<ll>v;
vector<ll> SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    for (ll p=2; p<=n; p++)
        if (prime[p])
            v.push_back(p);
    return v;
}

// 11 12 15 18 2 5 6 8 9 10
double fun(vector<double>&v, double m,double n)
{
    double s = 0;
    double ma = 0;
    double mi = 0;
    fi(i,n)
    {
        s += v[i] - m;
        ma = max(s,ma);
        mi = min(s,mi);
    }
    return ma - mi;
}
int main()
{
    faster();
    ll n;
    cin>>n;
    set<ll>st;
    for(ll i =1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            st.insert(i);
            st.insert(n/i);
        }
    }
    for(auto it = st.begin();it!=st.end();it++)
    {
        ll a = *it;
        cout<<a<<endl;
    }

}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, OO = 1e9;
long long   a[N] , j = 0;
long long n;
void divisor(long long value){
    long long i = 1;
    for( ; i * i < value; ++i){
        if(value % i == 0){
            a[j] = i;
            j++;
            a[j] = value / i;
            j++;
        }
    }
    if( i * i == value){
        a[j] = i;
        j++;
    }
}
int main() {
    cin >> n;
    divisor(n);
    sort(a , a + j);
    for(int i =0; i<j; ++i){
        cout << a[i] << endl;
    }

return 0;
}


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

typedef long long ll;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define INT(n) int n;assert(0<scanf("%d",&n))

static const int MAXP = 1000000;
vector<int> ps, fs;
void init(){
  fs.reserve(1 + MAXP);
  for(int i = 0; i <= MAXP; i++){fs.push_back(i);}
  for(int i = 2; i <= MAXP; i++){
    if (fs[i] == i){
      ps.push_back(i);
      for (int j = i; j <= MAXP; j += i){
        fs[j] = min(fs[j], i);
      }
    }
  }
}
bool isprime(const long long& n){
  if (n <= MAXP){
    return (1 < n && fs[n] == n);
  } else {
    for(int p: ps){
      if (n % p == 0){return false;}
    }
    return true;
  }
}
vector<pair<long long, int>> factor(long long n){
  vector<pair<long long, int>> v;
  long long i = n;
  if (MAXP < i){
    for(int p: ps){
      int r = 0;
      while (i % p == 0){r++; i /= p;}
      if (0 < r){v.push_back(make_pair(p, r));}
      if (i <= MAXP){break;}
    }
    if (MAXP < i){
      v.push_back(make_pair(i, 1));
      i = 1;
    }
  }
  while(1 < i){
    if (v.empty() || (*v.rbegin()).first != fs[i]){
      v.push_back(make_pair(fs[i], 1));
    } else {
      (*v.rbegin()).second++;
    }
    i /= fs[i];
  }
  return v;
}

int moebius(long long n){
  int m = 1;
  for(auto pr: factor(n)){
    if (pr.second == 1){
      m *= -1;
    } else {m = 0; break;}
  }
  return m;
}

int main(){
  ll ans = 0;
  init();
  INT(l); INT(r);
  REP(i, 2, r / 2 + 1){
    int n = r / i - (l - 1) / i;
    ans += (ll) -moebius(i) * n * (n - 1);
    if (l <= i){ans -= 2*(n - 1);}
  }
  printf("%lld\n", ans);
  return 0;
}

#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define read(x) for(auto& qw : (x)) cin >> qw;
#define print(x) for(auto& qw : (x)) cout << qw << " "; cout << endl;
using namespace std;

typedef long long ll;
typedef pair<double,double> ii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-6;

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

	vector<ii> V(N);
	for(ii &x : V) cin >> x.f >> x.s;

	int ans = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(j == i) continue;

			double slope = (V[i].s - V[j].s)/(V[i].f - V[j].f);
			if(fabs(slope) < 1 + EPS)
				ans++;
		}
	}

	cout << ans/2 << endl;
}

int main(){ _

	int tt = 1;
//	cin >> tt;

	while(tt--){
		test_case();
	}

	return 0;
}


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

int main() {
	double sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy;
	double ans = (gx - sx)*sy/(sy+gy) + sx;
	printf("%f06\n", ans);

    return 0;
}

#include <iostream>
#include <iomanip>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(16);
  double sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  if (sx > gx) {
    swap(sx, gx);
    swap(sy, gy);
  }
  sy = -sy;
  double dy = gy - sy, dx = gx - sx;
  auto check = [&](double x) {
    return dy * (sx - x) >= dx * sy;
  };
  double l = sx, r = gx, x;
  for (int it = 0; it < 50; it++) {
    check(x = (l + r) * 0.5) ? l = x : r = x;
  }
  cout << l << '\n';
  return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#define repi(i, s, e) for (int i = (s); i < (e); ++i)
using namespace std;
using ll = int64_t;

int main()
{
    int n;
    cin >> n;
    ll x[n];
    repi(i, 0, n) cin >> x[i];

    ll man = 0;
    repi(i, 0, n) man += abs(x[i]);

    double euc = 0;
    repi(i, 0, n) {
        euc += x[i]*x[i];
    }
    euc = sqrt(euc);

    ll che = 0;
    repi(i, 0, n) if(che < abs(x[i])) che = abs(x[i]);

    cout << man << endl;
    printf("%.9lf\n", euc);
    cout << che << endl;

    return 0 ;
}

/**
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define REP(i,a,n) for(i=a;i<=n;i++)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,b,a) for(i=b;i>=a;i--)
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll mod=1e16;
const ll MAXN=1000200;
ll i,j,mask;
int main()
{
IOS
/*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE*/
ll n;
cin>>n;
ll a=0,c=0;
double b=0;
F(i,0,n)
{
    ll x;
    cin>>x;
    a+=abs(x);
    b+=x*x;
    c=max(c,abs(x));
}
b=(double)sqrt(b);
cout<<a;nl
cout<<fixed<<setprecision(15)<<b;nl
cout<<c;
return 0;
}


#include<bits/stdc++.h>

#define DONTSYNC ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL) //dont use stdio with iostream functions //input and output are out of order now!
#define TEST unsigned long long T; cin>>T; while(T--)  //loop over each testcase
#define endl "\n"
#define fori(a,start,end) for(int a=start;a<end;a++)
#define forll(a,start,end) for(long long a=start;a<end;a++)
#define forull(a,start,end) for(unsigned long long a=start;a<end;a++)
#define MOD 998244353
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int N,K;
int parent(int a,vector<int> &par){
    if(par[a]==a){
        return a;
    }
    par[a]=parent(par[a],par);
    return par[a];
}
void group(int a,int b,vector<int> &par){
    int para=parent(a,par),parb=parent(b,par);
    if(para<parb){
        par[parb]=para;
    }
    else{
        par[para]=parb;
    }
}
bool check(int isrow,int a,int b,vector< vector<int> > &mat){
    if(isrow){
        fori(col,0,N){
            if(mat[a][col]+mat[b][col]>K) return false;
        }
    }
    else{
        fori(row,0,N){
            if(mat[row][a]+mat[row][b]>K) return false;
        }
    }
    return true;
}
void solve(){
    /* code */
     cin>>N>>K;
    long long res=1;
    vector< vector<int> > mat(N,vector<int>(N));
    fori(i,0,N) fori(j,0,N) cin>>mat[i][j];
    ////////
    vector<int> par(N); fori(i,0,N) par[i]=i;
    fori(a,0,N-1){
        fori(b,a+1,N){
            if (check(1,a,b,mat)) group(a,b,par);
        }
    }
    vector<int> count(N,1);
    fori(i,0,N) res=(res*count[parent(i,par)]++)%MOD;
    //////
    fori(i,0,N) par[i]=i;
    fori(a,0,N-1){
        fori(b,a+1,N){
            if (check(0,a,b,mat)) group(a,b,par);
        }
    }
    fill(count.begin(),count.end(),1);
    fori(i,0,N) res=(res*count[parent(i,par)]++)%MOD;

    cout<<res;
}

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

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

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

const int INF=1e9;
const ll MOD=998244353;

struct UnionFind{

    vector<int> par;
    vector<int> sizes;

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

    int find(int x) { //xの根を得る
        if (x == par[x]) return x;
        return par[x] = find(par[x]); //根を張り替えながら再帰的に根ノードを探す
    }

    //2つの要素が属する集合を併合
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    //2つの要素が同じ集合に属するか判定する
    bool same(int x, int y) {
        return find(x) == find(y);
    }

    //集合のサイズを取得
    int size(int x) {
        return sizes[find(x)];
    }

};

int main(){
    int N,K; cin >> N >> K;
    ll ans=1;
    ll a[N][N];
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> a[i][j];
        }
    }
    UnionFind ufr(N+10);
    UnionFind ufl(N+10);
    vector<int> r[N+1],l[N+1];
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            bool flag=true;
            bool flag2=true;
            for(int k=0;k<N;k++){
                if(i==j) continue;
                if((a[k][i]+a[k][j])>K) flag=false;
                if((a[i][k]+a[j][k])>K) flag2=false;
            }
            if(flag) ufr.unite(i,j);
            if(flag2) ufl.unite(i,j);
        }
    }
    bool usedr[N+10]={};
    bool usedl[N+10]={};
    for(int i=0;i<N;i++){
        if(usedr[ufr.find(i)]) continue;
        usedr[ufr.find(i)]=true;
        for(int j=1;j<=ufr.size(ufr.find(i));j++){
           ans*=j; ans%=MOD;
        }
    }
    for(int i=0;i<N;i++){
        if(usedl[ufl.find(i)]) continue;
        usedl[ufl.find(i)]=true;
        for(int j=1;j<=ufl.size(ufl.find(i));j++){
           ans*=j; ans%=MOD;
        }
    }
    cout << ans%MOD << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define each(e, v) for(auto &e: v)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct io_setup{
    io_setup(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

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

    vector<ll> L(N+2, INF), R(N+2, -INF);
    L[0] = 0, R[0] = 0, L[N+1] = 0, R[N+1] = 0;

    rep(i, N){
        ll x; int c; cin >> x >> c;
        chmin(L[c], x), chmax(R[c], x);
    }

    vector<vector<ll>> dp(N+2, vector<ll>(2, INF));
    dp[0][0] = 0, dp[0][1] = 0;

    int pre = 0;

    rep2(i, 1, N+1){
        if(L[i] == INF) {dp[i][0] = dp[pre][0], dp[i][1] = dp[pre][1]; continue;}

        chmin(dp[i][0], dp[pre][0]+abs(R[i]-L[pre])+abs(L[i]-R[i]));
        chmin(dp[i][1], dp[pre][0]+abs(L[i]-L[pre])+abs(R[i]-L[i]));

        chmin(dp[i][0], dp[pre][1]+abs(R[i]-R[pre])+abs(L[i]-R[i]));
        chmin(dp[i][1], dp[pre][1]+abs(L[i]-R[pre])+abs(R[i]-L[i]));

        pre = i;
    }

    //rep(i, N+2) cout << dp[i][0] << ' ' << dp[i][1] << '\n';

    cout << min(dp[N+1][0], dp[N+1][1]) << '\n';
}

#include <bits/stdc++.h>

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
    fastio
    //Equivalent to the problem which we need to collect from the top of the grid down
    int n;
    cin >> n;
    int l[n+1], r[n+1];
    fill(l,l+n+1,1e18);
    fill(r,r+n+1,-1e18);
    for(int i = 0;i < n;i++){
        int x,c;
        cin >> x >> c;
        l[c] = min(l[c],x);
        r[c] = max(r[c],x);
    }
    l[0] = r[0] = 0;
    int dp[n+1][2] = {}; //dp[i][0] => start from left, dp[i][1] start from right
    for(int i = 1;i <= n;i++){
        dp[i][0] = dp[i-1][0], dp[i][1] = dp[i-1][1];
        if(l[i]==1e18){
            l[i] = l[i-1], r[i] = r[i-1];
            continue;
        }
        dp[i][0] = min(dp[i-1][0]+abs(l[i]-r[i-1])+r[i]-l[i],dp[i-1][1]+abs(l[i]-l[i-1])+r[i]-l[i]);
        dp[i][1] = min(dp[i-1][0]+abs(r[i]-r[i-1])+r[i]-l[i],dp[i-1][1]+abs(r[i]-l[i-1])+r[i]-l[i]);
    }
    cout << min(dp[n][0]+abs(r[n]),dp[n][1]+abs(l[n])) << "\n";
}


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

int main() {
    double sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    double ty = sy + gy;
    double tx;
    if(sx >=0 && gx >= 0){
      if(sx > gx){
        tx = sx - gx;
      }
      else{
        tx = gx - sx;
      }
    }
    else if(sx < 0 && gx >=0){
        tx = -sx + gx;
    }
    else if(sx >=0 && gx < 0){
        tx = sx - gx;
    }
    else{
      if(sx > gx){
        tx = sx - gx;
      }
      else{
        tx = gx - sx;
      }
    }
    double ans;
    if(sx < gx){
        ans = sx + tx*(sy / ty);
    }
    else{
        ans = sx - tx*(sy / ty);
    }
  printf("%.10f\n", ans);
}

/*     Har Har Mahadev    */
//cout<<fixed<<setprecision(11)<<ans<<"\n";
//cin.ignore();getline(cin,s,'\n');
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define lab(i,a,b) for(i=a;i<=b;i++)
#define bal(i,a,b) for(i=b;i>=a;i--)
#define ff first
#define ss second
#define pb push_back
#define se(v) v.begin(), v.end()
#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tc ll t;cin>>t;while(t--)
#define fceil(a,b) ceil((ld)a/(ld)b)
#define dis(v) for(auto it:v)cout<<it<<" "
#define yep cout<<"Yes\n"
#define nope cout<<"No\n"
bool isPrime(ll n){if(n <= 1)return false;if(n <= 3)return true;if(n%2==0||n%3==0)return false;for(ll i=5;i*i<= n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
bool cmp(pll &a, pll &b){ if(a.ss == b.ss)return a.ff < b.ff;return a.ss < b.ss;}
const ll MOD = 1e9 + 7;
ll powerLL(ll x, ll n){ll result = 1;while (n){if (n & 1)result = result * x % MOD;n = n / 2;x = x * x % MOD;}return result;}
int main()
{
    fst
    ll n,m,i,j,k,f,sum,ans,x,y,z;
    //tc
    {
      m=0,i=0,j=0,f=0,sum=0,x=0,y=0,z=0,ans=0;
      ll a[3];
      cin>>a[0]>>a[1]>>a[2];
      sort(a,a+3);
      if(2*a[1]==a[0]+a[2])yep;
      else nope;
    }
    return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	for (int i=0;i<n;i++) cin>>a[i];
	vector<int> sav(200007,0);
	int m=0;int nm=1;
	for (int i=0;i<n;i++)
	{
		sav[a[i]]=1;

		if (sav[m]!=0)
		{

			while (sav[m]!=0)
			{
				m++;
			}

			cout<<m<<"\n";
		}
		else
		{
			cout<<m<<"\n";
		}

	}
	return 0;
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
#define int ll
//#define double long double
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int n, t;
set<int> S;

signed main() {
	fastio;
	cin >> n;
	FOR(i, n + 1) S.insert(i);
	FOR(i, n) {
		cin >> t;
		S.erase(t);
		cout << *S.begin() << endl;
	}
}


#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace __gnu_pbds;
//using namespace boost::multiprecision;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<vector<ll>> VVI;
typedef pair<ll, ll> PII;
typedef vector<PII> VPII;
typedef set<ll> SI;
typedef map<string, ll> MSI;
typedef map<ll, ll> MII;
typedef pair<ll, PII> PIII;

#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define MOD 1000000007
#define test ll t;cin>>t;while(t--)
#define REP(i,a,b) for (int i = a; i <= b; i++)

void solve()
{
    int a,b;
    cin >> a >> b;
    int x = INT_MAX-1;
    int arr[a][b];
    for(int i=0;i<a;i++)
    {
        for(int j=0;j<b;j++)
        {
            cin >> arr[i][j];
            x = min(x,arr[i][j]);
        }
    }
    int ans = 0;
     for(int i=0;i<a;i++)
    {
        for(int j=0;j<b;j++)
        {
            ans+=(arr[i][j]-x);
        }
    }
    cout << ans << "\n";

    return;
}

int main()
{
    flash;

    // test
    // {
    //     solve();
    // }
    solve();

    return 0;
}

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

#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rep2(i, m, n) for(ll i = (ll)(n)-1; i >= (ll)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;

constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;

using Array = vector<ll>;
using Matrix = vector<Array>;

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

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

struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n,m;
    cin>>n>>m;
    vvec<ll> a(n,vec<ll>(m,0));
    ll mi=INF;
    REP(i,n){
        REP(j,m){
            cin>>a[i][j];
            chmin(mi,a[i][j]);
        }
    }

    ll ans=0;
    REP(i,n) REP(j,m) ans+=a[i][j]-mi;
    cout<<ans<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    REP(i, t - 1) {
        solve();
    }*/

    solve();

    return 0;
}


#include <bits/stdc++.h>

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
typedef long long LL;

const int MAXN = 3005;
const int MOD = 998244353;
int n, k, dp[MAXN][MAXN];

template <class T>
void read(T& x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

template <class T, class... Args>
void read(T& x, Args&... args) {
    read(x), read(args...);
}

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

int make(int n, int k) {
    if (k > n) return 0;
    if (n == k) return 1;
    if (n == 0 || k == 0) return 0;
   // cout << n << " " << k << endl;
    if (dp[n][k]) return dp[n][k];
    dp[n][k] = (make(n - 1, k - 1) + make(n, k * 2)) % MOD;
    return dp[n][k];
}

signed main() {
    // freopen("1.in", "r", stdin);
    read(n, k);
    cout << make(n, k);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define fore(i_in,a) for (auto& i_in: a)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fio() cin.tie(nullptr);ios::sync_with_stdio(false);
#define DEBUG_CTN(v) cerr<<#v<<":";for(auto itr=v.begin();itr!=v.end();itr++) cerr<<" "<<*itr; cerr<<endl
template<class T> bool chmax(T &a, const T &b) {if (a<b) { a = b; return true; } return 0;}
template<class T> bool chmin(T &a, const T &b) {if (a>b) { a = b; return true; } return 0;}
template<class T> void print(const T &t) { cout << t << "\n"; }
const ll INF = 1LL << 62;
const int iINF = 1 << 30;

int n,m;
string s;

int main() {
    fio(); cin>>n>>m;
    vl cnt(2,0);
    rep(i,n) {
        cin>>s;
        ll tmp=count(all(s),'1');
        cnt[tmp%2]++;
    }
    print(cnt[0]*cnt[1]);
}
//9min 1wa


#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

int main(){
#ifdef LOCAL
	freopen("E_input.txt", "r", stdin);
	//freopen("E_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	for (int i = 0; i < n; ++i) {
		int A = i/2, B = min(n - 1, i/2 + (n+1) / 2);
		cout << A+1 << " " << B+1 << endl;
	}

}

///****In the name of ALLAH, most Gracious, most Compassionate****//

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

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

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

#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define NL cout<<endl

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

const int N=3e5+5;
const int oo=1e9+7;

int32_t main()
{
    FastIO;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cout<<(2*i)%n+1<<" "<<(2*i + 1)%n+1<<"\n";
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ud unsigned int
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x3f
#define MAX_INF_VAL 0x3f3f3f3f
#define MAX_INF_VAL_LL 0x3f3f3f3f3f3f3f3f
//#define pi 3.141592653589
#define eps 1e-9
#define F(x) ((x)/3+((x)%3==1?0:tb))
#define G(x) ((x)<tb?(x)*3+1:((x)-tb)*3+2)
//#define p 2173412051LL
//#define sz 2

using namespace std;

template< typename T > void read( T &x ) {
	x = 0;
	char ch = getchar();
	ll f = 1;
	while( !isdigit( ch ) ) {
		if( ch == '-' )
		f *= -1;
		ch = getchar();
	}
	while( isdigit( ch ) ) {
		x = x * 10 + ch - 48;
		ch = getchar();
	}
	x *= f;
}

struct custom_hash {
    static uint64_t splitmix64( uint64_t x ) {
        x += 0x9e3779b97f4a7c15;
        x = ( x ^ ( x >> 30 ) ) * 0xbf58476d1ce4e5b9;
        x = ( x ^ ( x >> 27 ) ) * 0x94d049bb133111eb;
        return x ^ ( x >> 31 );
    }

    size_t operator() ( uint64_t x ) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64( x + FIXED_RANDOM );
    }
};

vector< int > ans;

void opt( int );

int main() {
	ios::sync_with_stdio( false );
	cin.tie( 0 ), cout.tie( 0 );
	ll n;
	vector< ll > a, b;
	{
		ll x = 1, y = 1;
		a.push_back( x );
		a.push_back( y );
		while( true ) {
			x += y;
			if( x > 1e18 )
				break;
			a.push_back( x );
			swap( x, y );
		}
	}
	cin >> n;
	while( a[ a.size() - 1 ] > n )
		a.pop_back();
	for( auto v: a )
		b.push_back( v );
	while( true ) {
		int i = b.size() - 1;
		if( b[ i ] == n )
			break;
		ll del = n - b[ i ];
		int j = 0;
		while( j + 1 < a.size() && a[ j + 1 ] <= del )
			++j;
		int fk = i - j;
		for( int k = b.size() - 1; k >= fk; --k )
			b[ k ] += a[ k - fk ];
	}
	ll x = 0, y = 0;
	for( int i = 0, j = b.size() & 1; i < b.size(); ++i, j = 1 - j ) {
		if( j ) {
			x += y;
			assert( x == b[ i ] || x + 1 == b[ i ] );
			opt( 3 );
			if( x != b[ i ] ) {
				++x;
				opt( 1 );
			}
		} else {
			y += x;
			assert( y == b[ i ] || y + 1 == b[ i ] );
			opt( 4 );
			if( y != b[ i ] ) {
				++y;
				opt( 2 );
			}
		}
	}
	assert( x == n );
	cout << ans.size() << '\n';
	for( auto v: ans )
		cout << v << '\n';
	return 0;
}

void opt( int x ) {
	ans.push_back( x );
	assert( ans.size() <= 130 );
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rrep(i,n) for(ll i=n-1; i>=0; i--)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
string zero_padding(int val, int nf){ ostringstream sout;sout << setfill('0') << setw(nf) << val; return sout.str();};
ld PI=asin(1)*2;
//using namespace atcoder;

vector<vector<ll>> G(200010);
map<Pll,ll> mp;
map<Pll,ll> np;
vector<ll> ans(200010,0);

ll dfs(ll v, ll p){
    //sum += mp[Pll(p,v)];
    //ans[v] += sum;
    ll ret = 0;
    for(auto& u:G[v]){
        if(u==p)continue;
        ret += dfs(u,v);
    }
    return np[{v,p}] = ret + mp[{v,p}];
    //mp[Pll(-1,v)] += sum;
}
void bfs(ll v, ll p){
    ll ret = 0;
    for(auto& u:G[v]){
        ret += np[{u,v}];
    }
    ans[v] = ret;
    for(auto& u:G[v]){
        if(u == p) continue;
        np[{v,u}] = ans[v] - np[{u,v}] + mp[{v,u}];
        bfs(u,v);
    }
}

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N-1), B(N-1);
    rep(i,N-1){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    ll Q;
    cin >> Q;
    vector<ll> T(Q), E(Q), X(Q);
    rep(i,Q){
        cin >> T[i] >> E[i] >> X[i];
        E[i]--;
    }
    rep(i,Q){
        ll e = E[i];
        if(T[i] == 1){
            mp[Pll(B[e], A[e])] += X[i];
        }else{
            mp[Pll(A[e], B[e])] += X[i];
        }
    }
    dfs(0,-1);
    //for(auto&e:mp){
    //    cout << e.fi.fi << " " << e.fi.se << "   " << e.se << endl;
    //}
    bfs(0,-1);
    rep(i,N){
        cout << ans[i] << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define light ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vp(v)  for(auto it = v.begin(); it != v.end(); it++)  cout << *it << " "; cout<<endl;

int main()
{
    light
    ll tx;
    cin>>tx;
    ll h1, h2 , t;
    string s1 , s2 , ts ;
    cin>>s1>>h1;
    cin>>s2>>h2;
    if( h1 < h2){
        t = h1 ;
        ts = s1;
        h1 = h2 ;
        s1 = s2 ;
        h2 = t;
        s2 = ts;
    }
    for(ll i =2; i<tx; i++){
        ll he;
        string  m ;
        cin>>m>>he;
        if( he > h1 ){
            t = h1 ;
            ts = s1;
            h1 = he ;
            s1 = m ;
            h2 = t;
            s2 = ts;
        }
        else if( h1 > he && h2 < he){
            h2 = he ;
            s2 = m;
        }
    }

    cout<<s2<<endl;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
#include <tuple>
#include <fstream>
using namespace std;

#define FORN(i,m,n) for(int i=(m); i<int(n); ++i)
#define PRINTARR(a,n) FORN(i,0,n) cout<<a[i]<<" "; cout<<endl
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}

typedef long long ll;
const int ms = 50;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n; cin>>n;
  ll ans = 0;
  FORN(i,0,n){
    ll a, b;
    cin>>a>>b;
    ans += ((b - a + 1) * (a + b)) >> 1;
  }
  cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int main()
{
	int T;
	scanf("%d", &T);
	for(int cas = 1; cas <= T; ++cas)
	{
		int n;
		scanf("%d", &n);
		for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
		if(n & 1) puts("Second");
		else
		{
			sort(a + 1, a + n + 1);
			bool flag = 0;
			for(int i = 2; i <= n; i += 2)
				if(a[i] != a[i - 1])
				{
					flag = 1;
					break;
				}
			if(flag) puts("First");
			else puts("Second");
		}
	}
	return 0;
}

//Shinchan Loves Coding :))
#include<bits/stdc++.h>

using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);
#define double long double
#define int long long int
#define en "\n"
#define fi first
#define se second
#define PB push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define rep(i,x,y) for(int i=x ; i<y ; i++)
#define erep(i,x,y) for(int i=x ; i<=y ; i++)
#define erepr(i,x,y) for(int i=x ; i>=y ; i--)
#define repr(i,x,y) for(int i=x ; i>y ; i--)

typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> pii;

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

const int no=3e6+5,modulo=1e9+7,inf=1e18,N=2e3+1;
const double PI = 3.1415926535897932384;
int ar[no] ,br[no],cr[no];//,dr[no],er[no];
int used[no];
//int color[no];
//pii adj[no];
vi adj[no] ;
//LOWER_BOUND(n) - FIRST ELEMENT GREATER THAN EQUAL TO n
//UPPER_BOUND(n) - FIRST ELEMENT GREATER THAN n

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

int mark[no];
vi ans;

void dfs(int node) {
    used[node]=1;
    if(!mark[ar[node]]) ans.PB(node);
    mark[ar[node]]++;
    for(int child : adj[node]) {
        if(!used[child]) {
            dfs(child);
        }
    }
    mark[ar[node]]--;
}

void solve () {
    int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0,w=0,k=0;
    cin>>n;
    rep(i,1,n+1) cin>>ar[i];
    m=n-1;
    rep(i,0,m) {
        cin>>x>>y;
        adj[x].PB(y);
        adj[y].PB(x);
    }
    dfs(1);
    sort(all(ans));
    for(auto ii : ans) cout<<ii<<en;
}

inline void runn() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

signed main() {
    night_rider
    runn();
    int t=1;
    cout<<fixed<<setprecision(15);
  //  cin>>t;
    rep(i,1,t+1) {
       // cout << "Case #" << i << ": ";
        solve();
    }
}


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
// #include <atcoder/all>
// #include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;
// using namespace atcoder;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> p32;
typedef pair<ll, ll> p64;
typedef pair<p64, p64> pp64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<char>> vvc64;

typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln '\n'
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define f first
#define s second

#define INF 2e18
#define fast_cin()                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zero ll(0)
#define set_bits(x) __builtin_popcountll(x)
#define pp pair<ll, p64>
#define pc pair<int, char>
ll mpow(ll a, ll b)
{
    if (a == 0)
        return 0;
    if (b == 0)
        return 1;
    ll t1 = mpow(a, b / 2);
    t1 *= t1;
    t1 %= MOD;
    if (b % 2)
        t1 *= a;
    t1 %= MOD;
    return t1;
}
ll mpow(ll a, ll b, ll p)
{
    if (a == 0)
        return 0;
    if (b == 0)
        return 1;
    ll t1 = mpow(a, b / 2, p);
    t1 *= t1;
    t1 %= p;
    if (b % 2)
        t1 *= a;
    t1 %= p;
    return t1;
}

void norm(ll &n)
{
    n %= MOD;
    n += MOD;
    n %= MOD;
}

void dfs(int n, vv64 &adj, v64 &visited, int &count, int &m)
{
    visited[n] = 1;
    count++;
    for (int i = 0; i < sz(adj[n]); i++)
    {
        m++;
        int c = adj[n][i];
        if (visited[c] == 0)
            dfs(c, adj, visited, count, m);
    }
}
void solve(ll t)
{
    int n;
    cin >> n;
    int m = 4e6;
    vv64 adj(m + 1);
    for (int i = 1; i <= n; i++)
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    v64 visited(m + 1, 0);
    ll ans = 0;
    for (int i = 1; i <= m; i++)
    {
        if (visited[i] == 0)
        {
            int count = 0, edges = 0;
            dfs(i, adj, visited, count, edges);
            edges /= 2;
            ans += count;
            if (edges < count)
                ans--;
        }
    }
    cout << ans << endl;
}
int main()
{

    fast_cin();
    ll t = 1;
    // cin >> t;
    forn(i, t)
    {
        solve(i + 1);
    }
}

#include<bits/stdc++.h>

using namespace std;

const int maxN = 1e6 + 100;
int N, M, t[maxN], x[maxN], y[maxN], sz[maxN], vol[maxN];

int tata (int nod)
{
    if (t[nod] == nod) return nod;
    return t[nod] = tata (t[nod]);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &M);
for (int i=1; i<=M; i++)
    scanf ("%d %d", &x[i], &y[i]),
    N = max (N, max (x[i], y[i]));
for (int i=1; i<=N; i++)
    t[i] = i, vol[i] = 0, sz[i] = 1;
for (int i=1; i<=M; i++)
{
    int a = tata (x[i]), b = tata (y[i]);
    if (a == b) vol[a] ++;
    else vol[a] += vol[b] + 1, sz[a] += sz[b], t[b] = a;
}
int ans = 0;
for (int i=1; i<=N; i++)
    if (tata (i) == i)
        ans += min (sz[i], vol[i]);
printf ("%d\n", ans);
return 0;
}


#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
using ll = long long;
const int INT_INF = numeric_limits<int>::max();
const long long LL_INF = numeric_limits<long long>::max();

int main() {
  double A, B;
  cin >> A >> B;
  double C = 1 - B / A;
  cout << C * 100 << endl;
  return 0;
}

#include <iostream>

using namespace std;

int main() {

  long s,p;
  cin>>s>>p;

  for(int i=1; i<=1000000; i++){
    if(p%i==0&&i+p/i==s){
      cout<<"Yes\n";
      return 0;
    }
  }

  cout<<"No\n";
}


#include <algorithm>
#include <iomanip>
#include <iostream>
using ld = long double;

int main() {
  std::cout << std::fixed << std::setprecision(16);
  int N;
  ld D, H, res = -1.0;
  std::cin >> N >> D >> H;

  ld d, h, y;
  for (int i = 0; i < N; i++) {
    std::cin >> d >> h;
    y = ((h - H) * (-1 * D)) / (d - D);
    y+=H;
    // std::cout << y << '\n';
    res = std::max(res, y);
  }
  ld t = 0.00;
  res = std::max(res, t);
  std::cout << res << '\n';
}

#include<bits/stdc++.h>

typedef long long int lli;
typedef long double lld;
typedef long long ll;

//Fast Input I/O
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL);
//Datatype
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vvlli vector<vector<long long int>>
#define ppi pair<int, int>
#define rppi pair<int, pair<int, int>>
#define lppi pair<pair<int, int>, int>
#define vppi vector<pair<int, int>>
#define sppi stack<pair<int int>>
#define qppi queue<pair<int, int>>
//function
#define f first
#define s second
#define pb(x) push_back(x)
#define mkp(i, j) make_pair(i, j)
#define lmkp(i,j,k) make_pair(make_pair(i,j),k)
#define rmkp(i,j,k) make_pair(i,make_pair(j,k))
//loop
#define loop(i,n) for (i = 0; i < n; ++i)
#define loops(i,k,n) for (i = k; i <= n; ++i)
#define looprev(i,k,n) for (i = k; i >= n; --i)
//Const
#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//Print
#define prd(n) printf("%d", n)
#define prl(n) printf("%lld", n)
#define prdn(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define prf(n) printf("%f", n)
//Scan
#define scd(n) scanf("%d", &n)
#define scd2(a, b) scanf("%d %d", &a, &b)
#define scd3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scl(n) scanf("%lld", &n)
#define scl2(a, b) scanf("%lld %lld", &a, &b)
#define scl3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define scf(n) scanf("%f", &n)
#define all(x) (x).begin(), (x).end()

using namespace std;
void online_judge() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

void solve() {
	lli i, j, k;
	lld N, D, H, res = 0;
	cin >> N >> D >> H;
	loop(i, N) {
		lld d, h;
		cin >> d >> h;
		lld x = H - ((H - h) * D) / (D - d);
		res = max(res, x);
	}
	cout << res << "\n";
}

int main() {
	fio;
	online_judge();
	cout << fixed << setprecision(20);
	lli t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b;
    cin>>c>>d;
    int maks = -999999;
    for(int i=a;i<=b;i++){
        for(int j=c;j<=d;j++){
            maks = max(maks,i-j);
        }
    }cout<<maks<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int result= b-c;
    cout<< result <<endl;
    return 0;

}


#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12
//priority_queue<int,vector<int>, greater<int> > q2;

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

	int N; cin >> N;
	int ans = INF;
	REP(i, N) {
		int a, p, x; cin >> a >> p >> x;
		x -= a;
		if (x > 0)chmin(ans, p);
	}
	if (ans == INF)ans = -1;
	cout << ans << endl;

	return 0;
}

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

using namespace std;

struct DataA {
    int a;
    char b;
};

template<typename T> void vMap(vector<T>& dst, vector<T>& src, function<T(T)> callback) {
    transform(src.begin(), src.end(), dst.begin(), callback);
}

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if (B >= C * D) {
        cout << -1 << endl;
        return 0;
    }

    int i = 0;
    int diff = C * D - B;
    while (true) {
        i++;
        A -= diff;

        if (A <= 0) {
            cout << i << endl;
            break;
        }
    }
}


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

using lli = long long int;
using ii = pair<int, lli>;

const int MAXN = 2e5;
const lli MOD = 1e9+7;

int n;
vector<ii> adj[MAXN+1];

lli rootXor[MAXN+1];
void dfs(int u, int p, lli x) {
    rootXor[u] = x;

    for(ii v: adj[u]) {
        if(v.first == p) {
            continue;
        }

        dfs(v.first, u, x ^ v.second);
    }
}

lli safeMult(lli a, lli b) {
    if(!b) {
        return 0;
    }

    if(b%2) {
        return (safeMult(a, b-1) + a) % MOD;
    }
    else {
        lli aux = safeMult(a, b/2);
        return (aux + aux) % MOD;
    }
}

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

    for(int i=0; i<n-1; i++) {
        int u, v;
        lli w;
        scanf("%d %d %lld", &u, &v, &w);

        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }

    dfs(1, 1, 0);

    vector<lli> ones(60, 0);

    lli ans = 0;
    for(int i=1; i<=n; i++) {
        lli cand = 0;
        for(int j=0; j<60; j++) {
            lli zeroes = (i-1)-ones[j];
            if(rootXor[i]&(lli(1) << j)) {
                cand += safeMult(lli(1) << j, zeroes);
            }
            else {
                cand += safeMult(lli(1) << j, ones[j]);
            }
            cand = cand % MOD;
        }
        ans = (ans + cand) % MOD;

        for(int j=0; j<60; j++) {
            if(rootXor[i]&(lli(1) << j)) {
                ones[j]++;
            }
        }
    }
    printf("%lld\n", ans);
}


// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;
using i128 = __int128_t;
using u128 = __uint128_t;
using u64 = uint64_t;

//define
#define int long long
#define ll int
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()
#define itn int
#define sz(x) (int)x.size()

//typedef
typedef unsigned long long ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< std::vector<int> > vvi;
typedef std::vector< std::pair < pii, int > > vpp;

const long long MOD = 1000000007;
// const long long MOD = 998244353;
const long double PI = 3.141592653589793238;
const long long pi = 31415926;
const long long inf = 1000000000000000000;
const long long small_inf = INT_MAX;

int modpow(int x, int n, int mod = MOD){ int res=1; while(n>0){ if(n&1) res=res*x%mod; x=x*x%MOD; n>>=1;} return res;}
int power(int x, int n){ int res=1; while(n>0){ if(n&1) res=res*x; x=x*x; n>>=1; } return res;}

void init(){
}

int find(int a, int b, vi *v){
    int n1 = sz(v[a]), n2 = sz(v[b]);
    int x = 0;
    int mn = inf;
    repu(y,0,n2-1){
        while(x<n1-1 && v[a][x]<v[b][y])
            x++;
        mn = min(mn,abs(v[a][x]-v[b][y]));
        if(x)
            mn = min(mn,abs(v[a][x-1]-v[b][y]));
    }
    return mn;
}

void solve()
{
/*Don't hurry, nothing good comes if you rush*/
    int n;
    cin>>n;
    vi cnt(3,0);
    map<char, int> mm;
    mm['R'] = 0;
    mm['G'] = 1;
    mm['B'] = 2;
    vector<char> c(2*n+1,0);
    vi v[3];
    repu(i,1,2*n){
        int tmp;
        cin>>tmp>>c[i];
        cnt[mm[c[i]]]++;
        v[mm[c[i]]].pb(tmp);
    }
    int odd = 0, f=-1, a=-1, b=-1;
    rep(i,3){
        sort(all(v[i]));
        if(cnt[i]%2){
            if(a==-1)
                a=i;
            else
                b=i;
            odd++;
        }
        else
            f = i;
    }
    if(odd==0){
        cout<<0<<endl;
        return;
    }
    if(cnt[f]==0){
        cout<<find(a,b,v)<<endl;
        return;
    }
    cout<<min(find(a,f,v)+find(b,f,v), find(a,b,v))<<endl;
}

signed main(){
    // #ifndef ONLINE_JUDGE
    //    freopen("./input.txt", "r", stdin);
    //    freopen("./output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t23 = 1, tt23 = 1;
    // cin>>t23;
    init();
    while(tt23<=t23)
    {
        // cout<<"Case #"<<tt23<<": ";
        solve();
        tt23++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll LINF = 1001001001001001001;
#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;
	n *= 2;
	vector<ll> a(n);
	vector<string> c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> c[i];
	}
	vector<vector<ll>> v(3);
	for (int i = 0; i < n; i++) {
		int p;
		if (c[i] == "R") {
			p = 0;
		} else if (c[i] == "G") {
			p = 1;
		} else {
			p = 2;
		}
		v[p].push_back(a[i]);
	}
	vector<int> t;
	for (int i = 0; i < 3; i++) {
		if (v[i].size() & 1) {
			t.push_back(i);
		}
	}
	ll ans = LINF;
	if (t.size() == 2) {
		sort(v[t[1]].begin(), v[t[1]].end());
		for (int i = 0; i < v[t[0]].size(); i++) {
			int l = -1, r = v[t[1]].size(), m;
			while (abs(l - r) > 1) {
				m = (l + r) / 2;
				if (v[t[1]][m] <= v[t[0]][i]) {
					l = m;
				} else {
					r = m;
				}
			}
			if (l >= 0) ans = min(ans, abs(v[t[1]][l] - v[t[0]][i]));
			if (l + 1 < v[t[1]].size()) ans = min(ans, abs(v[t[1]][l + 1] - v[t[0]][i]));
		}
		t.push_back(3 - t[0] - t[1]);
		if (v[t[2]].size() != 0) {
			sort(v[t[2]].begin(), v[t[2]].end());
			ll tans = 0;
			for (int d = 0; d < 2; d++) {
				ll tvans = LINF;
				for (int i = 0; i < v[t[d]].size(); i++) {
					int l = -1, r = v[t[2]].size(), m;
					while (abs(l - r) > 1) {
						m = (l + r) / 2;
						if (v[t[2]][m] <= v[t[d]][i]) {
							l = m;
						} else {
							r = m;
						}
					}
					if (l >= 0) tvans = min(tvans, abs(v[t[2]][l] - v[t[d]][i]));
					if (l + 1 < v[t[2]].size()) tvans = min(tvans, abs(v[t[2]][l + 1] - v[t[d]][i]));
				}
				tans += tvans;
			}
			ans = min(ans, tans);
		}
	} else {
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  pair<int, int> p = {A, B};
  string ans;
  string next = C == 0 ? "A" : "B";

  while (true) {
    if (next == "A") {
      if (p.first < 0) {
        ans = "Aoki";
        break;
      }
      p.first--;
      next = "B";
    } else {
      if (p.second < 0) {
        ans = "Takahashi";
        break;
      }
      p.second--;
      next = "A";
    }
  }
  cout << ans << endl;
}

#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string S[3];
	cin >> S[0] >> S[1] >> S[2];
	set<char> st;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < S[i].size(); j++)st.insert(S[i][j]);
	}
	if (st.size() > 10) {
		cout << "UNSOLVABLE" << endl;
		return 0;
	}

	map<char, int> mp;
	int tmp = 0;
	for (auto&& x : st) {
		mp[x] = tmp;
		tmp++;
	}

	vector<int> a = { 0,1,2,3,4,5,6,7,8,9 };
	do {
		if (a[mp[S[0][0]]] == 0 || a[mp[S[1][0]]] == 0 || a[mp[S[2][0]]] == 0)continue;
		string N[3];
		for (int i = 0; i < 3; i++) {
			N[i] = S[i];
			for (int j = 0; j < N[i].size(); j++) {
				N[i][j] = a[mp[N[i][j]]] + '0';
			}
		}
		ll n[3];
		for (int i = 0; i < 3; i++)n[i] = stoll(N[i]);
		if (n[0] + n[1] == n[2]) {
			cout << N[0] << endl << N[1] << endl << N[2] << endl;
			return 0;
		}

	} while (next_permutation(a.begin(), a.end()));

	cout << "UNSOLVABLE" << endl;
}


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

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

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

	int N, M, K;
	cin >> N >> M >> K;
	int A[200200] = {};
	rep(i, K) {
		int a;
		cin >> a;
		A[a] = 1;
	}

	double L = 0, R = 1e18;
	double dp[200200] = {};
	rep(i, 100) {
		double m = (L + R) / 2;

		double kari = 0;
		for (int i = N - 1; i >= 0; i--) {
			if (A[i] == 0) dp[i] = kari + 1;
			else dp[i] = m;
			kari += dp[i] / M;
			kari -= dp[i + M] / M;
		}

		if (dp[0] >= m) L = m;
		else R = m;
	}

	if (L > 1e17) {
		co(-1);
	}
	else {
		cout << setprecision(12) << L << endl;
	}
	Would you please return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long double ldb;
#define pb push_back
const int N = 1500005;
struct pldld
{
    ldb x,y;
    friend pldld operator + (const pldld x,const ldb y)
    {
        return {x.x,x.y+y};
    }
    friend pldld operator + (const pldld x,const pldld y)
    {
        return {x.x+y.x,x.y+y.y};
    }
    friend pldld operator - (const pldld x,const pldld y)
    {
        return {x.x-y.x,x.y-y.y};
    }
    friend pldld operator / (const pldld x,const ldb y)
    {
        return {x.x/y,x.y/y};
    }
}dp[N],s[N];
int a[N],flag[N];
int n,m,k;
int main()
{
    cin>>n>>m>>k;
    for (int i=1;i<=k;++i) cin>>a[i],flag[a[i]]=1;
    for (int i=n-1;i>=0;--i)
    {
        if (flag[i]) dp[i]={1,0};else
        {
            dp[i]=((s[i+1]-s[i+m+1])/m)+1;
        }
        s[i]=s[i+1]+dp[i];
    }
    if ((1-dp[0].x)<1e-9) {puts("-1");return 0;};
    ldb ans=dp[0].y/(-dp[0].x+1);
    printf("%.10f\n",(double)ans);
    return 0;
}


// Problem: E - Spread of Information
// Contest: AtCoder - AtCoder Regular Contest 116
// URL: https://atcoder.jp/contests/arc116/tasks/arc116_e
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)

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

inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}

const int N=5e5+5;

int n,m,cnt,f[N],g[N],is[N],head[N],ans,gs;

struct nood
{
	int nex,to;
};
nood e[N*2];

inline void jia(int u,int v)
{
	e[++cnt].nex=head[u];
	head[u]=cnt;
	e[cnt].to=v;
}

inline void dfs(int u,int fa,int x)
{
	f[u]=1e9;
	g[u]=-1e9;
	for ( int i=head[u];i;i=e[i].nex )
	{
		int v=e[i].to;
		if(v==fa) continue;
		dfs(v,u,x);
		f[u]=min(f[v]+1,f[u]);
		g[u]=max(g[v]+1,g[u]);
	}
	if(is[u]&&f[u]>x) g[u]=max(g[u],0);
	if(g[u]+f[u]<=x) g[u]=-1e9;
	if(g[u]==x)
		gs++,g[u]=-1e9,f[u]=0;
}

inline bool check(int mid)
{
	gs=0;
	dfs(1,0,mid);
	gs+=(g[1]>=0);
	return gs<=m;
}

int main()
{
	n=read();
	m=read();
	for ( int i=1;i<=n;i++ )
		is[i]=1;
	for ( int i=1;i<n;i++ )
	{
		int x,y;
		x=read(),y=read();
		jia(x,y);
		jia(y,x);
	}
	int l=0,r=n;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))
		{
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}

//================code===================//

//#define TLE

#ifdef TLE
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#endif

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <ctime>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL unsigned long long
#define ld long double
#define fa(i,a,b) for(LL i=(a);i<(LL)(b);++i)
#define fd(i,a,b) for(LL i=(a);i>(LL)(b);--i)
#define setp pair<pair<int,int>,int>
#define setl pair<LL,LL>
#define micro 0.000001

using namespace std;

//LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }
//LL lcm(LL a, LL b) { return (a * b) / gcd(a, b); }
#ifdef OHSOLUTION
#define ce(t) cerr<<t
#define AT cerr << "\n=================ANS=================\n"
#define AE cerr << "\n=====================================\n"
#define DB(a) cerr << __LINE__ << ": " << #a << " = " << (a) << endl;
#else
#define AT
#define AE
#define ce(t)
#define __popcnt64 __builtin_popcountll
#define __popcnt __builtin_popcount
#endif

pair <int, int> vu[9] = { {0,1},{1,0},{0,-1} ,{-1,0},{0,0},{1,0}, {-1,1} , {1,-1},{-1,-1} }; //RDLU EWSN

template<typename T, typename U> void ckmax(T& a, U b) { a = a < b ? b : a; }
template<typename T, typename U> void ckmin(T& a, U b) { a = a > b ? b : a; }
struct gcmp { bool operator()(LL a, LL b) { return a < b; } bool operator()(setl a, setl b) { return a.second < b.second; } };
struct lcmp { bool operator()(LL a, LL b) { return a > b; } bool operator()(setl a, setl b) { return a.second > b.second; } };

const int max_v = 2e5 + 7;
const int INF = 1e9 + 7;
const LL LNF = (LL)5e18 + 7ll;
const LL mod = 998244353;

vector <int> adj[max_v];
struct node
{
    int cn,sl,mr;
};

node dfs(int idx,int dist,int par = -1)
{
    if (~par && adj[idx].size() == 1) return { 0,INF,0 };
    node ret = { 0,INF,-INF};

    for (auto& x : adj[idx]) if (x != par)
    {
         node tmp = dfs(x, dist, idx);
         ret.cn += tmp.cn;
         ckmin(ret.sl, tmp.sl+1);
         ckmax(ret.mr, tmp.mr+1);
    }

    //if (ret.mr == -INF) ret.mr = 0;

    if (ret.sl == INF)
    {
        if (ret.mr >= dist)
        {
            ret.sl = 0;
            ret.mr = -INF;
            ++ret.cn;
        }
    }
    else
    {
        if (ret.sl == 2 * dist + 1 || ret.mr>=dist)
        {
            ++ret.cn;
            ret.sl = 0;
            ret.mr = -INF;
        }
        else if (ret.sl > dist)
        {
            ckmax(ret.mr, ret.sl - dist - 1);
        }
        else if(ret.sl+ret.mr <=dist)
        {
            ret.mr = -INF;
        }
    }

    if (par == -1 && ret.mr!=-INF)
    {
        ++ret.cn;
    }

    return ret;
}

int main()
{
#ifdef OHSOLUTION
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k; ci(n >> k);

    vector <setl> test;

    fa(i, 0, n - 1)
    {
        int x, y; ci(x >> y); --x, --y;
        adj[x].push_back(y); adj[y].push_back(x);
        if (x > y) swap(x, y);
        test.push_back({ x,y });
    }

    if (n == k)
    {
        co(0);
        return 0;
    }

    int l = 1;
    int r = n;

    while (l != r)
    {
        int mid = l + r >> 1;
        if (dfs(0,mid).cn <= k) r = mid;
        else l = mid + 1;
    }
    co(l << "\n");

    return 0;
}


#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  if(N%2==0) cout<<"White";
  else cout<<"Black";
}

#include<bits/stdc++.h>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_2 499122177
#define INF 1000000000
#define PI 3.14159265358979323846

using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int m, h;
	cin >> m >> h;
	if(h%m == 0)
		cout << "Yes\n";
	else
		cout << "No\n";
}
//size


#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 bm = 200001;
int BIT[bm];
void add(int A) {
	while (A > 0) {
		BIT[A]++;
		A -= A & -A;
	}
}
int query(int A) {
	int ret = 0;
	while (A <= bm) {
		ret += BIT[A];
		A += A & -A;
	}
	return ret;
}
ll A[200001], B[200001], tmp[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}
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 main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N = getint();
	rep1(i, N) A[i] = ll(i) << 32 | i + getint();
	rep1(i, N) B[i] = ll(i) << 32 | i + getint();

	pakuri_sort(N, A + 1);
	pakuri_sort(N, B + 1);

	rep1(i, N) {
		if ((A[i] ^ B[i]) & (1ll << 32) - 1) {
			co(-1);
			return 0;
		}
		tmp[A[i] >> 32] = B[i] >> 32;
	}
	ll kotae = 0;
	rep1(i, N) {
		kotae += query(tmp[i]);
		add(tmp[i]);
	}
	co(kotae);

	Would you please return 0;
}

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

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

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

void solve(long long N, std::vector<long long> X){
    set<int> all;
    vector<vector<int>> v(N, vector<int>(50));
    rep(i, N) {
        ll x = X[i];
        set<int> primes;
        for (ll j = 2; j <= x; j++) {
            while (x % j == 0) {
                primes.insert(j);
                x /= j;
            }
        }
        for (int p: primes) {
            all.insert(p);
            v[i][p] = 1;
        }
    }
    vector<int> al;
    for (auto a: all) {
        al.push_back(a);
    }
    int s = al.size();
    ll ans = 1001001001001001001;
    for (int b = 0; b < (1 << s); b++) {
        vector<int> seen(N, 0);
        ll tmp = 1;
        rep(i, N) {
            for (int bi = 0; bi < s; bi++) {
                if ((b >> bi) & 1) {
                    if (v[i][al[bi]] == 1) {
                        seen[i] = 1;
                        break;
                    }
                }
            }
        }
        int cnt = 0;
        for (auto e: seen) {
            cnt += e;
        }
        if (cnt == N) {
            for (int bi = 0; bi < s; bi++) {
                if ((b >> bi) & 1) {
                    tmp *= al[bi];
                }
            }
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define fe(x)                   (*(x.begin()))
#define le(x)                   (*(x.rbegin()))
#define pb                      push_back
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x,id)               (*(x.find_by_order(id)))
#define ook(y)                  order_of_key(y)
#define all(x)                  (x).begin(),(x).end()
#define si(a)                   scanf("%d",&a)
#define sii(a,b)                scanf("%d %d",&a,&b)
#define siii(a,b,c)             scanf("%d %d %d",&a,&b,&c)
#define sl(a)                   scanf("%lld",&a)
#define sll(a,b)                scanf("%lld %lld",&a,&b)
#define slll(a,b,c)             scanf("%lld %lld %lld",&a,&b,&c)
#define rep(i,a,b)              for(ll i = a; i<=b;  i++)
#define un(x)                   x.erase(unique(all(x)), x.end())
#define TT                      long long TC;  scanf("%lld",&TC);  for(ll tc = 1; tc<=TC; tc++)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
#define assign(v,n,x)           v.clear(); for(int I = 0; I<n; I++)    v.pb(x);
#define SZ(x)                   (int)x.size()
#define ff                      first
#define ss                      second
#define FF                      fflush(stdout);
#define ms(AR,x)                memset(AR,x,sizeof AR);
#define case                    printf("Case %lld: ",tc);
using                           namespace __gnu_pbds;
using                           namespace std;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;

#define mx 200003

ll ara[mx];

map<char,vector<ll> > ar;

main(){
//read;

int n;
si(n);

for(int i = 0; i<2*n; i++){
    ll x;
    sl(x);
    char c;
    cin>>c;
    ar[c].pb(x);
}

ll ans = 0;
vector<char> v;
char d;

for(auto i:ar){
    if( SZ(i.ss)%2 )  v.pb(i.ff),ans = 9e18;
    else d = i.ff;
}

for(char X:{'R','G','B'})
    sort(all(ar[X]));

if(SZ(v)){
    for(ll i:ar[v[0]]){
        int id = lb( all(ar[v[1]]),i ) - ar[v[1]].begin();
        id = min( id,SZ(ar[v[1]]) - 1 );
        int id2 = id - 1;
        id2 = max(0,id2);
        ll x = ar[v[1]][id],y = ar[v[1]][id2];
        ans = min( { ans, abs(i-x) , abs(i-y) } );
    }
    if(SZ(ar[d])){
        ll tmp[mx];
        set<pll> st;
        for(ll i = 0; i<SZ(ar[d]); i++){
            ll x = ar[d][i];
            int id = lb( all(ar[v[1]]), x ) - ar[v[1]].begin();
            id = min( id,SZ(ar[v[1]]) - 1 );
            int id2 = id - 1;
            id2 = max(0,id2);
            ll p = min( abs(x - ar[v[1]][id] ) , abs( x - ar[v[1]][id2]) );
            tmp[i] = p;
            st.insert(pll(p,i));
        }

        for(ll i = 0; i<SZ(ar[d]); i++){
            pll u = pll(tmp[i],i);
            st.erase(u);
            ara[i] = fe(st).ff;
            st.insert(u);
        }

        for(ll i = 0; i<SZ(ar[d]); i++){
            ll x = ar[d][i],y,z;
            int id = lb(all(ar[v[0]]),x) - ar[v[0]].begin();
            id = min( id, SZ(ar[v[0]]) - 1);
            int id2 = id - 1;
            id2 = max(0,id2);
            y = ar[v[0]][id];
            z = ar[v[0]][id2];
            ll p = min( abs(x - y), abs(x - z) );
            ans = min(ans, p + ara[i]);
        }
    }
}

cout<<ans;

return 0;
}


//インクルード(アルファベット順)
#ifndef TEMPLATE
#define TEMPLATE
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<ctime>
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
#include<cstdint>
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;

#endif // TEMPLATE

int main(){
    ll N;
    cin >> N;
    vector<string> S(N);
    vector<ll> T(N);
    REP(i,N){
        cin >> S[i] >> T[i];
    }
    ll max=0,maxi=-1;
    ll smax=0,smaxi=-1;
    if(T[0]>T[1]){
        max=T[0];
        maxi=0;
        smax=T[1];
        smaxi=1;
    }else{
        max=T[1];
        maxi=1;
        smax=T[0];
        smaxi=0;
    }
    for(int i=2;i<N;i++){
        if(T[i]>max){
            smax =max;
            smaxi = maxi;
            max = T[i];
            maxi=i;
        }else if(T[i]>smax){
            smax=T[i];
            smaxi=i;
        }
    }

    cout << S[smaxi] << endl;
    return 0;
}

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

#define ff              first
#define ss              second
#define pb              push_back
#define ppb             pop_back
#define int             long long
#define mp              make_pair
#define all(x)             (x).begin(), (x).end()
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define mod1            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)        substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x)         cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

#ifndef ONLINE_JUDGE
#define dbg(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define dbg(x)
#endif

void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(double t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]"<<endl;}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

int gcd(int a, int b){if (b == 0)return a;return gcd(b, a % b);}
int lcm(int a, int b){return (a / gcd(a, b)) * b;}
int power(int x, unsigned int y, int p){int res = 1;x = x % p;if (x == 0) return 0;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
int mod_inverse(int a, int p){return power(a, p - 2, p);}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
int mod_add(int a, int b, int m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
int mod_mul(int a, int b, int m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
int mod_sub(int a, int b, int m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
int mod_div(int a, int b, int m) {a = a % m; b = b % m; return (mod_mul(a, mod_inverse(b,m), m) + m) % m;}  //only for prime m
int modfact(int n, int p){if (p <= n)return 0;int res = (p - 1);for (int i = n + 1; i < p; i++)res = (res * mod_inverse(i, p)) % p;return res;}
int fact(int n){if (n == 0)return 1;return n * fact(n - 1);}

void solve(){
    int n;
    cin>>n;
    vector<pair<int,string>> v(n);

    for(int i=0;i<n;i++){
        cin>>v[i].ss>>v[i].ff;
    }
    sort(all(v));
    cout<<v[n-2].ss<<endl;

}

int32_t main(){
    FIO;
    #ifndef ONLINE_JUDGE
    freopen("Error.txt", "w", stderr);
    #endif

    auto start1 = high_resolution_clock::now();
    //w(t)
    solve();
    auto stop1 = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop1 - start1);

    #ifndef ONLINE_JUDGE
    cerr << "Time: " << duration . count() / 1000 << " ms" <<endl;
    #endif
    return 0;
}


#line 1 "/home/siro53/kyo-pro/compro_library/template/template.cpp"
#include <bits/stdc++.h>
using namespace std;
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;
}
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define FOR(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------
#line 2 "d.cpp"

int H, W, A, B;
ll ans;

void dfs(int i, int mask, int a, int b) {
    if(i == H * W) {
        ans++; return;
    }
    if(mask >> i & 1) {
        dfs(i+1, mask, a, b);
        return;
    }
    if(a > 0) {
        if(i % W < W-1 and (mask >> (i+1) & 1) == 0) {
            dfs(i+1, mask | (1 << i) | (1 << (i+1)), a-1, b);
        }
        if(i / W < H-1 and (mask >> (i+W) & 1) == 0) {
            dfs(i+1, mask | (1 << i) | (1 << (i+W)), a-1, b);
        }
    }
    if(b > 0) {
        dfs(i+1, mask | (1 << i), a, b-1);
    }
}

int main() {
    cin >> H >> W >> A >> B;
    ans = 0;

    dfs(0, 0, A, B);

    cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef long double db;
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (int)r;}
template <class T>inline void sary(T st, T nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
int mod=998244353;
inline ll mul(ll a, ll b){return ((a%mod)*(b%mod))%mod;}
inline ll add(ll a, ll b){return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a, ll b){return ((a%mod)-(b%mod)+mod)%mod;}
inline ll divi(ll a, ll b) { return (500000004*(a%mod))%mod; }
const int N= 5002;

void solve() {
  int n; cin>>n;
  vii v(n);
  rep(i,n) cin>>v[i].fi>>v[i].se;
  int s=0;
  rep(i,n) s+=v[i].fi;
  vi a(n);
  rep(i,n) a[i]=2*v[i].fi+v[i].se;
  sort(all(a),greater<int>());
  int t=-s;
  rep(i,n) {
    t+=a[i];
    if(t>0) {
        cout<<i+1; return;
    }
  }
}

int32_t main() {
  IOS
  int t=1;
  //cin>>t;
  #ifndef ONLINE_JUDGE
    clock_t clk = clock();
    #endif
  while(t--) solve();
  #ifndef ONLINE_JUDGE
  cerr << "\nTime (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
  #endif
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#define sz(x) ((int)(x).size())
#define mp make_pair
#define full(a) a.begin(), a.end()
#define pii pair<int, int>
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 3e5 + 5;

// printf("%.2f\n", value); digits after decimal
// 'a' - 97
// 'A' - 65

ll binpow(ll a, ll b)
{
    a %= mod;
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); //cout.tie(NULL);
    int h, w; cin >> h >> w;
    ll tidy = 0;
    vector<vector<char>> v(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> v[i][j];
            if (v[i][j] == '.') tidy++;
        }
    }
    ll all = binpow(2, tidy);
    ll c = 0;
    ll cnt_row = -1;
    vector<ll> col(w, -1);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (v[i][j] == '#')
            {
                cnt_row = -1;
                col[j] = -1;
                continue;
            }
            if (cnt_row == -1)
            {
                cnt_row++;
                for (int k = j; k < w; k++)
                {
                    if (v[i][k] == '#') break;
                    cnt_row++;
                }
            }
            if (col[j] == -1)
            {
                col[j]++;
                for (int k = i; k < h; k++)
                {
                    if (v[k][j] == '#') break;
                    col[j]++;
                }
            }
            ll num = cnt_row + col[j];
            num--;
            c += (all + mod - binpow(2, tidy - num));
            c %= mod;
        }
        cnt_row = -1;
    }
    cout << c;
    return 0;
}


#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 2147483647
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
//#define mod 998244353
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define pi acos(-1.0)
#define me memset
// /#define bit(n,k) ((n>>k)&1)
#define lg length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se<b.fi.se;
}
ll cmp2(pair<ll,ll> a,pair<ll,ll> b){
    if(a.fi!=b.fi)
        return  a.fi<b.fi;
    else
        return a.se<b.se;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(int argc, char * argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    //ll begin_t=clock();
    //freopen("big.txt", "r", stdin);
    //freopen("out3.txt", "w", stdout);
    //------------------------------
    ll h,w,x,y;cin>>h>>w>>x>>y;
    x--;y--;
    char s[110][110];
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    ll ans = 1;

    for(ll i=x+1;i<h;i++){
        if(s[i][y]=='#')break;
        ans++;
    }
    for(ll i=x-1;i>=0;i--){
        //cout<<i<<endl;
        if(s[i][y]=='#')break;
        ans++;
    }
    for(ll i=y-1;i>=0;i--){
        //cout<<i<<endl;
        if(s[x][i]=='#')break;
        ans++;
    }
    for(ll i=y+1;i<w;i++){
        if(s[x][i]=='#')break;
        ans++;
    }
    cout<<ans<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

#include<bits/stdc++.h>
#define db double
#define reg register
#define LL long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ull unsigned long long
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
#define erep(i,a) for(int i=head[a];i;i=e[i].nxt)

using namespace std;
bool Handsome;
inline void Mi(int &x,int y){if(x>y && (x=y));}
inline void Mx(int &x,int y){if(x<y && (x=y));}
const int M=1005;
int n,m,ans=1e9;
bool vis[M][M];
vector<int> g[M][30];
struct node{int a,b,st;}tmp;
queue<node> q;
bool Most;
int main(){
//	printf("%.2lfMB\n",(&Most-&Handsome)/1024.0/1024.0);
	scanf("%d%d",&n,&m);
	rep(i,1,m){
		int a,b;char c;
		scanf("%d %d %c",&a,&b,&c);
		g[a][c-'a'].pb(b);
		g[b][c-'a'].pb(a);
	}
	vis[1][n]=1;
	q.push((node){1,n,0});
	while(!q.empty()){
		tmp=q.front();q.pop();
		int a=tmp.a,b=tmp.b,st=tmp.st;
		if(st>=ans)break;
		if(a==b){Mi(ans,st);continue;}
		rep(p,0,25){
			rep(i,0,g[a][p].size()-1)
				if(g[a][p][i]==b)Mi(ans,st+1);
			rep(i,0,g[b][p].size()-1)
				if(g[b][p][i]==a)Mi(ans,st+1);
			rep(i,0,g[a][p].size()-1){
				int u=g[a][p][i];
				rep(j,0,g[b][p].size()-1){
					int v=g[b][p][j];
					if(vis[u][v])continue;vis[u][v]=1;
					q.push((node){u,v,st+2});
				}
			}
		}
	}
	if(ans==1e9)ans=-1;
	printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

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

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

const ll   N     =  5e5+5;
const ll   M     =  4e6+5;
const ll   mod   =  1e9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll n, a, b;

ll fastmod(ll x, ll y = mod - 2){
	ll res = 1;
	while(y){
		if(y&1) res = res * x % mod;
		x = x * x % mod;
		y /= 2;
	}
	return res;
}

ll sum(ll x){
	return x * (x + 1) % mod * fastmod(2) % mod;
}

ll mul(ll x, ll y){
	return x * y % mod;
}

void solve(){
	cin >> n >> a >> b;
	ll x = n - b + 1;
	ll y = n - a - b + 1;
	ll z = n - a + 1;
	if(y <= 0){
		deb1(0)
		return;
	}
	ll s1 = mul(mul(sum(y), x), z), s2 = mul(sum(y), sum(y));
	deb1((4*(s1 - s2) + 4*mod) % mod)
}

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

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll mod=1000000007;

int solve(){
	ll N, A, B;
	cin >> N >> A >> B;
	if(A+B>N){
		cout << 0 << endl;
		return 0;
	}
	if(A>B) swap(A, B);
	ll sum=(((N-A+1)*(N-A+1)%mod)*((N-B+1)*(N-B+1)%mod))%mod;
	ll h=min(A+B-1, N-A+1)%mod;
	ll f=h*(N-B+1)%mod, g=(h-B)*(h-B+1)%mod;
	(sum += mod-(f+mod-g)*(f+mod-g)%mod) %= mod;
	cout << sum << endl;
	return 0;
}

int main() {
	int T;
	cin >> T;
	for(int i=0; i<T; ++i){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define re register
#define in inline
#define get getchar()
#define ll long long
int main()
{
	ll n;
	cin>>n;
	if(n<=2) cout<<1<<endl;
	else
	{
		ll l=2,r=sqrt(2*n),mid,ans;
		while(l<=r)
		{
			mid=l+r>>1;
			if((2+mid)*(mid-1)/2<=n) ans=mid, l=mid+1;
			else r=mid-1;
		}
		cout<<2+((n-1)-ans)<<endl;
	}
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i < n; ++i)
#define exrep(i, a, b) for (ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef vector<vector<double>> vvd;
typedef vector<vector<string>> vvs;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;
}
template <class T>
void debug(T v)
{
    rep(i, v.size()) cout << v[i] << " ";
    cout << endl;
}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{
    gearup;
    ll n;
    cin >> n;
    ll ma = 1e9 * 2 + 10, mi = 0;
    while (ma - mi > 1)
    {
        ll mid = (ma + mi) / 2;
        // 1 ~ midまでの数が作れるか
        ll ttl = mid * (1 + mid) / 2;
        if (ttl <= n + 1)
            mi = mid;
        else
            ma = mid;
    }
    out(n - ma + 2);
}


#include <algorithm>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define pii pair<int, int>
#define mii map<int, int>
#define pis pair<int, string>
#define vi vector<int>
#define int long long

#define endl "\n"
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

using namespace std;

const int inf = 1e16;
const int mod = 1e9 + 7;
const int Max = 1e5 + 5;
int pow(int a, int b)
{
    int res = 1;
    while(b > 0) {
        if(b & 1) {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;

        b >>= 1;
    }
    return res;
}
vector<bool> is_prime(Max, true);
void sieve()
{
    is_prime[0] = false;
    is_prime[1] = false;
    for(int i = 2; i * i < Max; i++) {
        if(is_prime[i]) {
            for(int j = i * i; j < Max; j += i) {
                is_prime[j] = false;
            }
        }
    }
}

int32_t main()
{
    IOS;
    int t;
    t = 1;
//    cin >> t;
    while(t--) {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int z=c*d-b;
        if(z<=0){
            cout<<-1<<endl;
            continue;
        }
        int ans=(a+z-1)/z;
        cout<<ans<<endl;
    }
    return 0;
}

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

    rep(i, T) {
        int N;
        string S1, S2, S3;
        cin >> N >> S1 >> S2 >> S3;
        string ans = "1";
        rep(i, N) ans += "0";
        rep(i, N) ans += "1";
        cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265
#define double long double
//#define DB
#ifdef DB
#define el cerr << "\n";
    #define db(...) cerr << " [" << #__VA_ARGS__ << " : " << __VA_ARGS__ << "] ";
#else
#define el
#define db(...)
#endif // DB
const int N = 505;
int n;
int p[N];
int sz;
int moves[N * N];
int curPos[N];

void doSwap(int i) {
    swap(p[i], p[i + 1]);
    curPos[p[i]] = i;
    curPos[p[i + 1]] = i + 1;
    moves[sz] = i;
    ++sz;
}

void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
        curPos[p[i]] = i;
    }
    sz = 0;
    for (int i = 1; i <= n; ++i) {
        if (p[i] == i) continue;
        int j = curPos[i];
        if (j % 2 != sz % 2) {
//            if (j < n - 2) {
//                doSwap(j + 2);
//            } else
            if (i < j - 1) {
                doSwap(j - 2);
            } else { // A i j
                doSwap(i - 1); doSwap(i);
                doSwap(i - 1); doSwap(i);
                doSwap(i - 1);
                continue;
            }
        }
        for (int k = j - 1; k >= i; --k) {
            doSwap(k);
        }
    }
}

int main() {
//    freopen("C:\\Users\\T\\CLionProjects\\cp-chemthan\\atcoder\\regular121\\C.in", "r", stdin);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
        cout << sz << "\n";
        if (sz) {
            for (int i = 0; i < sz; ++i) {
                cout << moves[i] << " ";
            }
            cout << "\n";
        }
    }
    return 0;
}

/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;
template<class T>void show(vector<T> &a) {cerr << "[ "; for (int ij = 0; ij < (int)a.size(); ij++) {cerr << a[ij] << " ";} cerr << "]\n";}
template<class T>void show(T a) {cerr << a << endl;}
template<typename... T>void show(T... args) {((cerr << args << ' '), ...); cerr << endl;}
template<class T>void read(vector<T> &a) {for (auto &x : a) {cin >> x;}}
template<class T> void read(T &a) {cin >> a;}

void solve() {
	int i, j;
	int n;

	read(n);

	vector<int> a(n);

	read(a);

	vector<int> ans;

	int f=0;
	while(!is_sorted(a.begin(),a.end())){
		bool b=1;
		for (int j = 0; j < n-1; ++j)
		{
			if(a[j]>a[j+1] && j%2==f){
				swap(a[j],a[j+1]);
				ans.push_back(j+1);
				f^=1;
				b=0;
			}
		}
		if(b){
			ans.push_back(f+1);
			swap(a[f],a[f+1]);
			f^=1;
		}
	}

	cout << ans.size() << endl;

	for(auto &x:ans){
		cout << x << ' ';
	}
	cout << endl;

}

int32_t main(int32_t argc, char *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
}