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

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

#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
		//order_of_key (k) : Number of items strictly smaller than k .
		//find_by_order(k) : K-th element in a set (counting from zero) (returns an iterator)

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

vector < vi > adj, vec;
vector < vector < pii >> a;
vi ans, sz, cnt, depth, mp;

void cal(int node)
{
	for(auto i : a[node])
	{
		ans[i.se] = cnt[i.fi];
	}
}

void dfs(int root, int keep)
{

	int bC =  - 1, mx = 0;

	for(auto i : adj[root])
	{
		if(sz[i] > mx)
		{
			mx = sz[i];
			bC = i;
		}
	}

	for(auto i : adj[root])
	{
		if(i != bC)
		{
			dfs(i, 0);
		}
	}

	if(bC !=  - 1)
	{
		dfs(bC, 1);
		mp[root] = mp[bC];
	}

	cnt[depth[root]]++ ;
	vec[mp[root]].pb(depth[root]);

	for(auto i : adj[root])
	{
		if(i != bC)
		{
			for(auto j : vec[mp[i]])
			{
				cnt[j]++ ;
				vec[mp[root]].pb(j);
			}
		}
	}

	cal(root);

	if(!keep)
	{
		for(auto i : vec[mp[root]])
		{
			cnt[i]-- ;
		}
	}
}

void pre_cal(int root)
{
	sz[root]++ ;
	for(auto i : adj[root])
	{
		depth[i] = depth[root] + 1;
		pre_cal(i);
		sz[root] += sz[i];
	}
}

int32_t main()
{
	fastIO
	inp_out();

	int n;
	cin >> n;

	adj = vec = vector < vi > (n + 1);
	a = vector < vector < pii >> (n + 1);
	sz = cnt = depth = mp = vi(n + 1);

	iota(mp.begin(), mp.end(), 0);

	for(int i = 2; i <= n; ++ i)
	{
		int x;
		cin >> x;
		adj[x].pb(i);
	}

	int q;
	cin >> q;

	ans = vi(q);

	for(int i = 0; i < q; ++ i)
	{
		int u, d;
		cin >> u >> d;
		a[u].pb({d, i});
	}

	pre_cal(1);
	dfs(1, 1);

	for(auto i : ans)
		cout << i << '\n';

	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define w(x)            int x; cin>>x; while(x--)
#define mii             map<int,int>
#define endl            ("\n")
#define vi              vector<int>
#define pii             pair<int,int>
#define f(i, a, n)      for(int i=a; i<n; i++)
#define r(i, n, a)      for(int i=n-1;i>=0;i--)
#define fd(i, a, n, d)  for(int i=a; i<n;i+=d)
#define rd(i, n, a, d)  for(int i=n-1;i>=0;i-=d)
#define in(a,n)         f(i,0,n){cin>>a[i];}
#define pb              push_back
#define yy              cout<<"YES\n"
#define nn              cout<<"NO\n"
#define kk              cout<<"-1\n"
#define inf             (long long)1e18
#define mod             1000000007LL
#define cc(r)           cout<<r<<" "
#define ce(r)           cout<<r<<endl
#define out(a,n)        f(i,0,n){cc(a[i]);}
#define cn              continue
#define br              break
#define ins             insert
#define pi              3.14159265358979323846
#define aint(a)          a.begin(),a.end()

//################################################################################

void ovector_n()
{
    ce("Fastest Man Alive!");
}

//################################################################################

void flash() {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
//################################################################################
int32_t main()
{
    flash();//1 June++;
    int T = clock();
    int x, y;
    cin >> x >> y;
    int q = (3LL - (x + y));
    if (x == y)
        ce(x);
    else
        ce(q);
    cerr << "TIME: " << (long double)(clock() - T) / CLOCKS_PER_SEC << " sec\n";
    return 0;
}


// Problem: C - Comma
// Contest: AtCoder - Panasonic Programming Contest (AtCoder Beginner Contest 195)
// URL: https://atcoder.jp/contests/abc195/tasks/abc195_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Date: 2021-03-13 22:42:44
// --------by Herio--------

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define PII pair<int,int>
#define fi first
#define se second
#define pb emplace_back
#define SZ(a) (int)a.size()
#define IOS ios::sync_with_stdio(false),cin.tie(0)
void Print(int *a,int n){
	for(int i=1;i<n;i++)
		printf("%d ",a[i]);
	printf("%d\n",a[n]);
}
int a[20];
ll dp[22][22][2][2];
ll dfs(int x,int c,bool li,bool lead){
	if(!x){
		//printf("c=%d\n",c);
		return (c-1)/3;
	}
	ll &s=dp[x][c][li][lead];
	if(~s) return s;
	s=0;
	int mx=li?a[x]:9;
	for(int i=0;i<=mx;i++)
		s+=dfs(x-1,(lead&&!i)?c:c+1,li&(i==mx),lead&&!i);
	return s;
}
ll fun(ll n){
	int w=0;while(n) a[++w]=n%10,n/=10;
	return dfs(w,0,1,1);
}
int main(){
	ll n;scanf("%lld",&n);mst(dp,-1);
	printf("%lld\n",fun(n));
	return 0;
}

#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>

#define rep(i,x,y) for(int i = x; i <= y; ++i)
#define repr(i,x,y) for(int i = x; i >= y; --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define endl "\n" // interactive problem
#define ll long long
#define int long long

using namespace std;

const int N = (int)(1e5) + 322;
const int inf = (int)(1e9) + 322;
const long long INF = (long long)(1e18) + 322;
const int mod = (int)(1e9) + 7;

void solve() {
    string s; cin >> s;
    if (sz(s) <= 4) {
        sort(all(s));
        do {
            if (stoi(s) % 8 == 0) {
                cout << "Yes";
                return;
            }
        } while (next_permutation(all(s)));
    }
    unordered_map <char, int> cnt;
    for(auto c : s) cnt[c]++;
    for(int i = 8; i < 1000; i += 8) {
        string cur = to_string(i);
        while (sz(cur) < 3) cur += '0';
        unordered_map <char, int> no;
        for(auto c : cur) no[c]++;
        bool good = true;
        for(auto it : no) {
            if (cnt[it.first] < it.second) good = false;
        }
        if (good) {
            cout << "Yes";
            return;
        }
    }
    cout << "No";

}

signed main () {
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
//    freopen("student.in", "r", stdin);
//    freopen("student.out", "w", stdout);
    int t = 1;//cin >> t;
    for(int tt = 1; tt <= t; ++tt) {
        solve();
    }
    return 0;
}


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

vector<ll>v[3];
int sz[3];
int baad;
ll calc(int c1,int c2,bool check=false)
{

    ll ansmin = 1e18;
    ll a1,a2;
    int pos, anspos = -1,i;
    for(i=0;i<sz[c1];i++)
    {
        a1 = v[c1][i];
        pos = upper_bound(v[c2].begin(), v[c2].end(), a1) - v[c2].begin();
        if(pos != sz[c2])
        {
            a2 = v[c2][pos];
            if(abs(a1-a2) < ansmin)
            {
                if(!(check && baad == pos))
                {
                    ansmin = abs(a1-a2);
                    anspos = pos;
                }
            }
        }
        if(pos > 0)
        {
            pos--;
            a2 = v[c2][pos];
            if(abs(a1-a2) < ansmin)
            {
                if(!(check && baad == pos))
                {
                    ansmin = abs(a1-a2);
                    anspos = pos;
                }
            }
        }
    }
    baad = anspos;
    return ansmin;

}

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

    int n,i,j,k;
    ll a;
    char c;
    cin >> n;
    n *= 2;
    for(i=1;i<=n;i++)
    {
        cin >> a >> c;
        if(c == 'R') v[0].push_back(a);
        else if(c == 'G') v[1].push_back(a);
        else v[2].push_back(a);
    }
    for(i=0;i<3;i++) {
        sz[i] = v[i].size();
        sort(v[i].begin(), v[i].end());
    }

    if(sz[0]%2==0 && sz[1]%2==0 && sz[2]%2==0)
    {
        cout << 0 << endl;
        return 0;
    }

    ll ans1, ans2, ansmin;
    if(sz[0]%2 == 0) {
        ansmin = calc(1,2);
        ans1 = (calc(1,0) + calc(2,0,true));
        ans2 = (calc(2,0) + calc(1,0,true));
        ansmin = min(ansmin, min(ans1, ans2));
    }
    else if(sz[1]%2 == 0) {
        ansmin = calc(0,2);
        ans1 = (calc(0,1) + calc(2,1,true));
        ans2 = (calc(2,1) + calc(0,1,true));
        ansmin = min(ansmin, min(ans1, ans2));
    }
    else {
        ansmin = calc(0,1);
        ans1 = (calc(0,2) + calc(1,2,true));
        ans2 = (calc(1,2) + calc(0,2,true));
        ansmin = min(ansmin, min(ans1, ans2));
    }
    cout << ansmin << endl;

}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

ll solve(vll a, vll b)
{
	ll ans = 1e18;
	int id1 = 0, id2 = 0;
	int m = a.size(), n = b.size();
	while( id1 < m && id2 < n )
	{
		ans = min( ans , abs(a[id1]-b[id2]) );
		if( a[id1] < b[id2] ) id1++;
		else id2++;
	}
	return ans;
}

ll solve1(vll a,vll b,vll c)
{
	ll ans1 = 1e18; int id = -1;
	int id1 = 0, id2 = 0;
	int m = a.size(), n = b.size();
	while( id1 < m && id2 < n )
	{
		if( ans1 > abs(a[id1]-b[id2]) )
		{
			ans1 = abs(a[id1]-b[id2]);
			id = id1;
		}
		if( a[id1] < b[id2] ) id1++;
		else id2++;
	}
	id1 = 0; id2 = 0;
	n = c.size();
	ll ans2 = 1e18;
	while( id1 < m && id2 < n )
	{
		if( id1 == id ){ id1++; continue; }
		if( ans2 > abs(a[id1]-c[id2]) )
		{
			ans2 = abs(a[id1]-c[id2]);
		}
		if( a[id1] < c[id2] ) id1++;
		else id2++;
	}
	return ans1 + ans2;
}

int main() {

	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int n; cin>>n;
	map <char,vll> m;
	forn(i,n*2)
	{
		ll a; char c;
		cin>>a>>c;
		m[c].pb(a);
	}
	sort(all(m['R']));
	sort(all(m['G']));
	sort(all(m['B']));

	if( m['R'].size()%2 == 0 && m['G'].size()%2 == 0 && m['B'].size()%2 == 0 )
	{
		cout<<0; return 0;
	}
	string s;
	if(m['R'].size()%2 == 0) s = "RBG";
	if(m['G'].size()%2 == 0) s = "GRB";
	if(m['B'].size()%2 == 0) s = "BRG";
	ll h1 = solve(m[s[1]],m[s[2]]);
	ll h2 = solve1(m[s[0]],m[s[1]],m[s[2]]);
	ll h3 = solve1(m[s[0]],m[s[2]],m[s[1]]);
	cout << min( h1 , min( h2 , h3 ) );

	return 0;
}


#include<iostream>
int n;
int main(){
  std::cin >> n;
  int ans = 0;
  while(true){
    ans++;
    if((ans-1)*100+1<=n&&n<=ans*100){
      std::cout << ans << std::endl;
      break;
    }
  }
  return 0;
}

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    string s;
    cin >> s;
    array<int, 10> a{};
    for (auto &&i : s) a[i-'0']++;
    vector<string> t = {"8", "16", "24", "32", "48", "56", "64", "72", "88", "96"};
    if(s.size() <= 2){
        for (auto &&i : t) {
            for (int j = 0; j < 2; ++j) {
                if(i == s) return puts("Yes"), 0;
                reverse(i.begin(),i.end());
            }
        }
        return puts("No"), 0;
    }
    for (int i = 104; i <= 999; i += 8) {
        string u = to_string(i);
        for (auto &&j : u) a[j-'0']--;
        int ok = 1;
        for (auto &&j : a) if(j < 0) ok = 0;
        if(ok) return puts("Yes"), 0;
        for (auto &&j : u) a[j-'0']++;
    }
    puts("No");
    return 0;
}


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

#define int long long
#define il inline
#define rg register

il int read()
{
	int re=0,k=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')k=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){re=re*10+ch-48;ch=getchar();}
	return re*k;
}

il void write(int x)
{
	if(x<0)return putchar('-'),write(-x),void();
	if(x<10)return putchar(x+48),void();
	return write(x/10),write(x%10),void();
}

int s,p;
signed main()
{
	s=read();p=read();
	for(rg int i=1;i*i<=p;i++)
	{
		if(p%i)continue;
		if(p/i+i==s)
		{
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if (abs(a-b)<3) cout<<"Yes";
  else cout<<"No";
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define SZ(v) ((int)(v).size())
#define abs(x) ((x) > 0 ? (x) : -(x))
typedef long long LL;

const LL mod = 1000000000 + 7;
LL n, p;
void solve() {
    cin >> n >> p;
    LL b = n - 1, a = (p - 2) % mod;
    LL res = 1;
    for (; b; b >>= 1) {
        if (b & 1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    cout << res * (p - 1) % mod << endl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    solve();
    return 0;
}

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

using ll = long long;
using namespace std;

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

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

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

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

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&...tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&...args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

constexpr int mod = 1'000'000'007; //1e9+7(prime number)
constexpr int INF = 1'000'000'000; //1e9
constexpr ll LLINF = 2'000'000'000'000'000'000LL; //2e18
constexpr int SIZE = 200010;

ll power(ll k, ll n, int M) {
  ll res = 1;
  for (; n; n /= 2) {
    if (n & 1) res = res * k % M;
    k = k * k % M;
  }
  return res;
}

int main() {
  int N, P;

  cin >> N >> P;

  ll ans = (ll)(P - 1) * power(P - 2, N - 1, mod);

  cout << ans % mod << endl;

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define ull unsigned long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define ti3 tuple<int,int,int>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll mod = 1e9 + 7;
const ll linf = 1LL << 62;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll dp[20][1 << 20];
int N;
ll X[20], Y[20], Z[20];
int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < (1 << N); j++) {
            dp[i][j] = linf;
        }
    }
    dp[0][1] = 0;
    for (int i = 0; i < N; i++) cin >> X[i] >> Y[i] >> Z[i];

    for (int i = 0; i < (1 << N); i++) {
        for (int j = 0; j < N; j++) {
            if (dp[j][i] == linf) continue;
            for (int k = 0; k < N; k++) {
                ll cost = abs(X[j] - X[k]) + abs(Y[j] - Y[k]) + max(0LL, Z[k] - Z[j]);
                chmin(dp[k][i | (1 << k)], dp[j][i] + cost);
            }
        }
    }
    ll ans = linf;
    for (int i = 1; i < N; i++) {
        ll cost = abs(X[0] - X[i]) + abs(Y[0] - Y[i]) + max(0LL, Z[0] - Z[i]);
        chmin(ans, dp[i][(1 << N) - 1] + cost);
    }
    cout << ans << endl;
}

#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rept(i,k,n) for(long long i = (k); i < (long long)(n); i++)
#define All(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Rsort(v) sort(v.begin(),v.end(),[](auto a, auto b) { return a > b; })
#define Reverse(v) reverse(v.begin(),v.end())
#define MAX 1000000007
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}

int main(){
    bitset<17> b(0);
    int n;
    cin>>n;
    vector<Tii> vs(n);
    rep(i,n){
        int x,y,z;
        cin>>x>>y>>z;
        vs[i]=Tii(x,y,z);
    }
    vector<vector<int> > dp(1<<n,vector<int>(n,1e9));
    dp[0][0]=0;
    sort(vs.begin(), vs.end(), [](Tii a, Tii b) { return get<2>(a) < get<2>(b); });
    for(int i=1;i<(1<<n);i++){
        b = i;
        rep(j,n){
            if(b.test(j)){
                rep(k,n){
                    int a,b,c,p,q,r;
                    tie(a,b,c)=vs[k];
                    tie(p,q,r)=vs[j];
                    int dist = abs(p-a)+abs(q-b)+max(0,r-c);
                    dp[i][j]=min(dp[i][j],dp[i-(1<<j)][k]+dist);
                }
            }
        }

    }
    cout<<dp.back()[0]<<endl;;
    return 0;
}


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

int main(void){
  long long N;
  long long X=1;
  long long x=1000000000;
  cin>>N;
  set<long long> Ax;
  for(long long n=0;n<N;n++){
    long long a;
    cin>>a;
    if(X<a)X=a;
    if(x>a)x=a;
    Ax.insert(a);
  }
  while(X!=x){
    Ax.erase(X);
    X-=x;
    Ax.insert(X);
    auto max=Ax.end();max--;
    auto min=Ax.begin();
    X=*max;x=*min;
  }
  cout<<x<<endl;
  return 0;
}

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

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using vi = vector<int>;

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

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

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

#if 1

i64 gcd(i64 a, i64 b) { return b ? gcd(b, a % b) : a; }

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

  int N;
  cin >> N;
  int b = -1;
  F0R(i, N) {
    int a; cin >> a;
    if (i) b = gcd(b, a);
    else b = a;
  }

  cout << b;
}
#endif


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

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, x;
    cin >> n;
    cin >> x;
    int hai = 0;
    int alSum = 0;
    int arr[n][2];
    for (int i = 0; i < n; i++) {
        cin >> arr[i][0];
        cin >> arr[i][1];
    }

    for (int i = 0; i < n; i++) {
        hai++;
        alSum += arr[i][0] * arr[i][1];
        if(alSum > x * 100){
            cout << hai << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void solve(){
    ll N,c;
    cin >> N >> c;
    vector<pll> v;
    ll a;
    vll cs(N+1);
    for(int i = 1; i <= N; i++){
        cin >> a;
        v.pb({a,i});
        cin >> a;
        v.pb({a+1,-i});
        cin >> cs[i];
    }
    sort(v.begin(),v.end());
    //cout << v[0].se<<"lol ";
    ll k =cs[v[0].se];
    ll l =v[0].fi;
    ll ans = 0;
    //cout << k <<" kek";
    for(int i = 1; i < 2*N; i++){
    //    cout << "k ans "<<k <<" "<<ans<<"\n";
        ans+=(v[i].fi-l)*min(c,k);
        l = v[i].fi;

        if(v[i].se<0)k-=cs[-v[i].se];
        else k+= cs[v[i].se];
    }
    cout << ans <<"\n";
    return;
}

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


#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int N, K, M;
constexpr int maxn = 1000000;
int arr[maxn << 1], *dp;
void add(int& X, int Y){
    X += Y;
    if(X >= M) X -= M;
}
void sub(int& X, int Y){
    X -= Y;
    if(X < 0) X += M;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> N >> K >> M;
    dp = arr + maxn;
    vector<int> ans;
    for(int i = 1; i <= (N + 1) / 2; i += 1){
        int L = -i * (i - 1) / 2 * K, R = (N - i + 1) * (N - i) / 2;
        for(int j = L; j <= R; j += 1) dp[j] = 0;
        dp[L] = 1;
        vector<int> v;
        for(int j = 1; j <= N; j += 1) if(i != j) v.push_back(abs(i - j));
        sort(v.begin(), v.end());
        R = L;
        for(int x : v){
            int d = x * K;
            R += d;
            for(int j = L + x; j <= R; j += 1) add(dp[j], dp[j - x]);
            for(int j = R; j >= L + d + x; j -= 1) sub(dp[j], dp[j - d - x]);
        }
        ans.push_back(((LL)dp[0] * (K + 1) + M - 1) % M);
    }
    for(int i = (N + 1) / 2 + 1; i <= N; i += 1) ans.push_back(ans[N - i]);
    for(int x : ans) cout << x << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define pll pair<ll,ll>
#define vll vector<long long>
#define f first
#define s second
long long mod = 1e9+7;

int diry[] = {-1,0,0,1,1,-1,-1,1};
int dirx[] = {0,-1,1,0,1,-1,1,-1};

bool comp(const pii &a,const pii &b){
    return a.second<b.second;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ull t=1,k;
    // cin>>t;
    // cin>>k;
  // int ulti=1;
    while(t--){
        ll n,c; cin>>n>>c;
        vector<pll> arr;
        for(int i=0;i<n;i++){
            ll a,b,d; cin>>a>>b>>d;
            arr.push_back({a-1,d});
            arr.push_back({b,-d});
        }
        sort(arr.begin(),arr.end());
        ll ans=0,fee=0,t=0;
        for(auto j:arr){
            ll x=j.first,y=j.second;
            if(t!=x){
                ans += min(c,fee)*(x-t);
                t = x;
            }
            fee+=y;
        }
        cout<<ans;
		cout<<endl;
    }
}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll n, C; cin >> n >> C;
    ll a[n], b[n], c[n];
    rep(i, n){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
    }

    map<ll, ll> mp;
    rep(i, n){
        mp[a[i]] += c[i];
        mp[b[i] + 1] -= c[i];
    }

    vector<pair<ll, ll>> vec;
    for(const auto& [k, v] : mp){
        vec.push_back({k, v});
    }

    vector<pair<ll, ll>> vec2;
    ll len_vec = vec.size();
    ll cost = vec[0].second;
    rep(i, len_vec - 1){
        ll d = vec[i + 1].first - vec[i].first;
        vec2.push_back({d, cost});

        cost += vec[i + 1].second;
    }

    ll ans = 0;
    for(auto p : vec2){
        if(p.second < C){
            ans += p.first * p.second;
        }
        else{
            ans += p.first * C;
        }
    }

    cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x1 gdsfdsf
#define y1 fgdfgdfg
#define endl '\n'
const ll DIM = 2E5+7;
pair<ll,ll> A[DIM],Q[DIM];
vector<pair<ll,ll> > V[DIM];
pair<ll,ll> ans[DIM];

pair<ll,ll> F(pair<ll,ll> a,ll rot){
    if (rot==0){
        return a;
    }
    if (rot==1){
        return {a.second,a.first};
    }
    if (rot==2){
        return {a.first,a.second};
    }
    if (rot==3){
        return {a.second,a.first};
    }
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    cin>>n;
    for(ll i = 1;i<=n;++i){
        cin>>A[i].first>>A[i].second;
    }
    ll m;
    cin>>m;
    for(ll i = 1;i<=m;++i){
        cin>>Q[i].first;
        if (Q[i].first>2)
            cin>>Q[i].second;
    }
    ll q;
    cin>>q;
    for(ll i = 1;i<=q;++i){
        ll x,y;
        cin>>x>>y;
        V[x].push_back({y,i});
    }
    for(auto to:V[0]){
        ans[to.second] = A[to.first];
    }
    ll rot = 0;
    ll addx = 0,addy = 0,multx = 1,multy = 1;
    for(ll i = 1;i<=m;++i){
        if (Q[i].first==1){
            rot = (rot+1)%4;
            swap(addx,addy);
            addy = -addy;
            swap(multx,multy);
            multy = -multy;
        }
        if (Q[i].first==2){
            rot = (3+rot)%4;
            swap(addx,addy);
            addx = -addx;
            swap(multx,multy);
            multx = -multx;
        }
        if (Q[i].first==3){
            multx = -multx;
            addx = -addx;
            addx+=Q[i].second*2;
        }
        if (Q[i].first==4){
            multy = -multy;
            addy = -addy;
            addy+=Q[i].second*2;
        }
        for(auto to:V[i]){
            pair<ll,ll> a = F(A[to.first],rot);
            a.first = a.first*multx+addx;
            a.second = a.second*multy+addy;
            ans[to.second] = a;
        }
    }

    for(ll i = 1;i<=q;++i)cout<<ans[i].first<<' '<<ans[i].second<<endl;
    return 0;
}


#include <bits/stdc++.h>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repll(i,n) for (ll i = 0; i < (ll)(n); i++)
#define fore(x,a) for(auto&(x) : (a))

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

#define ALL(a) (a).begin(), (a).end()

const ll INFL = 1e18;
const int INFI = 1e9;
const int MOD = 1e9 + 7;

const int MAX = 30;
ll dp[MAX+1][MAX+1];

string  find_kth(int A,int B,ll K) {
    if(A == 0) {
      return string(B,'b');
    }
    if(B == 0) {
      return string(A,'a');
    }
    if(K <= dp[A-1][B]) {
      return string("a") + find_kth(A-1,B,K);
    }
    else {
      return string("b") + find_kth(A,B-1,K-dp[A-1][B]);
    }
  }

int main(){
  int A,B;
  ll K;
  cin >> A >> B >> K;
  dp[0][0] = 1;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      if(i > 0) {
        dp[i][j] += dp[i-1][j];
      }
      if(j > 0) {
        dp[i][j] += dp[i][j-1];
      }
    }
  }
  cout << find_kth(A,B,K) << endl;
}

#include<bits/stdc++.h>
using namespace std;
int n,m,x[101010],y[101010];
long long ans=0;
map<pair<int,int>,int>mp;
string s;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		for(int j=0;j<m;j++)
		{
			if(s[j]=='0')
			{
				x[i]++;
			}
			else
			{
				y[i]++;
			}
		}
		mp[make_pair(x[i],y[i])]++;
	}
	for(int i=1;i<=n;i++)
	{
		int nw=1;
		while((y[i]-nw)>=0)
		{
			ans+=mp[make_pair(x[i]+nw,y[i]-nw)];
			nw+=2;
		}
		nw=1;
		while((x[i]-nw)>=0)
		{
			ans+=mp[make_pair(x[i]-nw,y[i]+nw)];
			nw+=2;
		}
	}
	cout<<ans/2<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

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

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}

string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int SUM(string s)
{
    int ans=0;
    for (auto i : s)
        ans+=(i-'0');
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s,t;
    cin>>s;
    cin>>t;
    cout<<max(SUM(s),SUM(t));
    return 0;
}

#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

// #define NDEBUG
#include<cassert>

#define rep(i, l, r) for(int i=(l), i##_end_=(r); i<=i##_end_; ++i)
#define drep(i, l, r) for(int i=(l), i##_end_=(r); i>=i##_end_; --i)
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define Endl putchar('\n')
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T>inline T fab(T x){ return x<0? -x: x; }
template<class T>inline T readin(T x){
    x=0; int f=0; char c;
    while((c=getchar())<'0' || '9'<c) if(c=='-') f=1;
    for(x=(c^48); '0'<=(c=getchar()) && c<='9'; x=(x<<1)+(x<<3)+(c^48));
    return f? -x: x;
}
template<class T>inline void writc(T x, char s='\n'){
    static int fwri_sta[1005], fwri_ed=0;
    if(x<0) putchar('-'), x=-x;
    do fwri_sta[++fwri_ed]=x%10, x/=10; while(x);
    while(putchar(fwri_sta[fwri_ed--]^48), fwri_ed);
    putchar(s);
}

const int maxn=2e5;

ll ans[maxn+5], pre[maxn+5];
int premax[maxn+5], a[maxn+5], n;

signed main(){
    n=readin(1);
    rep(i, 1, n) a[i]=readin(1);
    rep(i, 1, n) premax[i]=max(premax[i-1], a[i]), pre[i]=pre[i-1]+a[i];
    ll cur=0;
    rep(i, 1, n){
        cur+=pre[i];
        ans[i]=cur+1ll*premax[i]*i;
    }
    rep(i, 1, n) writc(ans[i]);
    return 0;
}


#include <bits/stdc++.h>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#define loop(i,a,b) for (int i = (a); i <= (b); i++)
#define loopr(i, a, b) for(int i = (a); i >= (b); i--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define mp(a,b) make_pair(a,b)
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long int
#define inf 1e18
#define mod 1000000007
#define mod1 998244353
using namespace std;

int main()
{
	fast_io;
	ll s,p;
	cin>>s>>p;
	int f = 0;
	for(ll i = 1;i*i<=p;i++)
	{
		if(p%i==0)
		{
			if(i+p/i==s)
			{
				f = 1;
			}
		}
	}
	if(f)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

#include <bits/stdc++.h>
#define LOCAL

using namespace std;

using ll = long long;
const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_vector(vector<ll> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

ll gcd(ll x, ll y) {
    return (y == 0 ? x : gcd(y, x % y));
}
ll lcm(ll x, ll y) {
    return x * y / gcd(x, y);
}

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

int color[100000 + 10];
int node_color[100000 + 10];
vector<int> res;
set<int> v;

void dfs(int node, unordered_map<int, vector<int>>& nei) {
    // cout << node << " " << parent << endl;
    v.insert(node);
    if (color[node_color[node]] == 0) {res.push_back(node);}
    color[node_color[node]]++;
    for (auto x : nei[node]) {
        if (v.find(x) == v.end()) {
            // cout << x << " " << node << endl;
            dfs(x, nei);
        }
    }
    color[node_color[node]]--;
}

int solve() {
    memset(color, 0, sizeof(color));
    memset(node_color, 0, sizeof(color));

    int n;
    cin >> n;

    int c;
    REP(i, n) {
        cin >> c;
        node_color[i+1] = c;
    }

    unordered_map<int, vector<int>> nei;

    int a, b;
    REP(i, n - 1) {
        cin >> a >> b;
        nei[a].push_back(b);
        nei[b].push_back(a);
    }

    dfs(1, nei);
    sort(ALL(res));

    for (auto x : res) {
        cout << x << endl;
    }

    return 0;
}

int main() {
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        int res = solve();
        // cout << "Case #" << _ + 1 << ": " << res << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define f(i,a,b) for( ll i = a; i <  b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(numeros) (ll) __builtin_popcountll(numeros)
#define cuantos(a,x) count(all(a),x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " es " << (x) <<"\n"
#define test ll deftestcases;cin>>deftestcases;while(deftestcases--)
#define PI acos(-1)
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
typedef vector<ll>  vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
//template<class T> using ordered_set =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
const ll inf = 2e18;
const ll mod = 1e9+7;
const ll MAX = 1e5;

int main(){
    fastio;
    ll n,k;cin>>n>>k;
    while(n%200==0 && k){
        k--;
        n/=200;
    }
    bool go =1;
    while(k){
        if(go){
            n*=10;
            n+=2;
            n*=100;
        }else n/=200;
        go^=1;
        k--;
    }
    cout<<n<<"\n";
    return 0;
}

#include <iostream>
using namespace std;

int H, W, A, B, ans = 0;
void dfs(int i, int bit, int A, int B){
    if(i == H * W) return (void)ans++;
    if(bit & 1 << i) return dfs(i + 1, bit, A, B);
    if(B) dfs(i + 1, bit | 1 << i, A, B - 1);
    if(A){
        if(i % W != W - 1 && ~bit & 1 << (i + 1)) dfs(i + 1, bit | 1 << i | 1 << (i + 1), A - 1, B);
        if(i + W < H * W) dfs(i + 1, bit | 1 << i | 1 << (i + W), A - 1, B);
    }
}
int main(){
    cin >> H >> W >> A >> B;
    dfs(0, 0, A, B);
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define mii map<int, int>
#define pii pair<int, int>
#define qii priority_que<int, vector<int>, greater<int>>
#define For(i, n) for(int i = 0; i < n; ++i)
#define For1(i, n) for(int i = 1; i <= n; ++i)
#define Forlr(i, l, r) for(int i = l; i <= r; ++i)
#define Forrl(i, r, l) for(int i = r; i >= l; --i)
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) {For(i, a.size()) cout << a[i] <<" ";}
#define ovv(a) {For(i, a.size()) {For(j, a[i].size()) cout << a[i][j] <<" ";cout <<"\n";}}
using ll = long long;
int n, m, k, q;
const int INF = 1e9 + 5;
const int nax = 1e5 + 5;
pair<int, int> a[5 * nax];
int d[1505][1505][2];
int g[1505][1505];
ll rs = 0;
void dfs(int x, int y){
	int nx = x, ny = y;
	//if(!g[nx][ny] && !d[nx][ny][1] && !d[nx][ny][0]) rs ++, g[nx][ny] = 1;
	while(1){
		nx ++;
		if(nx <= n && !d[nx][ny][0] && !g[nx][ny]){
			if(!d[nx][ny][1]) rs ++;
			d[nx][ny][0] = 1;
		}
		else{
			break;
		}
	}
	nx = x;
	while(1){
		nx --;
		if(nx >= 1 && !d[nx][ny][0] && !g[nx][ny]){
			if(!d[nx][ny][1]) rs ++;
			d[nx][ny][0] = 1;
		}
		else{
			break;
		}
	}
	nx = x;
	while(1){
		ny ++;
		if(ny <= m && !d[nx][ny][1] && !g[nx][ny]){
			if(!d[nx][ny][0]) rs ++;
			d[nx][ny][1] = 1;
		}
		else{
			break;
		}
	}
	ny = y;
	while(1){
		ny --;
		if(ny >= 1 && !d[nx][ny][1] && !g[nx][ny]){
			if(!d[nx][ny][0]) rs ++;
			d[nx][ny][1] = 1;
		}
		else{
			break;
		}
	}
}
int main()
{
	fast();
	cin >> n >> m;
	int na, nb;
	cin  >> na >> nb;
	For(i, na){
		cin >> a[i].first >> a[i].second;
		g[a[i].first][a[i].second] = 1;
		rs++;
	}
	For(i, nb){
		int x, y;
		cin >> x >> y;
		g[x][y] = 1;
	}
	For(i, na){
		dfs(a[i].first, a[i].second);
	}
	// For(i, n){
	// 	For(j, m){
	// 		cout << g[i + 1][j + 1] <<" ";
	// 	}
	// 	cout <<"\n";
	// }
	cout << rs;
}

 #include <bits/stdc++.h>
#define fo(i, k, n) for (ll i = k; i < n; i++)
#define rfo(i, k, n) for (ll i = k; i >= n  ; i--)
#define ll long long
#define ld long double
#define que queue
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define gcd(m,n) __gcd( m,  n)
#define sq(x)   (x*x)
#define rev(v)  reverse(v.begin(),v.end())
#define srt(v)  sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<int>())
#define mnv(v)     *min_element(v.begin(),v.end())
#define mxv(v)    *max_element(v.begin(),v.end())
#define all(v)    v.begin(),v.end()
#define integer(s) stoi(s)
#define intoString(num) to_string(num);

using namespace std;
ll MOD = 1e9 + 7;
//--------------------------------------------functions-------------------------------------------------//

ll power(ll a,ll b){ll result=1;while(b>0){if(b%2 == 1){result *= a;} a *= a;b /= 2;}return result;}
ll countSetBits(ll x){ll Count=0;while(x>0){if(x&1) Count++;x=x>>1;}return Count;}
bool isPerfectSquare(ll n){ll sr = sqrt(n);if (sr * sr == n)return true;else return false;}
ll mod(ll x,ll M){return ((x%M + M)%M);}
ll mul(ll a, ll b,ll M){return mod(mod(a,M)*mod(b,M),M);}
ll powerM(ll a,ll b,ll M){
    ll res=1ll;
    while(b){
        if(b%2ll==1ll){
            res=mul(a,res,M);
        }
        a=mul(a,a,M);b/=2ll;
    }
    return res;
}

//--------------------------------------------SieveOfEratosthenes-------------------------------------------------//
//mem will have true if its prime.
void SieveOfEratosthenes( vector<bool>&mem)
{ ll n = 1e6 +1;

    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= n; p++)
    {

        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }

     fo(i,2,n)
     if(prime[i])mem[i]=true;

}

//--------------------------------------------solve-------------------------------------------------//

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

 string s;
cin>>s;

int k;
cin>>k;

ll temp;
 fo(i,0,k)
 { temp = stoll(s);
  if(temp%200)
  {
    s = s + "200";

  }
  else
  {
    temp /= 200;
    s=intoString(temp);

  }

 }
 cout<<s<<endl;

  return 0;
}


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

#define rep(i,a,b) for(auto i=(a); i<(b); ++i)
#define trav(a,x) for(auto& a: x)
#define all(x) begin(x),end(x)
#define sz(x) (int)size(x)
#define PB push_back
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;

struct edge{int to;};
using graph = vector<vector<edge>>;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n, d, h; cin >> n >> d >> h;

    ld ans = 0.0;

    rep(i, 0, n) {
        int di, hi; cin >> di >> hi;

        ld slope = ((ld)h-hi)/(d-di);
        ans = max(ans, (ld)hi-slope*di);
    }
    cout << fixed << setprecision(15) << ans << "\n";
}

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

int main() {
    int N; cin >> N;
    string S,T; cin >> S >> T;
    vector<int> s1,t1;
    rep(i,N){
        if(S[i]=='1') s1.push_back(i);
        if(T[i]=='1') t1.push_back(i);
    }
    t1.push_back(2*N);
    ll cnt = 0; int k = 0; bool skip = false;
    rep(i,s1.size()){
        if(skip){
            skip = false; continue;
        }
        int x = s1[i]; int y = t1[k];
        if(x<y){
            if(i==s1.size()-1) cnt = -1;
            else{
                cnt += (ll)s1[i+1] - (ll)x;
                skip = true;
            }
        }
        else{
            cnt += (ll)x-(ll)y; k++;
        }
    }
    if(k!=t1.size()-1) cnt = -1;
    cout << cnt << endl;
}


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

int main() {
  int N, S, D;
  cin >> N >> S >> D;

  int X[N], Y[N];
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }

  bool res = false;
  for (int i = 0; i < N; i++) {
    if (X[i] < S) {
      if (Y[i] > D) {
        res = true;
        break;
      }
    }
  }

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

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const long double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
class MF{//max flow
	public:
	int n;
	vector<vector<edge> >G;//[MAX];
	vi level,iter;//[MAX];
	MF(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int from, int to, int cap){
		edge q={to,cap,int(G[to].size())};
		G[from].push_back(q);
		q={from,0,int(G[from].size()-1)};
		G[to].push_back(q);
	}
	void bfs(int s){
		level=vi(n,-1);
		queue<int>q;
		level[s]=0;
		q.push(s);
		while(!q.empty()){
			int v=q.front();q.pop();
			for(int i=0;i<G[v].size();i++){
				edge &e=G[v][i];
				if(e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					q.push(e.to);
				}
			}
		}
	}
	int dfs(int v,int t, int f) {
		if(v==t)return f;
		for(int &i=iter[v];i<G[v].size();i++){
			edge &e=G[v][i];
			if(level[v]>=level[e.to]||e.cap<=0) continue;
			int d =dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
		return 0;
	}
	int mf(int s,int t) {//from s to t,ford_fulkerson
		int flow=0;
		while(1){
			bfs(s);
			if(level[t]<0)return flow;
			iter=vi(n);
			int f;
			while((f=dfs(s,t,inf))>0)flow+=f;
		}
	}
};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,x,y;
	cin>>n>>x>>y;

	while(n--){
		int a,b;
		cin>>a>>b;
		if(a<x&&b>y){
			yes;
			return 0;
		}
	}
	no;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
ll decimaltoOctal(ll deciNum)
{

    // initializations
    ll octalNum = 0, countval = 1;
    ll dNo = deciNum;

    while (deciNum != 0) {

        // decimals remainder is calculated
        ll remainder = deciNum % 8;

        // storing the octalvalue
        octalNum += remainder * countval;

        // storing exponential value
        countval = countval * 10;
        deciNum /= 8;
    }
    return octalNum;
}
int main()
{
    fast

    ll n;
    cin>>n;
    ll count=0;
    for(ll i=1;i<=n;i++)
    {
        string str1 = to_string(i);
        string str2 = to_string(decimaltoOctal(i));

        if(str1.find('7') ==string::npos &&  str2.find('7') ==string::npos)
        {
            count++;
        }

    }
    cout<<count;

    return 0;
}

// 問題の URL を書いておく
//

#include <bits/stdc++.h>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    int N;
    cin >> N;
    int ans = 0;
    rep(i, N)
    {
        auto n = i + 1;
        auto dn = n;
        bool valid = true;
        while(dn > 0)
        {
            auto m = dn % 10;
            if(m == 7)
            {
                valid = false;
                break;
            }
            dn /= 10;
        }
        if(!valid) continue;

        auto on = n;
        while(on > 0)
        {
            auto m = on % 8;
            if(m == 7)
            {
                valid = false;
                break;
            }
            on /= 8;
        }
        if(!valid) continue;

        ans++;
    }
    cout << ans << endl;
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
long long A[10010];
int main()
{
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
        scanf("%lld",&A[i]);

    long long ans=A[0];

    for(int i=0;i<N;i++)
    {
        long long minimum=A[i];
        for(int j=i;j<N;j++)
        {
            minimum=min(minimum,A[j]);
            ans=max(ans,minimum*(j-i+1));
        }
    }
    printf("%lld",ans);

    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define irep(i,a,b) for(int i=int(a);i<(int)b;++i)
#define rrep(i,a,b) for(int i=int(a);i>=(int)b;--i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll,ll>>>
#define vpl vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define pb push_back
#define se second
#define fi first
#define all(v) v.begin(),v.end()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>

using namespace std;

template<typename T> istream& operator>>(istream&i,v(T)&v){rep(j,v.size())i>>v[j];return i;}
template<typename T> string join(const v(T)&v){stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T> ostream& operator<<(ostream&o,const v(T)&v){if(v.size())o<<join(v);return o;}

using ll = long long;
const ll INF = LLONG_MAX-1e9;
const double PI = acos(-1);

const ll mod = 1e9 + 7; //998244353;

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

ll modpow(ll a,ll b){
    if(b == 0){
        return 1;
    }
    if(b%2 == 0){
        ll tmp = modpow(a,b/2);
        return tmp*tmp%mod;
    }else{
        return modpow(a,b-1)*a%mod;
    }

}

//区間最大値または最小値を求めるセグメント木の構造体

template <typename T>
struct RMQ {
    const T INF = numeric_limits<T>::max();
    T bound;  //最小値のときはinf,それ以外の時0となる
    int n;
    bool flag; //最大値でtrue
    vector<T> dat;
    RMQ(int n_,bool flag_ = true) : n(),flag(flag_), dat(n_ * 4,flag_ ? 0 : INF){
        int x = 1;
        while(n_ > x){
            x *= 2;
        }
        n = x;
        if(flag_){
            bound = 0;
        }else{
            bound = INF;
        }
    }

    T func(T a,T b){
        if(flag){
            return max(a,b);
        }else{
            return min(a,b);
        }
    }

    void update(int i,T x){
        i += n - 1;
        dat[i] = x;
        while(i > 0){
            i = (i-1)/2;
            dat[i] = func(dat[i*2+1],dat[i*2+2]);
        }
    }

    T query(int a,int b){
        return query_sub(a,b,0,0,n);
    }

    T query_sub(int a,int b,int k,int l,int r){
        if(r <= a || b <= l){
            return bound;
        }else if(a <= l && r <= b){
            return dat[k];
        }else{
            T v_l = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T v_r = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return func(v_l, v_r);
        }
    }

};

ll dp[10005][10005];

int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vl a(n);
    cin >> a;
    ll ans = 0;
    rep(i,n){
        int l = i,r = i;
        while(l >= 0){
            --l;
            if(a[l] < a[i] || l == -1){
                l++;
                break;
            }
        }
        while(r < n){
            r++;
            if(a[r] < a[i] || r == n){
                --r;
                break;
            }
        }

        ans = max(ans,a[i]*(r-l+1));
    }
    cout << ans << endl;
    return 0;
}


// Author:   old_school
// Created:  18.04.2021 17:30:11

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back
#define F                 first
#define S                 second
#define nl                '\n'
#define YES               cout<<"YES";
#define NO                cout<<"NO";
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define MOD               1000000007
#define tod               (long long)1e5
#define pi                3.14159265358979323844
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define jot(n)            for(lld j=0;j<n;j++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;

template <typename T>
bool mycomp(T x,T y){
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){
return x.second<y.second;
}

void solve(){
   lld a,b; cin>>a>>b;
   vector<lld> A,B;
   lld r=1;
   lld za=a,zb=b;
   lld sa=0,sb=0;
   while(za--) sa+=r,A.pb(r++);
   r=-1;
   while(zb--) sb+=abs(r),B.pb(r--);
   if(sa>sb){
   	B[b-1]-=(sa-sb);
   }
   else if(sa<sb){
   	A[a-1]+=(sb-sa);
   }
   for(auto &p:A) cout<<p<<" ";
   for(auto &p:B) cout<<p<<" ";
}
int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld t=1; //cin>>t;
      while(t--){
            solve();
            cout<<endl;
      }
}

#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define db double
#define endl "\n"
#define f first
#define se second
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll power(ll x, ll y) {ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, MOD - 2);}

using namespace std;
ll a[10000000],b[10000000];
int main()
{
	quick;
#ifndef ONLINE_JUDGE
    freopen("C:/coding/input.txt", "r", stdin);
    freopen("C:/coding/output.txt", "w", stdout);
#endif

		ll m,h;
		string s;
		cin>>m>>h;
		if(h%m==0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;

 cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;

typedef long long int ll;
typedef string str;

ll power(ll x, ll y, ll p)
{
    ll res = 1;

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

ll nCrModP(ll n, ll r, ll p)
{
    if (!r)
      return 1;

	ll fac[n+1];
   	fac[0] = 1;
    for (ll i=1 ; i<=n; i++)
        fac[i] = fac[i-1]*i%p;

    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p;
}

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

void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{

	ll t,n,m,k,i,j,a,b;
	// cin >> t;
    str st,s;
    cin >> n >> k;
    while(k>0)
    {
        if(n%200==0)
        {
            n/=200;
        }
        else
        {
            n*=1000;
            n+=200;
        }
        k--;
    }
    cout << n << "\n";
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pp=pair<int,int>;
const ll INF=1e9;
const ll mod=1e9+7;

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

  stack<int> ss, res;
  int m=0;
  int i=0;
  while (i<N) {
    if (i+2<N && s[i]=='f' && s[i+1]=='o' && s[i+2]=='x') {
      m++;
      i+=3;
    }

    else if (i+1<N && s[i]=='f' && s[i+1]=='o') {
      ss.push(2);
      i+=2;
    }

    else if (i<N && s[i]=='f') {
      ss.push(1);
      i++;
    }

    else if (ss.size()>0 && i<N && s[i]=='x') {
      int sss=ss.top();
      if (sss==2) {
        m++;
        i++;
        ss.pop();
      }
      else {
        ss=res;
      }
    }

    else if (ss.size()>0 && i+1<N && s[i]=='o' && s[i+1]=='x') {
      int sss=ss.top();
      if (sss==1) {
        m++;
        i+=2;
        ss.pop();
      }
      else {
        ss=res;
      }
    }
    else if (ss.size()>0 && i<N && s[i]=='o') {
      int sss=ss.top();
      if (sss==1) {
        ss.pop();
        ss.push(2);
        i++;
      }
      else {
        ss=res;
      }
    }
    else {
      ss=res;
      i++;
    }
  }
  cout << N-3*m << endl;
}


#include <bits/stdc++.h>
/*
// using ASL (use make)
#include <atcoder/all>
using namespace atcoder;
*/
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
// 1次元 vector print
template <class T>
ostream &operator<<(ostream &s, vector<T> vec) {
    for (int i = 0; i < (int)vec.size(); ++i) {
        if (i > 0) {
            s << " ";
        }
        s << vec[i];
    }
    return s << endl;
}
// 2次元 vector print
template <class T>
ostream &operator<<(ostream &s, vector<vector<T>> vec2) {
    for (int i = 0; i < (int)vec2.size(); ++i) {
        s << vec2[i];
    }
    return s;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    char C1, C2, C3;
    cin >> C1 >> C2 >> C3;
    if (C1 == C2 && C2 == C3) {
        cout << "Won\n";
    } else {
        cout << "Lost\n";
    }
    return 0;
}

//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

/*
ビット全探索
for(int bit=0;bit<(1<<n);bit++){
        for(int i=0;i<n;i++){
            if(bit & (1<<i)){
            }
        }
*/

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

signed main(){
    //小数の桁数の出力指定
    //cout<<fixed<<setprecision(10);
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    string s;
    cin>>s;
    rep(i,s.size()){
        if(i%2==1)if(s[i]-'a'>=0){
            cout<<"No"<<endl;
            return 0;
        }
        if(i%2==0)if(s[i]-'Z'<=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

const int MOD = 998244353;
int f[200002];
int find(int x) {
	return f[x] == x ? f[x] : f[x] = find(f[x]);
}

int main() {
	int n; cin >> n;
	REP(i, n) f[i] = i;
	REP(i, n) {
		int x; cin >> x;
		f[find(x)] = find(i);
	}
	int res = 1;
	REP(i, n)
		if (f[i] == i)
			res = (res<<1) % MOD;
	cout << res-1 << '\n';
	return 0;
}

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

#define amax(a, b) a = std::max(a, b)
#define amin(a, b) a = std::min(a, b)

using ll = long long;

std::pair<int, int> log3(int n) {
    int i;
    // std::cerr << ": " << n << std::endl;
    for (i=0; n % 3 == 0; n /= 3, i++);
    // std::cerr << "=> " << i << ' ' << n % 3 << std::endl;
    return {i, n % 3};
}

int main() {
    int n;
    std::string s;
    std::cin >> n >> s;
    std::map<char, int> zip {
        {'B', 0},
        {'W', 1},
        {'R', 2},
    };
    std::string unzip = (n % 2 == 1 ? "BWR" : "BRW");
    int sum = 0;
    ll comb_r = 1;
    int cnt3 = 0;
    for (int i=0; i<n; i++) {
        int comb = (cnt3 == 0 ? comb_r : 0);
        sum = (sum + zip[s[i]] * comb) % 3;

        if (i == n-1) break;

        auto [loga, vala] = log3(n - i - 1);
        auto [logb, valb] = log3(i + 1);

        int valb_inv = valb;

        comb_r = comb_r * vala * valb_inv % 3;
        cnt3 += loga - logb;
        // std::cerr << sum << ' ' << comb_r << ' ' << cnt3 << std::endl;
    }
    std::cout << unzip[sum] << '\n';
    return 0;
}


#pragma GCC optimize("Ofast")

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pop_b pop_back
#define pf push_front
#define pop_f pop_front
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld;
typedef vector<int> vi;
typedef vector<set<ll>> vset;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef deque<ll> dql;
typedef deque<int> dqi;
typedef unsigned long long ull;
typedef tuple<int,int,int> State;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << ", ";
	err(++it, args...);
	cout<<"\n";
}

#define vmax(type)   std::numeric_limits<type>::max()
#define vmin(type)   std::numeric_limits<type>::min()
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;
#define resize_vec(a) a.resize(unique(a.begin(), a.end()) - a.begin());
#define ms(dp, x) memset(dp, x, sf(dp))
#define endl '\n'

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

const ll mod = 1e9 + 7;
const ll N = 1000005;
const ll inf = 1e9;

void solve()
{
	ll n, a, b;
	cin>>n>>a>>b;
	cout<<n+b-a<<endl;
}

// #define _DEBUG
// #define testCases
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(15);

	int tc = 1;
#ifdef testCases
	cin>>tc;
#endif
	for(int t = 1; t <= tc; t++)
	{
#ifdef _DEBUG
	int tt = clock();
#endif
		// cout<<"Case #"<<t<<": ";
		solve();

#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif
	}
	return 0;
}

//Codeforcesで128bit整数を使いたいとき
//→__int128_tを使う&GNU C++17 (64)で提出する

//インクルードなど
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
typedef long long ll;

//イテレーション
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//x:コンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による
//略記
#define F first
#define S second
//出力(空白区切りで昇順に)
#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl;
#define coutall(x) {for(int i=0;i<sizeof(x)/sizeof(x[0]);i++){cout<<x[i]<<"|";};};cout<<endl;
//aをbで割る時の繰上げ,繰り下げ
ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}

signed main(){
    ll x;cin>>x;ll y=0;
    FOR(a,1,x){FOR(b,1,x){
        if(x<a*b){break;};
        y+=myfloor(x,a*b);
    };};cout<<y;
}


#include <bits/stdc++.h>
using namespace std;
#define show(a) for(auto e:a)cout<<e<<" ";cout<<endl
#define size(a) static_cast<int>((a).size())

int main(){
  long long n, maxb, powb, ans = LLONG_MAX, a, c;
  cin >> n;
  maxb = log(n) / log(2);
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  for(int b = 0; b < maxb; ++b){
    powb = static_cast<long long>(pow(2.0, b));
    a = n / powb;
    c = n - a * powb;
    ans = min(ans, a + b + c);
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-7;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

void Add(ll &a, ll b){
    a=(a+b)%mod;
    return;
}

void Mul(ll &a, ll b){
    a=(a*b)%mod;
    return;
}

bool nana(ll x, ll n){
    if(!x) return false;
    if(x%n==7) return true;
    return nana(x/n,n);
}

int main(){
    ll N; cin>>N;
    ll ans=0;
    REP(i,1,N+1) if(!nana(i,10) && !nana(i,8)) ans++;
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test() int t; cin>>t; while(t--)
#define all(v) v.begin(),v.end()
#define st(v) sort(all(v))
#define stA(arr,n) sort(arr,arr+n)
#define dps(n,c) vector<vector<ll>> dp(n,vector<ll>(c,0))
#define vc(v,n,f) vector<ll> v(n,f)
#define vct(v) vector<ll> v
#define findInVec(v,key) (find(all(v),key)!=v.end())
#define findInSet(v,key) (v.find(key) != v.end())
#define findInStr(s,key) (s.find(key) != string::npos)
#define findInMap(m,key) (mp.find(key) != mp.end())
#define prt(i) cout<<i<<"\n"
#define fos(v) for(auto x:v)
#define fo(m,n,i) for(int i=m;i<n;i++)
#define Fo(m,n,i) for(int i=m;i>n;i--)
#define setbit(i) __builtin_popcount(i)
#define del(v,pos) v.erase(v.begin()+pos)
#define cnt(v,key) (count(all(v),key))
#define cnts(s,key) (s.count(key))
#define sumArr(a,s,e,sum)(accumulate(a+s,a+e,sum))
#define pb(c) push_back(c);
#define mod 1000000007
typedef long long ll;
using namespace std;
template <typename Kausi>
void debug(vector<Kausi> v){cout<<"v = [ ";ll n=v.size();fo(0,n,i){cout<<v[i];if(i<n-1)", ";}cout<<" ]\nlength = "<<v.size()<<"\n";}
ll stringToLong(string s){stringstream raaz(s);ll x = 0;raaz >> x;return x;}
string longToString(ll k){stringstream ss;ss<<k;string s; ss>>s; return s;}
bool isPowerOfTwo(int n){if(n==0) return false; return (ceil(log2(n)) == floor(log2(n)));}
void scanArr(int *arr,int n){fo(0,n,i) cin>>arr[i];}
void printArr(int *arr,int n){fo(0,n,i) cout<<arr[i]<<" ";}
template <typename Kausi>
void scanVector(vector<Kausi> &v,int n){fo(0,n,i){Kausi temp;cin>>temp;v.push_back(temp);}}
template <typename Kausi>
void printVector(vector<Kausi> v){fos(v) cout<<x<<" ";}
int main()
{
	IOS
    ll n;
    cin>>n;
    vector<ll> v(n);
    map<ll,ll> mp;
    fo(0,n,i){
        cin>>v[i];
        mp[v[i]]++;
    }
    ll ans=0;
    fo(0,n,i)
    {
        mp[v[i]]--;
        ll curr = mp[v[i]];
        ans+=(n-i-1-curr);
    }
    prt(ans);
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
template <typename T>
using orderedSet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using orderedMultiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld pi = 4.0 * atan(1.0);
#define xlr8                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);                   \
	cout.precision(10);               \
	cout << fixed

//76149
template <int D, typename T>
struct Vec : public vector<Vec<D - 1, T>>
{
	static_assert(D >= 1, "Vector dimension must be greater than zero!");
	template <typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...))
	{
	}
};
template <typename T>
struct Vec<1, T> : public vector<T>
{
	Vec(int n = 0, T val = T()) : vector<T>(n, val)
	{
	}
};

int main()
{
	xlr8;
	int testCases = 1;
	// cin >> testCases;
	while (testCases--)
	{
		int n;
		cin>>n;
		vector<int> a(n);
		map<int ,int> freq;
		for(int i = 0 ; i < n  ; i++)
			{
				cin>>a[i];
				freq[a[i]]++;
			}
		ll ans = 0;
		for(auto & k : freq)
		{
			ans += (1LL*k.second* (n - k.second));
		}
		cout<<ans/2<<"\n";

	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int a;
cin>>a;
if(a%2==0)
	cout<<"White";
else
	cout<<"Black";
}

//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <ctime> // へびになりたい
#include <bitset> // へびになった ｼｬｰ
#include <cassert>

// #include <atcoder/all>
// using namespace atcoder; // コンパイル重い

#define DB cerr<<"D"<<endl

using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
using P=pair<int,int>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
ll mod_pow(ll x, ll a, ll m) { ll an = 1; while(a > 0) { if (a&1) an = an * x % m; x = x * x % m; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;} bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
ll gcd(ll a, ll b) {if (b==0) return a; else return gcd(b, a%b);}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};

int main() {
  ll n; cin>>n;
  vector<string> v[2];
  v[0].push_back("AB");
  for(int i=0;i<n-1;i++) {
    int ii = i % 2;
    int jj = (i+1)%2;
    string st = "";
    for(int j=0;j<1<<(i+1);j++) st+="A";
    for(int j=0;j<1<<(i+1);j++) st+="B";
    v[jj].push_back(st);
    for(string s : v[ii]) {
      //cout << i << " " << s << endl;
      v[jj].push_back(s+s);
      string t;
      for(char ch : s) t += (ch == 'B') ? 'A' : 'B';
      v[jj].push_back(s+t);
    }
    v[ii].clear();
    v[ii].shrink_to_fit();
  }
  cout<<v[(n+1)%2].size()<<endl;
  for(string s : v[(n+1)%2]) {
    cout<<s<<endl;
  }
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


#include<bits/stdc++.h>
#include<cstdlib>
#include <algorithm>
#include <string>
using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

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

    int n;
    cin>>n;
    string t = "atcoder";
    for(int i=0;i<n;++i){
        string s;
        cin>>s;
        int m = (int)s.size();
        if(s > t){
            cout << 0 << endl;
            continue;
        }
        int num = inf;
        for(int i=0;i<m;++i){
            if(s[i] != 'a'){
                swap(s[1],s[i]);
                if(s > t) num = min(num,i-1);
                swap(s[1],s[i]);
                swap(s[0],s[i]);
                if(s > t) num = min(num,i);
                swap(s[0],s[i]);
                break;
            }
        }
        if(num == inf)cout << -1 << endl;
        else cout << num << endl;

    }
    return 0;

}

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

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

string t="atcoder";
int go() {
	string s; cin>>s;
	if (t<s) return 0;
	int ans=INF;
	for (int si=1;si<s.length();si++) if (s[si]>'a') chkmin(ans,si);
	if (s[0]=='a') {
		for (int si=2;si<s.length();si++) if (s[si]>'t') chkmin(ans,si-1);
	}
	if (ans>=INF/2)ans=-1;
	return ans;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int t; cin>>t;
    for (int i=0;i<t;i++) {
    	int ans=go();
    	cout<<ans<<endl;
    }
}


#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
ll calc[3000000]{0};
void pre(){
    calc[0]=1;
    for(int i=1;i<=2e6;i++){
        if(i%2==1)
            calc[i]=calc[i-1]+((i+2)/2)*2;
        else
            calc[i]=calc[i-1]+ ((i+2)/2)*2 - 1;
    }
}
void solve(){
    ll l,r;cin>>l>>r;
    if(r<2*l){
        cout<<0<<"\n";
    }else{
        cout<<calc[r-2*l]<<"\n";
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }
}

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define DEBUG
#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
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = (1<<30)-1;
const ll linf = 1LL<<61;
const int MAX = 510000;
int dy[8] = {0,1,0,-1,1,-1,-1,1};
int dx[8] = {-1,0,1,0,1,-1,1,-1};
const double pi = acos(-1);
const double eps = 1e-9;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    int sz = a.size();
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr;
        sz--;
        if(sz) cout << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    int n; cin >> n;
    int sum = 0;
    for(int i=1; i<=n; i++){
        sum += i;
        if(sum >= n){
            cout << i << endl;
            return 0;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	auto read = [&](){
		int x; cin >> x;
		return x;
	};
	vector<int> a(4);
	for(int & v : a) v = read();
	sort(a.begin(), a.end());
	if(a[0] + a[3] == a[1] + a[2] || a[3] == a[0] + a[1] + a[2]) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    string x;
    cin >> x;
    int i=0;
    for(int i=0; i<x.length(); i++){
        if( ( (i%2!=0)&&(x[i]>='a')&&(x[i]<='z') ) || ( (i%2==0)&&(x[i]>='A')&&(x[i]<='Z') ) ) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll a,b,x,y;
  cin >> a >> b >> x >> y;
  ll ans=0;
  if(a>b){
    if(2*x>y){
      ans=x;
      for(int i=0;i<a-b-1;i++){
        ans+=y;
      }
    }else{
      ans=x;
      a--;
      for(int i=0;i<2*(a-b);i++){
        ans+=x;
      }
    }
  }else if(a==b){
    ans=x;
  }else{
    if(2*x>y){
      ans=x;
      for(int i=0;i<b-a;i++){
        ans+=y;
      }
    }else{
      if(2*x>y){
        ans=x;
        for(int i=0;i<b-a;i++){
          ans+=y;
        }
      }else{
        ans=x;
        for(int i=0;i<2*(b-a);i++){
          ans+=x;
        }
      }
    }
  }
  cout << ans;
}

#include<bits/stdc++.h>
using namespace std;
long long a[200005],b[200005];
int main()
{
    int k,n,m;
    cin>>k>>n>>m;
    for (int i=1;i<=k;i++){
        cin>>a[i];
    }
    priority_queue<pair<long long,int> > q;
    long long cn=m;
    double c=1.0*m/n;
    for (int i=1;i<=k;i++){
      b[i]=(int)(c*a[i]);
    cn-=b[i];
    q.push({-b[i]*n+a[i]*m,i});
    //cout<<-b[i]*n+a[i]*m<<" ";
    }
    while(cn--)
    {
        pair<long long ,int> now=q.top();
        q.pop();
        int i=now.second;
        b[i]++;
        q.push({-b[i]*n+a[i]*m,i});
    }
    for (int i=1;i<=k;i++) cout<<b[i]<<" ";
    cout<<endl;
    return 0;
}


/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)         v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 1000000007
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}

using namespace std;

const int N = 1000005;
int c = 1;

void solve() {
    int n;
    cin >> n;
    string s[n];
    map<string, int> mp;
    for(int i = 0; i < n; i++) {
        cin >> s[i];
        if(s[i][0] == '!') continue;
        mp[s[i]]++;
    }
    for(int i = 0; i < n; i++) {
        if(s[i][0] == '!') {
            string t = s[i];
            t.erase(t.begin());
            if(!mp[t]) continue;
            cout << t << '\n';
            return;
        }
    }
    cout << "satisfiable\n";
}

int main() {
    /*int tc;
    cin >> tc;
    while(tc--)*/
    solve();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
map<string, int> m;
int main(){
  int n;
  cin >> n;
  string ans = "satisfiable";
  for(int i = 0; i < n; i++){
    char a[20];
    cin >> a;
    if(a[0] == '!'){
      if(m[a+1] == 1){
        ans = a+1;
      }
      else{
        m[a+1] = 2;
      }
    }
    else{
      if(m[a] == 2){
        ans = a;
      }
      else{
        m[a] = 1;
      }
    }
  }
  cout << ans << '\n';

}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 200005;

int n;
int a[MAXN << 1];

priority_queue<int,vector<int>,greater<int> > taken;

int main()
{
	scanf("%d",&n);
	for (int i = 1;i <= n * 2;i++)
		scanf("%d",&a[i]);
	for (int i = n;i >= 1;i--)
	{
		int u = a[i],v = a[2 * n - i + 1];
		if (u < v)
			swap(u,v);
		taken.push(u);
		if (taken.top() < v)
		{
			taken.pop();
			taken.push(v);
		}
	}
	long long ans = 0;
	while (!taken.empty())
	{
		ans += taken.top();
		taken.pop();
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define endl '\n'
#define int long long
#define Bit(x, k) (((x) >> (k)) & 1)
#define Xor(x, k) ((x) ^ (1 << (k)))

signed main() {
  // freopen("in" , "r", stdin );
  cin.tie(0)->sync_with_stdio(0);
  int n; cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  int ans = 2e9;
  for (int mask = 0; mask < (1 << n); mask++) {
    int cal = 0, val = 0, mode = -1;
    for (int i = 0; i < n; i++) {
      int m = Bit(mask, i);
      if (m != mode) {
        mode = m;
        cal ^= val;
        val = a[i];
      }
      else val |= a[i];
    }
    cal ^= val;
    ans = min(ans, cal);
  }
  cout << ans << endl;
}


#include <iostream>
#pragma GCC optimize("O3")
#define int unsigned long long
using namespace std;

bool check(int n,int x){
    if(x%n!=1)return 1;
    return 0;
}

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

signed main(){
    int n;
    cin>>n;
    int sum=1;
    for(int i=2;i<=n;i++){
        if(sum%i==0)continue;
        int k=gcd(sum,i);
        sum=sum/k*i;
    }
    cout<<sum+1<<'\n';
}

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

typedef long long int ll;
#define deb(x) cout << #x << " " << x << endl;
#define debtwo(x,y) cout << x << ", " << y << endl;
#define mod 1000000007
#define N 1000001

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

	ll res = 1;
	vector<bool> primes(31, true);

	for (int i = 2; i <= 5; i++) {
		if (primes[i]) {
			for (int j = i * i; j <= 30; j += i) {
				primes[j] = false;
			}
		}
	}

	for (int i = 2; i <= n; i++) {
		if (primes[i]) {
			res = i * res;
			if (i == 3 || i == 5)
				res = i * res;
			if (i == 3)
				res = i * res;
		}
		else if (i == 4) {
			res = i * i * res;
		}
	}

	cout << res + 1 << endl;
}

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

	ll t = 1;
	//cin >> t;

	while (t--) {
		solve();
	}
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
#include <sstream>
#include <map>
#include <unordered_map>
#include <cmath>

// #include <boost/numeric/ublas/vector.hpp>
// #include <boost/numeric/ublas/matrix.hpp>
// #include <boost/numeric/ublas/io.hpp>

// namespace ublas = boost::numeric::ublas;
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)

// const LLI MAX = 100000001;

using VALUE = int;
using SIZE = int;

int valueOf(vector<SIZE> hako, vector<pair<VALUE, SIZE>> nimotsu) {
    std::sort(hako.begin(), hako.end());

    // int j = 0;
    // for (auto h : hako) {
    //     while (j < int(nimotsu.size())) {
    //         auto a = nimotsu[j++];
    //         if (h >= a.second) {
    //             val += a.first;
    //             break;
    //         }
    //     }
    // }

    int val = 0;
    vector<int> X(hako.size(), 0);
    for (auto p : nimotsu) {
        bool f = false;
        for (int j = 0; j < hako.size(); j++) {
            if (X[j] == 0 && hako[j] >= p.second) {
                X[j] = p.first;
                val += p.first;
                f = true;
                break;
            }
        }
    }

    return val;
}

int main(int argc, char *argv[])
{

    int N, M, Q;
    cin >> N >> M >> Q;

    vector<pair<VALUE, SIZE>> nimotsu;
    Rep(i, N) {
        int w, v;
        cin >> w >> v;
        nimotsu.emplace_back(v, w);
    }

    vector<SIZE> hako(M);
    Rep(i, M) {
        cin >> hako[i];
    }

    vector<pair<int, int>> query;
    Rep(i, Q) {
        int s, e;
        cin >> s >> e;
        query.emplace_back(s-1, e-1);
    }

    sort(nimotsu.begin(), nimotsu.end(), greater<pair<VALUE, SIZE>>());

    for (pair<int, int> q : query) {
        vector<SIZE> temp;
        for (int i = 0; i < q.first; i++) {
            temp.push_back(hako[i]);
        }
        for (int i = q.second + 1; i < hako.size(); i++) {
            temp.push_back(hako[i]);
        }

        int val = valueOf(temp, nimotsu);

        cout << val << endl;
    }

    return 0;
}

#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int digit(int n){
   if(n < 10)  return n;
   return digit(n/10) + n%10;
}
int main(){
  int A,B;
  cin>>A>>B;
  cout<<A/B;
return 0;}


#include<bits/stdc++.h>
using namespace std;
int h,m;
int main()
{
	scanf("%d %d",&m,&h);
	if(h%m==0) printf("Yes");
	else printf("No");
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n, w;
	cin >> n >> w;
	cout << n / w;
	return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int n;
    int min = 100000;
    for (int i = 1; i <= 4;i++){
        cin >> n;
        if(n<min)
            min = n;
    }
    cout << min;
    return 0;
}

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

#define ll long long int
#define pb push_back
#define RONALDO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pii pair<ll, ll>
#define ff first
#define ss second
#define mod 1000000007
#define vi vector<ll>
#define mi map<ll, ll>
#define Max(x, y, z) max(x, max(y, z))
#define Min(x, y, z) min(x, min(y, z))

//LOVE U MEssi10 && ROnaldo7 !!

//INSPIRATIONAL MICHAEL PHELPS && USAIN BOLT !!

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

     cout << min({a,b,c,d});
     return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
// typedef pair<int,P> IP;
// typedef pair<P,P> PP;
double const PI=3.141592653589793;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll N;

void dfs(int v, int p, ll d, vector<ll> &dist, vector<vector<P>> &G){
    dist[v]=d;
    repr(e,G[v]){
        if(e.first!=p) dfs(e.first,v,d^e.second,dist,G);
    }
}

int main(){
    cin>>N;
    vector<vector<P>> G(N,vector<P>());
    rep(i,N-1){
        ll u,v,w;
        cin>>u>>v>>w;
        u--, v--;
        G[u].push_back({v,w});
        G[v].push_back({u,w});
    }

    vector<ll> dist(N,0);
    dfs(0,-1,0,dist,G);

    vector<ll> cnt(60,0);
    rep(i,N){
        rep(j,60) cnt[j]+=dist[i]>>j&1;
    }

    ll ans=0;
    ll two=1;
    rep(i,60){
        ans+=cnt[i]*(N-cnt[i])%MOD*two%MOD;
        ans%=MOD;
        two*=2;
        two%=MOD;
    }

    cout<<ans<<endl;

    return 0;
}

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

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

//みんなよく解けるなぁ

const int CM = 1 << 17, CL = 20;
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;
const ll ma10 = ma1 & (1ll << 32) - 1;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	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;
	return tmp;
}
const ll pre[9] = { 1,10,100,1000,10000,100000,1000000,10000000,100000000 };
inline ll getll_karini_sakusei() {
	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;
		ll tmp2 = *(ll*)ci;
		if ((tmp2 & ma0) ^ ma0) {
			int dig = 68 - __builtin_ctzll((tmp2 & ma0) ^ ma0);
			if (dig == 64) {
				ci++;
				return tmp;
			}
			tmp2 = tmp2 << dig & ma1;
			tmp2 = tmp2 * 10 + (tmp2 >> 8) & ma2;
			tmp2 = tmp2 * 100 + (tmp2 >> 16) & ma3;
			tmp2 = tmp2 * 10000 + (tmp2 >> 32) & ma4;
			ci += (72 - dig >> 3);
			tmp = tmp * pre[64 - dig >> 3] + tmp2;
		}
		else {
			tmp2 = tmp2 & ma1;
			tmp2 = tmp2 * 10 + (tmp2 >> 8) & ma2;
			tmp2 = tmp2 * 100 + (tmp2 >> 16) & ma3;
			tmp2 = tmp2 * 10000 + (tmp2 >> 32) & ma4;
			ci += 8;
			tmp = tmp * pre[8] + tmp2;
			tmp2 = *(ll*)ci;
			int dig = 36 - __builtin_ctzll((tmp2 & ma0) ^ ma0);
			tmp2 = tmp2 << dig & ma10;
			tmp2 = tmp2 * 10 + (tmp2 >> 8) & ma2;
			tmp2 = tmp2 * 100 + (tmp2 >> 16) & ma3;
			ci += (40 - dig >> 3);
			tmp = tmp * pre[32 - dig >> 3] + tmp2;
		}
	}
	return tmp;
}

const int mod = 1e9 + 7;
int to[400001], ne[400001], he[200001], Q[200001], q;
ll w[200001], W[200001];
ll kazu[20];
const ll mk = 1ll << 40 | 1 << 20 | 1, mk2 = (1ll << 20) - 1;

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

	int N = getint();
	for(int i = 2; i < 2 * N; i++) {
		int u = getint(), v = getint();
		w[i >> 1] = getll_karini_sakusei();
		to[i] = v;
		ne[i] = he[u];
		he[u] = i++;
		to[i] = u;
		ne[i] = he[v];
		he[v] = i;
	}

	Q[q++] = 1;
	rep(p, N) {
		for (int t = he[Q[p]]; t; t = ne[t]) {
			int u = to[t];
			if (he[u] >= 0) {
				W[u] = W[Q[p]] ^ w[t >> 1];
				Q[q++] = u;
			}
		}
		he[Q[p]] = -1;
	}

	ll kotae = 0;
	rep1(i, N) {
		rep(j, 20) kazu[j] += W[i] >> j & mk;
	}
	rep(j, 20) rep(k, 3) {
		ll tmp = (kazu[j] >> k * 20 & mk2);
		kotae += (1ll << k * 20 + j) % mod * tmp % mod * (N - tmp) % mod;
	}

	co(kotae % mod);

	Would you please return 0;
}