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

#define int              long long
#define pb              push_back
#define all(v)          v.begin(),v.end()
#define sz(a)           (int)a.size()
#define F               first
#define S               second
#define INF             2000000000000000000
#define popcount(x)     __builtin_popcountll(x)
#define pll             pair<int,int>
#define pii             pair<int,int>
#define ld              long double
#define bug(x) cerr<<"#x"<<" is "<<x<<endl;
const int M = 1000000007;
const int MM = 998244353;
const long double PI = acos(-1);

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{
    return os<<'('<<p.F<< ","<<p.S<<')';
}
int tError()
{
    int l,r;
    cin>>l>>r;
    if(l==0 && r==0)
    	return cout<<1<<endl,0;
    else if((l==r)or(r-2*l+1<=0))
    	return cout<<0<<endl,0;

    int ans=(r-2*l)+1;
    int anss=(ans*(ans+1))/2;
    cout<<anss<<endl;
    return 0;
}

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

    int TESTS=1;
    cin>>TESTS;
    while(TESTS--)
        tError();

    //    cerr << "Time taken: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";

    return 0;
}

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

int main()
{
    int n, a[1000], b[1000];
    cin>>n;
    for (int j = 0; j < n; j++)
    cin>>a[j]>>b[j];
    int min = a[0], mini = 0;
    for (int i = 1; i < n; i++)
    {
        if(a[i]<min)
        {
            min = a[i];
            mini = i;
        }
    }
    b[mini] = a[mini]+b[mini];
    int mi = b[0], mii = 0;
    for (int k = 1; k < n; k++)
    {
        if(b[k]<mi)
        {
            mi = b[k];
            mii = k;
        }
    }
    if(mini==mii)cout<<b[mii];
    else
    printf("%d", max(a[mini], b[mii]));
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const long long INF=1e9+7;
int main(){
	IOS;
	long long n;
	cin>>n;

	long long i=1;
	while(i*(i+1)<2*n){
		i++;
	}
	cout<<i<<endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return ((a * b) / gcd(a, b)); }
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ld n;
	cin >> n;
	cout << ceil(-0.5 + pow(1 + 8 * n, 0.5) * 0.5);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
int bitmask[18];
int bits[20];
int dp[2000000];
bool chMap[2000000];
bool check(int state){

    for (int i=0;i<18;++i)
        if ((bits[i]&state) && (bitmask[i]&state)!=state) return false;
    return true;

}
int solve(int n){
    chMap[0]=true;
    for (int state=1;state<bits[n];++state)
        chMap[state]=check(state);

    dp[0]=0;
    for (int state=1;state<bits[n];++state){
        dp[state]=INT_MAX;
        //if (state%1000==0) cout<<"1000!\n";
        for (int sub=state;sub!=0;sub=(sub-1)&state)
            if (chMap[sub]) dp[state]=min(dp[state],dp[state^sub]+1);
    }
    return dp[bits[n]-1];
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for (int i=0;i<20;++i) bits[i]=1<<i;
    for (int i=0;i<m;++i){
        int u,v;
        scanf("%d%d",&u,&v);
        u--; v--;
        bitmask[u]|=bits[v];
        bitmask[v]|=bits[u];
    }
    for (int i=0;i<n;++i){
        bitmask[i]|=bits[i];
    }
    printf("%d",solve(n));
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n;
    ll x;
    cin >> n >> x;

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

    ll r = 1LL << 60;
    for (int k = 1; k <= n; k++) {
        int dp[101][100];
        for (int j = 0; j <= k; j++) {
            for (int b = 0; b < k; b++) {
                dp[j][b] = -(1 << 30);
            }
        }
        dp[0][0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = min(i + 1, k); j > 0; j--) {
                for (int b = 0; b < k; b++) {
                    int t = (b - a[i]) % k;
                    if (t < 0) t += k;
                    dp[j][b] = max(dp[j][b], dp[j - 1][t] + a[i]);
                }
            }
        }
        int t = dp[k][x % k];
        if (t < 0) continue;
        r = min(r, (x - t) / k);
    }

    cout << r << endl;

    return 0;
}


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

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

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> v(N+1, 0);

    rep(i, M) v[A[i]]++;

    vector<bool> ok(N+1, false);
    rep(i, N+1){
        if(v[i] == 0) ok[i] = true;
    }

    rep(i, N-M){
        int l = A[i], r = A[M+i];

        v[r]++, v[l]--;
        if(v[l] == 0) ok[l] = true;
    }

    rep(i, N+1){
        if(ok[i]) {cout << i << '\n'; return 0;}
    }
}

#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#ifdef LOCAL
#include "/Users/lbjlc/Desktop/coding/debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#define printg(...) ;
#define fprint(...) ;
#define fprintn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define maxi(x, y) x = max(x, y)
#define mini(x, y) x = min(x, y)
// long long fact(long long n) { if(!n) return 1; return n*fact(n-1); }
// #define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int get_random() {
    static uniform_int_distribution<int> dist(0, 1e9 + 6);
    return dist(rng);
}
#define solve_testcase int T;cin>>T;for(int t=1;t<=T;t++){solve(t);}

typedef unsigned long long ull;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;
#define bd(type,op,val) bind(op<type>(), std::placeholders::_1, val)

template<class T>
void make_unique(T & v) {
    sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
}
int geti() { int x; cin >> x; return x; }
long long getll() { long long x; cin >> x; return x; }
double getd() { double x; cin >> x; return x; }
// pair<int, int> a(geti(), geti()) does not work
// pair<int, int> a({geti(), geti()}) works, since it uses initializer.

const int MAXN = 3e5 + 100;

void solve(int tt) {
    // cout<<"Case #"<<tt<<": ";
}

ll cal(int n, int tot) {
	if(n+n<tot) return 0;
	if(n<tot) return n-(tot-n)+1;
	return tot-1;
}

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // solve_testcase;

    int n,k;
    cin>>n>>k;
    k=abs(k);

    long long res=0;
    rep(i,2,2*n+1) {
    	res+=cal(n,i)*cal(n,i+k);
    }
    cout<<res<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
int main()
{
string s;
cin>>s;int c1=0,c2=0,n=s.length();
for(int i=0;i<n;i++)
{
    if(i%2==0)
    {
       if(s[i]>=97&&s[i]<=122)
       {
           ++c1;
       }
    }
    if(i%2==1)
    {
        if(s[i]>=65&&s[i]<=90)
        {
            ++c2;
        }
    }
}
if(c1+c2==n)
{
    cout<<"Yes";
}
else
{
    cout<<"No";
}
    return 0;
}

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

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif

	int N;

	cin >> N;

	int tax = N * 1.08;

	if (tax < 206) {
		cout << "Yay!" << endl;
	} else if (tax == 206) {
		cout << "so-so" << endl;
	} else {
		cout << ":(" << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const ll mod =1000000007;
#define rep(i,n) for(ll i=0; i<n; i++)
int main(){
  double a,b;
  cin>>a>>b;

  cout<<fixed<<setprecision(10);
  cout<<(1-b/a)*100<<endl;
}

#include <bits/stdc++.h>

using namespace std;

int main(){
	int n, w;
  	cin >> n >> w;
	cout << n/w << endl;
    return 0;
}


#include<iostream>
#include<string>

using namespace std;

int main(){

	int n;
	string s;

	cin >> n >> s;

	int ans = 0;

	for(int l = 2; l <= n; l = l + 2){
		int anum = 0, tnum = 0, cnum = 0, gnum =0;

		string t = s.substr(0, l);
		for(int i = 0, size = t.size(); i < size; ++i){
			switch (t[i]){
				case 'A': ++anum; break;
				case 'T': ++tnum; break;
				case 'C': ++cnum; break;
				case 'G': ++gnum; break;
				default: break;
			}
		}

		if((anum == tnum)&&(cnum == gnum))++ans;

		for(int i = 1; i + l <= n; ++i){
			switch (s[i-1]){
				case 'A': --anum; break;
				case 'T': --tnum; break;
				case 'C': --cnum; break;
				case 'G': --gnum; break;
				default: break;
			}
			switch (s[i + l -1]){
				case 'A': ++anum; break;
				case 'T': ++tnum; break;
				case 'C': ++cnum; break;
				case 'G': ++gnum; break;
				default: break;
			}

			if((anum == tnum)&&(cnum == gnum))++ans;
		}
	}

	cout << ans;
	fflush(stdout);
	return 0;
}

/*
"An anomaly, I'm Muhammad Ali
  Cause I know one day I'm gonna be the"
                - Greatest, Eminem
*/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#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;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;

int main(){
    Shazam;
    ll n, x; cin >> n >> x;
    string s; cin >> s;
    for(char c : s){
        x = max(0LL, x + ((c=='x')?-1:1));
    }
    cout << x << endl;
    return 0;
}


#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve(int tc)
{
	int n;
	string s;
	cin >> n >> s;
	map<char, int> id;
	id['A'] = 0;
	id['C'] = 1;
	id['G'] = 2;
	id['T'] = 3;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		v32 cnt(4, 0);
		for (int j = i; j < n; j++)
		{
			cnt[id[s[j]]]++;
			if (cnt[0] == cnt[3] && cnt[1] == cnt[2])
				ans++;
		}
	}
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}

/*
Author: rafa45
Date: 28 Sep 2020
*/
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define mod 1000000007
using namespace std;

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

    int i=0, j=0, n=0;
    int c1=0, c2=0, cnt=0;
    string s, sub;

    cin >> n >> s;

    for(i=0; i<n-1; i++){
        c1=0; c2=0;
        for(j=i; j<n; j++){
            if(s[j]=='A') c1++;
            else if(s[j]=='T') c1--;
            else if(s[j]=='C') c2++;
            else c2--;
            if(c1==0 && c2==0) cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    long a;
    long sum = 0;
    long sum1 = 0;
    for (long i = 0; i < n; i++)
    {
        cin >> a;
        sum += a;
        sum1 += a * a;
    }
    cout << n * sum1 - sum * sum << endl;
    return 0;
}

#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
using namespace std;
#define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
typedef long long ll;
ll a[402]={0};
int main(void)
{
	ll n;
	scanf("%lld",&n);
	for(ll i=0;i<n;i++)
	{
		ll v;
		scanf("%lld",&v);
		a[v+200]++;
	}
	ll ans=0;
	for(ll i=-200;i<=200;i++)
	{
		for(ll j=i+1;j<=200;j++)
		{
			ans+=(i-j)*(i-j)*a[i+200]*a[j+200];
		}
	}
	printf("%lld\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define loops(i, s, n) for (ll i = s; i < (ll)n; i++)
#define loop(i, n) loops(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define pub push_back
#define pob pop_back
#define mp make_pair
#define dump(x) cerr << #x << " = " << (x) << endl;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vl;

// for dp
// 第一引数と第二引数を比較し、第一引数(a)をより大きい/小さい値に上書き
template <typename T>
inline bool chmin(T &a, const T &b)
{
  bool compare = a > b;
  if (a > b)
    a = b;
  return compare;
}
template <typename T>
inline bool chmax(T &a, const T &b)
{
  bool compare = a < b;
  if (a < b)
    a = b;
  return compare;
}

#define in_v(type, name, cnt) \
  vector<type> name(cnt);     \
  loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行

#define set_fix(x) ((std::cerr << std::fixed << std::setprecision(x)), (std::cout << std::fixed << std::setprecision(x)))

//cout for vector
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
  o << "{";
  for (int i = 0; i < (int)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}

// gcd
ll gcd(ll a, ll b)
{
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}

//prime numbers
bool IsPrime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;

  double sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += (ll)2)
  {
    if (num % i == 0)
    {
      return false;
    }
  }
  return true;
}
vector<ll> Eratosthenes(ll N)
{
  int arr[N];
  vector<ll> res;
  for (int i = 0; i < N; i++)
  {
    arr[i] = 1;
  }
  for (int i = 2; i < sqrt(N); i++)
  {
    if (arr[i])
    {
      for (int j = 0; i * (j + 2) < N; j++)
      {
        arr[i * (j + 2)] = 0;
      }
    }
  }

  for (int i = 2; i < N; i++)
  {
    if (arr[i])
    {
      res.push_back(i);
    }
  }
  return res;
}

//digit number
int GetDigit(ll num, ll radix)
{
  unsigned digit = 0;
  while (num != 0)
  {
    num /= radix;
    digit++;
  }
  return digit;
}

int digsum(ll n)
{
  ll res = 0;
  while (n > 0)
  {
    res += n % (ll)10;
    n /= (ll)10;
  }
  return res;
}

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

  sort(ALL(a), greater<ll>());
  for (int i = 0; i < n; i++)
  {
    sum += a[i];
    a_sum[i] = sum;
  }
  ll res = 0;
  for (int i = 0; i < n; i++)
  {
    res -= (i+1) * a[i] - a_sum[i];
  }
  cout << res << endl;
  return 0;
}

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

ll M = 998244353;
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(){
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    int n; cin >> n;
    vec<ll> a(n);
    rep(i, n) cin >> a[i];

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

    ll ans = 0;
    ll tmp = 0;
    for(int i = n-1; i>=0; i--) {
        tmp *= 2;
        tmp %= M;
        if (i < n-1) tmp += M - a[i+1], tmp %= M;

        tmp += a[i];
        tmp %= M;
        // cout << i << " " << a[i] * tmp << endl;
        ans += a[i] * tmp;
        ans %= M;
    }
    cout << ans << endl;

}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(int)(n);i++)
template <typename T> bool chmax(T &a, const T& b) {if (a < b) {a = b; return true;}return false;}
template <typename T> bool chmin(T &a, const T& b) {if (a > b) {a = b; return true;}return false;}
const int MOD = 1000000007;
ll x = 10000000000;

int main(){
    int a,b,c,d;
    cin >> a >> b;
    cin >> c >> d;
    cout << b-c << endl;

}

#include <bits/stdc++.h>

using namespace std;

int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int a, b;
	cin >> a >> b;
	int c = a * 2 + 100;
	int d = c - b;
	cout << d;
}


//  ██████  ██    ██ ██████  ██ ██   ██  ██████
// ██       ██    ██ ██   ██ ██ ██  ██  ██    ██
// ██   ███ ██    ██ ██████  ██ █████   ██    ██
// ██    ██ ██    ██ ██   ██ ██ ██  ██  ██    ██
//  ██████   ██████  ██   ██ ██ ██   ██  ██████

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int MAX=1e5+10;
const int INF=1e9;
const double PI=acos(-1);

int main() {
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    sort(a.begin(),a.end());
    if (a[2]-a[1]==a[1]-a[0]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (2 * a[1] == a[0] + a[2])
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
const int INF = 1000000000;
const int MOD = 1000000007;
const ll llINF = 1000000000000000000;

void solve() {
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(all(a));
  if (a[2] - a[1] == a[1] - a[0]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#include<bits/stdc++.h>
#include<math.h>

#define    str     string
#define    sz      size()
#define    bgn      begin()
#define    ll      long long int
#define    li      long int
#define    con     continue
#define    rt      return 0
#define    fr      first
#define    sec     second
#define    pf      push_front
#define    pb      push_back
#define    vb      vct.begin()
#define    ve      vct.end()
#define    vs      vct.size()
#define    db      dq.begin()
#define    de      dq.end()
#define    ds      dq.size()
#define    ib      it.begin()
#define    ie      it.end()
#define    itf     it->first
#define    its     it->second
#define    lb      lst.begin()
#define    le      lst.end()
#define    mb      mp.begin()
#define    me      mp.end()
#define    stb     st.begin()
#define    ste     st.end()
#define    sb      s.begin()
#define    se      s.end()
#define    NL      printf("\n")
#define   yes       printf("YES\n")
#define   no        printf("NO\n")
#define   forone    for(i=1;i<=n;i++)
#define   forzero   for(i=0;i<n;i++)
#define   sortone   sort(ara+1,ara+n+1)
#define   sortzero  sort(ara,ara+n)
#define   get(ara)  forone cin>>ara[i]
#define tc ll tc;scanf("%lld",&tc);while(tc--)

using namespace std;
int main( )
{

//tc
{

ll i,j,k,y,n,x,m,a,b,ans=0,sum=0,cnt=0;

ll c,mx=0,mn=INT_MAX,mod=1e9+7;

    str s,z,taj="No";
    cin>>n>>k;
    x=abs(n-k);
    if(x<=2) taj="Yes";
    cout<<taj;
    NL;
 }

    return 0;
}


#include <bits/stdc++.h>
#ifdef LILY
#include "./Debug.h"
#else
#define var(...) (0)
#define dbg(...) (0)
#endif
using int32 = int;
using int64 = long long;
using namespace std;

class Solution
{
#define int int64
#define sfor(i, n) for (int i = 1; i <= (n); ++i)
#define tfor(i, n) for (int i = 0; i < (n); ++i)

    int n, m, l, r, res;
    vector<int> x;
    using p = pair<int, int>;
    vector<p> t;

    void SHURU()
    {
        cin >> l >> r;
        --l, --r;
        res = 0;
    }

    void SHUCHU()
    {
        cout << res << endl;
    }

    void CHULI()
    {
        vector<int> cases;
        for (int i = 0; i < m; ++i)
        {
            if (i < l || i > r)
                cases.push_back(x[i]);
        }
        if (cases.size() == 0) return;
        sort(cases.begin(), cases.end());
        for (auto i : t)
        {
            auto j = lower_bound(cases.begin(), cases.end(), i.first);
            if (j == cases.end()) continue;
            cases.erase(j);
            res += i.second;
            if (cases.size() == 0) return;
        }
    }

public:
    Solution()
    {
        int q, s, y;
        cin >> n >> m >> q;
        tfor(i, n)
        {
            cin >> s >> y;
            t.emplace_back(s, y);
        }
        tfor(i, m)
        {
            cin >> s;
            x.push_back(s);
        }
        sort(t.begin(), t.end(), [](p a, p b) {
            return a.second > b.second;
        });
        while (q--)
        {
            SHURU();
            CHULI();
            SHUCHU();
        }
    }
#undef int
#undef tfor
#undef sfor
};

int32 main()
#ifndef LILY
{
    Solution();
}
#endif

// Problem: B - Reversible Cards
// Contest: AtCoder - AtCoder Regular Contest 111
// URL: https://atcoder.jp/contests/arc111/tasks/arc111_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

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

struct splitmix64_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

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

template <typename K, typename V, typename Hash = splitmix64_hash>
using hash_map = __gnu_pbds::gp_hash_table<K, V, Hash>;

template <typename K, typename Hash = splitmix64_hash>
using hash_set = hash_map<K, __gnu_pbds::null_type, Hash>;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

bool cycle, has[maxN], visited[maxN];
vi graph[maxN];

int DFS(int x, int prv) {
	int ile = 1;
	visited[x] = true;
	for (auto v: graph[x]) {
		// cout << x << " " << prv << ": " << v << endl;
		if (!visited[v]) {
			ile += DFS(v, x);
		} else {
			if (v != prv) {
				cycle = true;
			}
		}
	}
	return ile;
}

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	int mx = 0;
	REP(i, n) {
		int a, b; cin >> a >> b;
		graph[a].pb(b);
		graph[b].pb(a);
		mx = max(mx, max(a, b));
		has[a] = true;
		has[b] = true;
	}
	int ans = 0;
	RI(i, mx) {
		if (!has[i]) continue;
		if (!visited[i]) {
			int ile = DFS(i, -1);
			// cout << ile << " " << cycle << endl;
			ans += ile - !cycle;
			cycle = false;
		}
	}
	cout << ans;
	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793
//#include <atcoder/all>
//using namespace atcoder;
//using Mint = modint;

struct UnionFind{
	vector<int> par,siz;
	UnionFind(int N): par(N), siz(N){
		rep(i, N){
			par[i] = i; siz[i] = 1;
		}
	}
	int root(int x){
		if(par[x]==x) return x;
		else return root(par[x]);
	}
	void unite(int x, int y){
		x=root(x); y=root(y);
		if(x==y) return;
		if(siz[x] < siz[y]) swap(x, y);
		par[y] = x;
		siz[x] += siz[y];
	}
	bool same(int x, int y){
		return root(x)==root(y);
	}
	int size(int x){
		return siz[root(x)];
	}
};

int main(){
  int h, w; cin >> h >> w; string s[h]; UnionFind uf(2020);
  rep(i, h){
    cin >> s[i];
  }
  uf.unite(0, w-1);
  uf.unite(w, h+w-1);
  rep(i, h){
    set<int> yoko;
    rep(j, w){
      if((i==0 || i==h-1) && s[i][j]=='#'){
        uf.unite(0, j);   //cout << 0 << " " << j << endl;
      }
      if(s[i][j]=='#') yoko.insert(j);
    }
    auto itr = yoko.begin();
    for(auto k: yoko){
      uf.unite(*itr, k);
      //cout << *itr << " " << k << endl;
    }
    yoko.clear();
  }
  rep(j, w){
    set<int> tate;
    rep(i, h){
      if((j==0 || j==w-1) && s[i][j]=='#'){
        uf.unite(w, w+i);   //cout << w << " " << w+i << endl;
      }
      if(s[i][j]=='#') tate.insert(w+i);
    }
    auto itr = tate.begin();
    for(auto k: tate){
      uf.unite(*itr, k);
      //cout << *itr << " " << k << endl;
    }
    tate.clear();
  }
  set<int> ansa, ansb;
  rep(i, w){
    ansa.insert(uf.root(i));
  }
  for(int i=w; i<=h+w-1; i++){
    ansb.insert(uf.root(i));
  }
  cout << min(ansa.size()-1, ansb.size()-1) << endl;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> Pair;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    int N; double D,H; cin >> N >> D >> H;
    VI d(N),h(N); REP(i,N) cin >> d[i] >> h[i];

    double ng = 0, ok = 1000;
    REP(_,50){
        double b = (ok+ng)/2;
        double a = (H-b)/D;
        bool flag = true;
        REP(i,N){
            if(a*d[i]+b < h[i]){
                flag = false;
                break;
            }
        }
        if(flag) ok = b;
        else ng = b;
    }
    cout << ok << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    while(t--) Main();
    return 0;
}


#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0, length = n; i < length; i++)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ep emplace
#define epb emplace_back
#define scll static_cast<long long>
#define sz(x) static_cast<int>((x).size())
#define pfll(x) printf("%lld\n", x)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define ci3(x, y, z) cin >> x >> y >> z
#define ci4(w, x, y, z) cin >> w >> x >> y >> z
#define co(x) cout << x << endl
#define co2(x, y) cout << x << " " << y << endl
#define co3(x, y, z) cout << x << " " << y << " " << z << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int>> PQG;
typedef priority_queue<P> PQP;
typedef priority_queue<P, vector<P>, greater<P>> PQPG;

const int MAX_N = 2e5, MOD = 1e9 + 7, INF = 1e9;
int n, k, a[800][800];

int comp(int x) {
    int sum[n + 1][n + 1];
    rep(i, n + 1) sum[0][i] = 0;
    rep(i, n + 1) sum[i][0] = 0;
    rep(i, n) rep(j, n) sum[i + 1][j + 1] = sum[i][j + 1] + (a[i][j] >= x);
    rep(i, n - k + 1) {
        int tmp = 0;
        rep(j, k) tmp += sum[i + k][j] - sum[i][j];
        rep(j, n - k + 1) {
            tmp += sum[i + k][j + k] - sum[i][j + k] -
                sum[i + k][j] + sum[i][j];
            if (tmp < k * k / 2 + 1) return false;
        }
    }
    return true;
}

int main() {
    ci2(n, k);
    rep(i, n) rep(j, n) ci(a[i][j]);
    int l = 0, r = 1e9 + 1;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        ((comp(mid)) ? l : r) = mid;
    }
    co(l);
    return 0;
}

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

int n,k;
int a[805][805], s[805][805];

int binary_search(int key) {
  auto check = [&](int mid) {
    REP(i,n) REP(j,n) s[i+1][j+1] = a[i][j] > mid ? 1 : 0;
    REP(i,n+1) REP(j,n) s[i][j+1] += s[i][j];
    REP(i,n) REP(j,n+1) s[i+1][j] += s[i][j];

    REP(i,n-k+1) REP(j,n-k+1) {
      int now = s[i+k][j+k];
      now -= s[i][j+k];
      now -= s[i+k][j];
      now += s[i][j];

      if (now < key) return true;
    }
    return false;
  };

  int ok = INF;
  int ng = -1;
  while(abs(ok-ng) > 1) {
    int mid = (ok+ng)/2;
    check(mid) ? ok = mid : ng = mid;
  }

  return ok;
}

int main() {
  cin >> n >> k;
  REP(i,n) REP(j,n) cin >> a[i][j];

  int med = k * k / 2 + 1;
  cout << binary_search(med) << endl;
  return 0;
}


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

int main() {
  int N;
  long long count[200] = {};
  cin >> N;

  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    count[A % 200]++;
  }

  long long result = 0;

  for (int i = 0; i < 200; i++) {
    result += (count[i] - 1) * count[i] / 2;
  }

  cout << result << endl;
}

#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
*/
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rrep(i,a,b) for(ll i=a;i>=b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second
#define all(x)  x.begin(),x.end()
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ll INF = 1e18+7;
const ll mod = 1e9+7;
const ll MAXN = 1e4+10;

ll poww(ll a, ll b) {
    if(b<0) return 0LL;
    ll ans = 1;
    while (b) {
        if (b & 1)ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}
ll binpow(ll a, ll b, ll m)
{
    if (b < 0) return 0LL;
    if (a <= 0)return 0LL;
    a %= m;

    ll ans = 1LL;
    while (b) {
        if (b & 1)ans = ans * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return ans;
}
ll modinv(ll n) {
    return binpow(n, mod - 2, mod);
}

void solve() {
    ll n; cin>>n;
    ll a[n]; FOR(i,n) cin>>a[i];

    map<ll,ll> mt;
    ll ans = 0;
    for(ll i=0; i<n; i++) {
        ans += mt[a[i]%200];
        mt[a[i]%200]++;
    }
    cout<<ans;
}

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

    //ll no_of_test_cases; cin>>no_of_test_cases;
    ll no_of_test_cases = 1;
    //cout<<setprecision(15);

    for(ll i=1; i<=no_of_test_cases; i++) {
        solve();
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const ll mod = 1000 * 1000 * 1000 + 7;

vector<ll> v; ll res = 0;

struct edge {
	int u, v; ll w; edge() {}
	edge(int _u, int _v, ll _w) :
		u(_u), v(_v), w(_w) {}
};

struct node { vector<edge> edges; };

struct graph {
	vector<node> nodes; int n;
	graph(int _n) : n(_n) { nodes.resize(n); }

	void add_edge(int u, int v, ll w) {
		nodes[u].edges.emplace_back(u, v, w);
		nodes[v].edges.emplace_back(v, u, w);
	}

	void dfs1(int cur, int prev, ll W) {
		v[cur] = W; for (edge& e : nodes[cur].edges)
			if (e.v != prev) { dfs1(e.v, cur, W ^ e.w); }
	}

	void dfs2(int cur, int prev, int cnt, ll W, bool inv = false) {
		ll cont = ((inv ? n - cnt : cnt) * (W % mod)) % mod;
		res = (res + cont) % mod; for (edge& e : nodes[cur].edges) {
			if (e.v == prev) { continue; }
			bool b = (e.w & W) != 0;
			dfs2(e.v, cur, cnt, W, inv ^ b);
		}
	}
};

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

	int n; cin >> n; graph g(n); v.resize(n);
	for (int i = 1; i < n; i++) {
		int u, v; ll w; cin >> u >> v >> w;
		g.add_edge(--u, --v, w);
	}

	g.dfs1(0, -1, 0);

	for (int i = 0; i <= 60; i++) {
		int cnt = 0; ll W = 1ll << i;
		for (int j = 0; j < n; j++)
			if (v[j] & W) { cnt++; }
		g.dfs2(0, -1, cnt, W);
	}

	cout << (res * 500000004) % mod << '\n';
	cin.ignore(2); return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define DWN(i, m, n) for (ll i(m); i >= n; i--)
#define REP(i, n) FOR(i, 0, n)
#define DW(i, n) DWN(i, n, 0)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define D(n) DW(i, n)
#define DD(n) DW(j, n)
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vtll = vector<tll>;
using gr = vector<vll>;
using wgr = vector<vpll>;
void add_edge(gr&g,ll x, ll y){ g[x].pb(y);g[y].pb(x); }
void add_edge(wgr&g,ll x, ll y, ll z){ g[x].eb(y,z);g[y].eb(x,z); }
template<typename T,typename U>
ostream& operator<<(ostream& os, const pair<T,U>& p) {
    cerr << ' ' <<  p.x << ',' << p.y; return os; }
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for(auto x: v) os << ' ' <<  x; return os; }
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
    for(auto x: v) os << ' ' <<  x; return os; }
template<typename T,typename U>
ostream& operator<<(ostream& os, const map<T,U>& v) {
    for(auto x: v) os << ' ' <<  x; return os; }
struct d_ {
    template<typename T> d_& operator,(const T& x) {
        cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define deb(X ...) dbg(#X, "=", X);
#define EPS (1e-10)
#define INF (1LL<<61)
#define YES(x) cout << (x ? "YES" : "NO") << endl;
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

struct E {
    ll x,y,w;
};

const ll MOD = 1e9+7;
ll mod(ll a, ll b=MOD) {
  return ((a%b)+b)%b;
}
ll extended_euclid(ll a,ll b,ll &x,ll &y) {
    if (a == 0) { x = 0; y = 1; return b;}
    ll x1, y1; ll d = extended_euclid(b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
ll mod_inverse(ll a, ll n=MOD) {
  ll x, y;
  ll d = extended_euclid(a, n, x, y);
  if (d > 1) return -1;
  return mod(x,n);
}
struct Mt {
    ll x = 0;
    Mt(){}
    Mt(ll y):x(mod(y)){}
    bool operator==(Mt &y){return x==y.x;}
    Mt operator+(Mt y){return mod(x+y.x);}
    Mt operator-(){return mod(-x);}
    Mt operator-(Mt y){return mod(x-y.x);}
    Mt operator*(Mt y){return mod(x*y.x);}
    Mt operator/(Mt y){return mod(x*mod_inverse(y.x));}
    Mt operator+=(Mt y){return x=(*this+y).x;}
    Mt operator-=(Mt y){return x=(*this-y).x;}
    Mt operator*=(Mt y){return x=(*this*y).x;}
    Mt operator/=(Mt y){return x=(*this/y).x;}
};
ostream& operator<<(ostream& os, const Mt&m){
    os << m.x; return os;
}

ll cnt[67];
void dfs(ll u, wgr &g, ll p=-1, ll on=0) {
    F(60) cnt[i]+=(on&(1ll<<i))?1:0;
    for(auto [v,w]: g[u]) if(v!=p) dfs(v,g,u, on^w);
}

int main(void) {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    wgr g(n);
    F(n-1) {
        ll u,v,w; cin >> u >> v >> w;
        u--; v--;
        add_edge(g, u,v,w);
    }
    dfs(0,g);
    ll ret = 0;
    F(60) {
        ll cur = cnt[i];
        ret = mod(ret + mod(1ll<<i) * mod((cur) * (n-cur)));
    }
    cout << ret << endl;
    return 0;
}


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

typedef long long int lli;

using namespace std;

void solve(){
    lli n;
    cin>>n;
    if(n%2 != 0){
            cout<<"Odd\n";
    }
    else{
            n=n/2;
            if(n%2 != 0){
                        cout<<"Same\n";
            }
            else{
                        cout<<"Even\n";
            }
    }

 }

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

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string S;
    cin >> S;
    auto ans = "Yes";
    for (size_t i = 0; i < S.length(); i++)
    {
        if (i % 2 == 0 && !islower(S[i]))
            ans = "No";
        else if (i % 2 == 1 && islower(S[i]))
            ans = "No";
    }
    cout << ans << endl;
}


#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target("sse4")
#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;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define mod         1000000007
#define pi          3.1415926535898
#define eps         1e-9

#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define vt vector
#define ar array
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define unique(c) (c).resize(unique(all(c)) - (c).begin())
#define sz(x) (int)(x).size()
#define revsort(x) sort(all(x));reverse(all(x))

#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)
#define EACH(x, a) for (auto& x: a)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;
typedef vector<vector<LL> > matrix;
typedef vector<vector<int> > graph;

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}

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

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

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

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

int add (LL var1, LL var2) {
    return ( (var1 % mod) + (var2 % mod) + mod) % mod;
}

int mul (LL var1, LL var2) {
    return (var1*var2) % mod;
}

int powm (LL x, LL y) {
    int ans = 1;
    while (y) {
        if (y & 1) {
            ans = mul(ans, x);
        }
        x = mul(x, x);
        y /= 2;
    }
    return ans;
}

int inv(LL x) {
    return powm(x, mod-2);
}

LL INF=1e9;

void solve() {
    int n;
    read(n);
    vi a(n);
    read(a);
    int x = *min_element(all(a));

    map <int, int> mp;

    REP (i, 0, n-1) {
        for (LL j = 1; j*j <= a[i]; j++) {
            if (a[i]%j) continue;
            mp[j] = __gcd(a[i], mp[j]);
            mp[a[i]/j] = __gcd(a[i], mp[a[i]/j]);
        }
    }
    int ans = 0;
    for (auto px : mp) {
        if (px.fs > x) break;
        if (px.fs == px.sc) ans++;
    }
    cout << ans << nl;
}

int main() {
    fast;
        solve();
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x, y) make_pair(x, y)
#define mem(dp, a) memset(dp, a, sizeof dp);
#define all(a) a.begin(), a.end()
#define sall(a) sort(all(a))
#define X first
#define Y second
typedef long long int ll;
typedef pair<ll, ll> pp;

#define debug(x) cout << #x << " :: " << x << "\n";
#define debug2(x, y) cout << #x << " :: " << x << "\t" << #y << " :: " << y << "\n";
#define debug3(x, y, z) cout << #x << " :: " << x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pp, null_type, less<pp>, rb_tree_tag, tree_order_statistics_node_update>

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

int main()
{
    boost;
    ll n;
    cin >> n;
    ll a[n], g = 0;
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    ll mn = *min_element(a, a+n);
    unordered_map<ll, ll> ma;
    ll ans = 1;
    for (ll i = 0; i < n; i++)
    {
        ll num = a[i];
        for (ll j = 1; ((j*j) <= num)&&(j<mn); j++)
        {
            if ((num%j)==0)
            {
                ma[j] = __gcd(ma[j], a[i]);
                if( ((num/j)!=j)&&((num/j)<mn) )
                    ma[num / j] = __gcd(ma[num / j], a[i]);
            }
        }
    }
    for(auto it:ma) {
        ans += (it.first == it.second);
    }
    cout << ans;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
int a =0 , b=0 , c =0 , d=0;
cin >> a>> b >> c >> d;
cout << (a*d) - (b*c) <<endl;

return 0;}

#include <bits/stdc++.h>
#define rep(i,n)    for(int i=0;i<(n);++i)
#define repA(i,k,n) for(int i=k;i<=(n);++i)
#define repD(i,k,n)	for(int i=k;i>=(n);--i)
#define endl '\n'
#define print(b)	for(auto a:b) cout<<a<<' ';
#define printN(b)   for(auto a:b) cout<<a<<endl;
#define fin    		freopen("C:\\Users\\Nazmul Rahul\\Desktop\\in.txt", "r++", stdin)
#define fout   		freopen("C:\\Users\\Nazmul Rahul\\Desktop\\out.txt", "w++", stdout)
#define fastio    	ios::sync_with_stdio(false)
#define max(a,b)	((a)>(b)?(a):(b))
#define min(a,b)	((a)<(b)?(a):(b))
#define pb    		push_back
#define pob   		pop_back
#define ll 			long long int
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
	fin;
	fout;
#endif
	int ara[2][2];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++)
			cin >> ara[i][j];
	}
	cout << ((ara[0][0]*ara[1][1]) - (ara[0][1]*ara[1][0]));
	cout << endl;

	return 0;

}


#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
	ll n;
    while(cin>>n){
        ll ans=0, tmp1 = 3, tmp2 = 1, ans1 = -1, ans2 = -1;
        for(ll i = 1; tmp1<=n; tmp1*=3, ++i){
        	tmp2 = 5;
        	for(ll j = 1; tmp2<=n-tmp1; ++j, tmp2*=5){
        		if(tmp2+tmp1==n){
        			ans1 = i;
        			ans2 = j;
        			break;
        		}
        	}
        	if(ans1!=-1){
        		break;
        	}
        }
        if(ans1==-1){
        	printf("-1\n");
        }
        else{
        	printf("%lld %lld\n",ans1, ans2);
        }
    }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll N; cin >> N;
  for(ll i = 1; i <= 37; i++){
   for(ll j = 1; j <= 37; j++){
     if(powl(3,i)+powl(5,j)==N){cout<<i<<" "<<j<<endl;return 0;};
     if(powl(5,i)+powl(3,j)==N==N){cout<<j<<" "<<i<<endl;return 0;};
   }
  }
  cout << "-1" << endl;
  return 0;
}


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

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>

constexpr ll INF = (1ll << 60);
constexpr ll mod = 1000000007;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll n,m,t,a[1001],b[1001],x,k=0,time=0;
    cin>>n>>m>>t;
    rep(i,m){
        cin>>a[i]>>b[i];
    }
    x=n;
    rep(i,m){
        x-=a[i]-time;
        if(x<=0){
            k=1;
            break;
        }
        x+=b[i]-a[i];
        if(x>n) x=n;
        time=b[i];
    }
    x-=t-time;
    if(x<=0) k=1;

    if(k==1) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

/*   --------------------
    |       LOSER        |
    |     ~NOOBOSS~      |
     --------------------
*/
#include <bits/stdc++.h>
using namespace std;
#define      mxx                 LLONG_MAX
#define      mnn                 LLONG_MIN
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      Ceil(x,y)           ((x+y-1)/y)
#define      sz(s)               (int)s.size()
#define      angle(x)            double(x * acos(-1) / 180.0)
#define      max_3(a,b,c)        max(a, max(b,c))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      loser               return 0
#define      ll                  long long
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      all(v)              v.begin(),v.end()
#define      SORT(v)             sort(v.begin(),v.end())
#define      SRV(v)              sort(v.rbegin(),v.rend())
#define      REV(v)              reverse(v.begin(),v.end())
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      MP                  make_pair
#define      flash               cout.flush()
#define      InTheNameOfGod      ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
constexpr ll MOD = 998244353;
constexpr ll mod = 1e9  + 7;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cerr<<a<<endl;
#define bug2(a,b)  cerr<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cerr<<a<<" "<<b<<" "<<c<<endl;
/*----*/
const ll N=3e5+5;
vector<ll> adj[N];
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll modpow(ll a,ll b,ll m){ll ans=1;while(b){if(b&1)ans=(ans*a)%m;b/=2;a=(a*a)%m;}return ans;}
ll nsum(ll num){return (num*(num+1))/2;}
void edge (ll u,ll v) {adj[u].PSB(v) ;adj[v].PSB(u);}
/*------------------START---------------------*/

/*-----*/
void solve(){
   ll n,m,t,mah;
   cin>>mah>>m>>t;
   n=mah;
   ll pre=0;
   while(m--){
    ll x,y;
    cin>>x>>y;
    mah-=(x-pre);
    if(mah<=0){
        cout<<"No"<<endl;
        return;
    }
    pre=y;
    mah+=(y-x);
    mah=min(mah,n);
   }
  // bug1(mah);
   mah-=(t-pre);
   //bug1(mah);
   if(mah<=0){
        cout<<"No"<<endl;
        return;
    }
    cout<<"Yes"<<endl;

   //cout << fixed << setprecision(10);
}
/*-----*/
int main(){
   InTheNameOfGod

   ll Test=1;
   //cin>>Test;
   while(Test--){
     solve();
    }
  loser;
}
///////   C O D I N G  I S  L I F E   ///////


#include <bits/stdc++.h>

#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i, n) for(ll i=n-1;i>=0;--i)
#define rep1(i, n) for(ll i=1; i<=n; ++i)
#define repitr(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

using namespace std;
using ll  = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;
const double PI = 3.1415926535897932384626433;

int main(){
    ll n;
    cin >> n;

    if(n % 2)cout << "Black";
    else cout << "White";
}

#include <cstdio>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if(n%2){
		printf("Black\n");
	}else{
		printf("White\n");
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <regex>
using namespace std;

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int Q; cin >> Q;

    string pre = S.substr(0, N);
    string post = S.substr(N);

    for (int i = 0; i < Q; ++i) {
        int t, a, b;
        cin >> t >> a >> b;
        if (t == 1) {
            a--; b--;

            if (b < N) {
                swap(pre[a], pre[b]);
            } else if (N <= a) {
                swap(post[a - N], post[b - N]);
            } else {
                swap(pre[a], post[b - N]);
            }
        } else {
            swap(pre, post);
        }
    }

    cout << pre << post << endl;
}

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

const int M=18;
const int INF=0x3f3f3f3f;
int x[M],y[M],z[M];
int d[M][M];
inline int dis(int i,int j)
{
	return abs(x[i]-x[j])+abs(y[i]-y[j])+max(0,z[j]-z[i]);
}

int dp[1<<M][M];

int main()
{
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i]>>z[i];
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			d[i][j]=dis(i,j);
	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	memset(dp,INF,sizeof(dp));
	int mask=1<<n;
	dp[1][0]=0;
	for(int s=1;s<mask-1;s++)
	{
		for(int j=0;j<n;j++)
		{
			if(dp[s][j]==INF) continue;
			for(int k=0;k<n;k++)
			{
				if(s&(1<<k)) continue;
				dp[s^(1<<k)][k]=min(dp[s^(1<<k)][k],dp[s][j]+d[j][k]);
			}
		}
	}
	int ans=INF;
	for(int i=1;i<n;i++)
	{
		ans=min(ans,dp[mask-1][i]+d[i][0]);
	}
	printf("%d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define All(v) v.begin(), v.end()
#define rAll(v) v.rbegin(), v.rend()
template<class in_chmax> void chmax(in_chmax &x, in_chmax y) {x = max(x,y);}
template<class in_chmin> void chmin(in_chmin &x, in_chmin y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

const ll inf = 1e18;
const ll mod = 1e9 + 7;

int main() {
    ll N, M; cin >> N >> M;

    vector<ll> cnt(2);
    rep(i,N) {
        string S; cin >> S;
        ll v = 0;
        rep(j,M) if (S[j]-'0') v++;
        cnt[v%2]++;
    }

    ll ans = 1;
    rep(i,2) ans *= cnt[i];
    Cout(ans);
}

#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
string s[100010];
ll cnt[1<<20] = {};
int main(){
    int i,j,n,m; cin >> n >> m;
    ll od = 0,ev = 0;
    for(i=0;i<n;i++){
        cin >> s[i];
        int cnt = 0;
        for(j=0;j<m;j++) cnt += s[i][j] - '0';
        if(cnt&1) od++;
        else ev++;
    }
    cout << od*ev << endl;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;

vector<int> ans;

bool gcd(ll a, ll b, int c) {
	if (c < 0) return false;
	if (a == 0) {
		if (b > c) return false;
		for (int i = 0; i < b; ++i) {
			ans.push_back(2);
		}
		return true;
	}
	if (b == 0) {
		if (a > c) return false;
		for (int i = 0; i < a; ++i) {
			ans.push_back(1);
		}
		return true;
	}
	if (a > b) {
		if (gcd(a - b, b, c - 1)) {
			ans.push_back(3);
			return true;
		}
		return false;
	}
	if (gcd(a, b - a, c - 1)) {
		ans.push_back(4);
		return true;
	}
	return false;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	std::mt19937_64 gen{0};
	for (;;) {
		ll b = gen() % n;
		if (gcd(n, b, 130)) {
			break;
		} else if (gcd(b, n, 130)) {
			break;
		}
	}
	cout << ans.size() << endl;
	for (auto v: ans) {
		cout << v <<  endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
inline ull Hash(const string& s){
    ull ans=0;
    for(auto c : s)
        ans=ans*26+c-'a';
    return ans;
}
string s;
int N;
set<ull> s1,s2;
inline void work(){
    for(int i=1;i<=N;i++){
        cin>>s;
        set<ull> &t1=(s[0]=='!'?s1:s2);
        set<ull> &t2=(s[0]!='!'?s1:s2);
        reverse(s.begin(),s.end());
        if( *s.rbegin()=='!' ) s.pop_back();
        ull val=Hash(s);
        if( t1.find(val)!=t1.end() ){
            reverse(s.begin(),s.end());
            cout<<s<<endl;
            return ;
        }
        else t2.insert(val);
    }
    cout<<"satisfiable"<<endl;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>N;
    work();
    return 0;
}

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

int main() {
	// ll N;
	string S;
	cin >> S;
	vector<int> A(10,-1); // -1:x, 0:? 1:o
	for(int i = 0; i < 10; i++){
		if(S[i] == 'o') A[i] = 1;
		if(S[i] == '?') A[i] = 0;
	}
	int c = 0;
	bool f = true;
	vector<int> B(10,0);
	for(int i = 0; i < 10000; i++){
		f = true;
		fill(B.begin(),B.end(),0);
		int n = i;
		for(int j = 0; j < 4; j++){
			B[n % 10]++;
			n /= 10;
		}
		for(int j = 0; j < 10; j++){
			if(A[j] == 1){
				if(B[j] == 0) f = false;
			}else if(A[j] == -1){
				if(B[j] > 0) f = false;
			}
		}
		if(f) c++;
	}

	cout << c << endl;
	return(0);
}


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

#define int long long
#define FOR(i, size) for (int i = 0; i < size; i++)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define MOD 1000000007

#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template <typename... Args>
void logger(string vars, Args &&...values)
{
	cout << vars << " = ";
	string delim = "";
	(..., (cout << delim << values, delim = ", "));
}

template <typename T>
void print_list(vector<T> collection, bool newline = true)
{
	for (const auto &item : collection)
	{
		cout << item << " ";
	}
	if (newline)
		cout << endl;
}

#define ONE_TESTCASE 1

int n, m, timer;

void Solve()
{
	cin >> n;
	vector<pair<double, double>> v;
	FOR(i, n)
	{
		int t;
		cin >> t;

		double a, b;
		cin >> a >> b;

		if (t == 2)
		{
			b -= 0.1;
		}
		else if (t == 3)
		{
			a += 0.1;
		}
		else if (t == 4)
		{
			a += 0.1;
			b -= 0.1;
		}

		v.push_back({a, b});
	}

	int cnt = 0;
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if ((v[i].second >= v[j].first and v[i].first <= v[j].first) or (v[j].second >= v[i].first and v[i].first >= v[j].first))
				cnt++;
		}
	}
	cout << cnt;
}

int32_t main()
{

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

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

#if ONE_TESTCASE
	int test = 1;
#else
	int test;
	cin >> test;
#endif

	for (int t = 1; t <= test; t++)
	{
		Solve();
		cout << endl;
	}
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int inf=1e9+7;
const ll INF=1e18+7;
int n,t;
long double a[2001],b[2001];
bool intersect(int i,int j){
	if(a[i]<=b[j]&&b[i]>=a[j]) return 1;
	return 0;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>t>>a[i]>>b[i];
		if(t>2) a[i]+=0.5;
		if(t%2==0) b[i]-=0.5;
	}
	int ans=0;
	for(int i=0;i<n-1;i++)
		for(int j=i+1;j<n;j++)
			if(intersect(i,j))
				ans++;
	cout<<ans;
	return 0;
}


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

#define mp make_pair
#define pb push_back
#define ll long long int
#define sd(x) scanf("%lld",&x)
#define sdi(x) scanf("%d",&x)
#define sdc(c) scanf("%c",&c)
#define inf 1000000000000000000ll
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define bits(x) __builtin_popcountll(x)
#define ld long double
#define test() ll test; cin>>test; while(test--)
#define fi first
#define se second
#define all(x) x.begin(),x.end()

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

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

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

inline ll GCD(ll x, ll y) {
    if(x<y) swap(x,y);
    if(x==0) return y;
    if(y==0) return x;
    return GCD(x%y,y);
}

ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}

ll power(ll x, ll n, ll mod) {
    ll res = 1;
    x %= mod;
    while(n) {
        if(n&1) {
            res = ((res*x)%mod+mod)%mod;
        }
        x = ((x*x)%mod+mod)%mod;
        n>>=1;
    }

    return res;
}

const int MOD = 1e9+7;

inline ll add(ll x, ll y, ll MOD) {
    x %= MOD;
    y %= MOD;
    ll ans = (x+y)%MOD;
    return ans;
}

inline ll mul(ll x,ll y, ll MOD) {
    x %= MOD;
    y %= MOD;
    ll ans = ((x*y)%MOD+MOD)%MOD;
    return ans;
}

int main() {
    fastio;

    ll N, X;
    cin>>N>>X;
    ll ans = 0;

    ll V,P;
    int indx = -1;
    for(int i=1;i<=N;i++) {
        cin>>V>>P;

        ans += V*P;
        if(ans>X*100 && indx == -1) {
            indx = i;
        }
    }

    cout<<indx<<endl;
    time_taken();
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <cstring>
#include <string>
#include <queue>
#include <cstdio>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

const ll MAX = 510000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll m,ll n){
    if(n==0) return m;
    return gcd(n,m%n);
}

const long long INF = 1LL << 60;

template<class T> void chmax(T& a,T b){
    if(a<b){
        a=b;
    }
}
template<class T> void chmin(T& a,T b){
    if(a>b){
        a=b;
    }
}

using Interval = pair<ll,ll>;

bool cmp(const Interval &a,const Interval &b){
    return a.second<b.second;
}

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

    ll n,m,b,fut=0;
    cin>>n>>m>>b;
    ll maxi=n;
    rep(i,m){
        ll st,fi;
        cin>>st>>fi;
        n -= st-fut;

        if(n <= 0){
            cout<<"No"<<endl;
            return 0;
        }

        if(n + fi-st > maxi) n = maxi;
        else n += fi-st;

        fut = fi;
    }
    n -= b-fut;
    if(n <= 0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<numeric> // __GCD()
#include<stack>
#include<string.h>
#include<math.h>
#include<set>

using namespace std;

#define ll long long
#define all(v) v.begin(),v.end()

int main(){

    ll r;
    double x,y; cin>>r>>x>>y;

    double a=sqrt(x*x+y*y);

    ll b=a;
    if(a-b==0){
        if(b%r==0){
            cout<<b/r<<endl;
        }
        else{
            if(b<r) cout<<2<<endl;
            else cout<<b/r+1<<endl;
        }
    }
    else{
        if(b<r) cout<<2<<endl;
        else cout<<b/r+1<<endl;
    }

    return 0;
}

#include <bits/stdc++.h>

int main() {
    int a, b;
    std::cin >> a >> b;
    for (int i = b - a; i > 0; i--) {
        int l = a / i * i; if (l < a) l += i;
        int r = b / i * i; if (r + i <= b) r += i;
        if (l < r) {
            std::cout << i << '\n';
            break;
        }
    }
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll ans = 2e18;
  for (int bit = 0; bit < (1 << n); ++bit) {
    vector<ll> v;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
      if (bit >> i & 1) {
        v.push_back(sum);
        sum = a[i];
      } else {
        sum |= a[i];
      }
    }
    v.push_back(sum);
    ll res = 0;
    for (int i = 0; i < v.size(); ++i) {
      res ^= v[i];
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using isize = ptrdiff_t;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using usize = size_t;

using f32 = float_t;
using f64 = double_t;

i32 n;
vector<i64> a;
i64 ans = 1e18;

void solve(i32 p, i64 Or, i64 Xor) {
    if (p == n) {
        ans = min(Xor ^ Or, ans);
        return;
    }

    Or |= a[p];
    solve(p + 1, Or, Xor);
    solve(p + 1, 0, Xor ^ Or);
}

auto main() -> i32 {

    ios::sync_with_stdio(false), cin.tie(nullptr);

    cin >> n;
    a.resize(n);
    for (auto& x : a) {
        cin >> x;
    }

    solve(0, 0, 0);
    cout << ans;
    cout << "\n";

    return 0;
}


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

#define ls n << 1
#define rs n << 1 | 1
#define PB push_back
#define MP make_pair
#define LD double
#define int long long
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
const int N = 1e5;
const int M = 300;
const int mod = 1e9 + 7;
const LL inf = 1e18;
// inline char nc() {
//     static char buf[1000000], *p1 = buf, *p2 = buf;
//     return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++;
// }
// #define getchar nc
inline int read() {
	int s = 0;
	register bool neg = 0;
	register char c = getchar();
	for (; c < '0' || c > '9'; c = getchar())
		neg |= (c == '-');
	for (; c >= '0' && c <= '9'; s = s * 10 + (c ^ 48), c = getchar())
		;
	s = (neg ? -s : s);
	return s;
}

int a, b, h[2];
char s[N + 10][21];

signed main() {
	// freopen("in1.in", "r", stdin);
	// freopen("out.out", "w", stdout);
	a = read();
	b = read();
	int ans=0;
	for (int i = 1; i <= a; i++) {
		scanf("%s", s[i] + 1);
		int val=0;
		for (int j = 1; j <= b; j++) val ^= (s[i][j]=='1');
		h[val]++;
	}
	printf("%lld", h[0]*h[1]);
	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

ll cnt[10000000];

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

    int N, M;
    cin >> N >> M;
    vector<string> s(N);
    for(int i = 0; i < N; ++i){
        cin >> s[i];
        cnt[stoi(s[i], nullptr, 2)] += 1;
    }

    ll ans = 0;
    ll odd = 0, even = 0;
    for(int mask = 0; mask < 1 << M; ++mask){
        int popcnt = __builtin_popcount(mask);
        if(popcnt % 2 == 0){
            even += cnt[mask];
        }
        else{
            odd += cnt[mask];
        }
    }

    ans += odd * even;

    cout << ans << endl;

    return 0;
}


#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define ul unsigned long long
#define ui unsigned int
#define ri register int
#define pb push_back
#define mp make_pair
char p[30]={'0','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
inline ll rd(){
	ll x=0,flag=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') flag=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
	return x*flag;
}
/*
int wl,x,y,head[];
struct node{
	int nxt,to;
}star[];
inline void add(int from,int to){
	wl++;
	star[wl].to=to;
	star[wl].nxt=head[from];
	head[from]=wl;
}*/
inline int lowbit(int x){return x & ( - x ) ;}
ll n;
map<ll,int>vis;
int main()
{
	n=rd();
	ll lim=sqrt(n),ans=0;
	for(ll i=2;i<=lim;++i){
	    ll tmp=i;
        for(ri j=2;;++j){
            tmp*=i;//cout<<i<<" "<<tmp<<endl;
            if(tmp>n) break;
            if(vis.find(tmp)==vis.end()) vis[tmp]=1,ans++;
        }
    }
    cout<<n-ans;
    return 0;
}

#include <iostream>
#define int long long
using namespace std;

const int N = 100000 + 7;

int pd[N], prime[N];
int cnt;
inline void diprime()
{
    pd[0] = pd[1] = 1;
    for(int i=2; i<=N-7; i++)
    {
        if(!pd[i]) prime[++cnt]=i;
        for(int j=1; j<=cnt; j++)
        {
            if(prime[j] * i > N-7) break;
            pd[prime[j] * i] = 1;
            if(i%prime[j] == 0) break;
        }
    }
    return ;
}

int n, ans;

bool nmsl[100007];

inline void doit(int x)
{
    int now = x;
    for(int i=2; (now*=x)<=n; i++) {
        // now *= x;
        // if(pd[i]) continue;
        if(now <= 100000) nmsl[now] = 1;
        // cout << x << ' ' << i << ' ' << now << ' ' << nmsl[now] << '\n';
        ans++;
    }
    return ;
}

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

    // diprime();

    cin >> n;
    for(int i=2; i*i<=n; i++) {
        if(nmsl[i]) continue;
        doit(i);
    }
    cout << n - ans << '\n';
}


#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <numeric>
#include <math.h>
#include <complex>

using namespace std;

#define rep(i, n) for (long long int i = 0; i < (long long int)(n); i++)
#define irep(i, n) for (long long int i = 1; i <= (long long int)(n); i++)
#define drep(i, n, diff) for (long long int i = 0; i < (long long int)(n); i += diff)
#define mod 1000000007
#define INF 100100100100100101
#define ld(val) printf("%s : %lld\n", #val, val);
#define sd(val) printf("%s : %s\n", #val, val.c_str());

typedef long long int ll;
typedef pair<ll, ll> P;
typedef pair<P, P> PP;
typedef tuple<ll, ll, ll> TP;

vector<ll> to[200005];
vector<ll> lst[200005];
ll d[200005];
ll in[200005];
ll out[200005];
ll cnt;

void dfs(ll n, ll cd) {
  in[n] = cnt;
  cnt++;
  lst[cd].push_back(in[n]);
  for(auto v: to[n]) {
    dfs(v, cd+1);
  }
  out[n] = cnt;
}

int main() {
  ll n;
  cin >> n;
  rep(i, n-1) {
    ll x;
    cin >> x;
    to[x-1].push_back(i+1);
  }

  dfs(0, 0);

  ll q;
  cin >> q;
  rep(i, q) {
    ll u, d;
    cin >> u >> d;
    --u;
    ll l = lower_bound(lst[d].begin(), lst[d].end(), out[u]) - lst[d].begin();
    ll r = lower_bound(lst[d].begin(), lst[d].end(), in[u]) - lst[d].begin();
    printf("%lld\n", l-r);
  }

  return 0;
}

#include <bits/stdc++.h>
#define int long long

using namespace std;
const int MOD=1e9+7;

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

const int N = 200005;
int n,q,root=1,dis[N];
vector<int> G[N];
vector<pii> Ques;
int L[N],R[N],TIME=0;

int calc_QUAI(int x){
	return x/sqrt(n);
}

bool cmp(pii a, pii b){
	if(calc_QUAI(a.first.first)!=calc_QUAI(b.first.first))
		return calc_QUAI(a.first.first)<calc_QUAI(b.first.first);
	return a.first.second<b.first.second;
}

void dfs(int now,int dep){
	L[now]=TIME++;
	dis[L[now]]=dep;
	for(int next:G[now])
		dfs(next,dep+1);
	R[now]=TIME-1;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);	cout.tie(nullptr);

	cin >> n;
	for(int i=1;i<n;++i){
		int p;	cin >> p;
		G[p].push_back(i+1);
	}

	dfs(root,0);

	cin >> q; Ques.resize(q);
	for(int i=0;i<q;++i){
		int u,d;	cin >> u >> d;
		Ques[i]={{L[u],R[u]},{d,i}};
	}

	sort(Ques.begin(),Ques.end(),cmp);

	int LL=0,RR=0;
	vector<int> COUNT;	COUNT.resize(n);
	vector<int> ans;	ans.resize(q);
	COUNT[dis[L[0]]]++;
	for(int i=0;i<q;++i){
		while(RR<Ques[i].first.second){
			++RR;
			COUNT[dis[RR]]++;
		}
		while(RR>Ques[i].first.second){
			COUNT[dis[RR]]--;
			--RR;
		}
		while(LL<Ques[i].first.first){
			COUNT[dis[LL]]--;
			++LL;
		}
		while(LL>Ques[i].first.first){
			--LL;
			COUNT[dis[LL]]++;
		}
		ans[Ques[i].second.second]=COUNT[Ques[i].second.first];
	}
	for(int i=0;i<q;++i)	cout << ans[i] << '\n';

	return 0;
}


// @Date    : 2021-06-05 19:00:19
// @Author  : raj lath (oorja.halt@gmail.com)
// @Link    : link
// @Version : 1.0.0

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

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define mod 9982444353
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

void solve()
{

}

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

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

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

  if(C==0){
    A=A-1;
    if(A<B){
      cout<<"Aoki"<<endl;
    }
    else{
      cout<<"Takahashi"<<endl;
    }
  }
  else{
    B=B-1;
    if(B<A){
      cout<<"Takahashi"<<endl;
    }
    else{
      cout<<"Aoki"<<endl;
    }
  }
}


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

ll h, w, a, b;

ll count(vector<ll> mas, ll aed, ll bed, ll now){
  /*
  cout << now << endl;
  for(int i=0;i<w*h;i++) cout << mas[i] << " ";
  cout << endl;
  */

  if(aed<0 || bed<0) return 0;
  if(now == h*w) return 1;
  if(mas[now]!=0) return count(mas, aed, bed, now+1);

  mas[now]=1;
  ll c = count(mas, aed, bed-1, now+1);
  if((now+1)%w!=0 && mas[now+1]==0){
    mas[now+1] = 1;
    c += count(mas, aed-1, bed, now+1);
    mas[now+1] = 0;
  }
  if((now+w)<w*h){
    mas[now+w] = 1;
    c += count(mas, aed-1, bed, now+1);
    mas[now+w] = 0;
  }
  return c;
}

int main(){

  cin >> h >> w >> a >> b;
  vector<ll> A(w*h, 0);
  cout << count(A, a, b, 0) << endl;
  return 0;
}

#include <bits/stdc++.h>
#define LL long long
#define db double
#define mp make_pair
#define x first
#define y second
#define vi vector<int>
#define SZ(a) (int)((a).size())
using namespace std;
const int N = 1e5 + 10;
int k, n, m, id[N];
LL a[N], b[N], c[N];

int cmp(int x, int y) { return abs(c[x] - a[x]) < abs(c[y] - a[y]); }

void quit() {
	for(int i = 1; i <= k; i++) printf("%lld ", b[i] / n);
	printf("\n");
	exit(0);
}

int main() {
	scanf("%d%d%d", &k, &n, &m);
	int L = 0, R = 0;
	for(int i = 1; i <= k; i++) {
		scanf("%lld", &a[i]);
		a[i] *= m;
		LL l = a[i] / n * n, r = (a[i] / n + 1) * n;
		if(abs(l - a[i]) > abs(r - a[i])) swap(l, r);
		L += l / n, R += l / n;
		b[i] = l;
		c[i] = r;
		id[i] = i;
	}
	sort(id + 1, id + k + 1, cmp);
	if(L <= m && m <= R) quit();
	for(int i = 1; i <= k; i++) {
		int x = id[i];
		if(m < L) {
			if(c[x] > b[x]) continue;
			b[x] = c[x], L--;
		} else {
			if(c[x] < b[x]) continue;
			b[x] = c[x], R++;
		}
		if(L <= m && m <= R) quit();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(var) (var).begin(), (var).end()
#define sz(x) (int)x.size()
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define vvpi vector<vector<pair<int,int> > >

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

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

	int n,s,d,fl=0;
	cin >> n >> s >> d;
	while(n--)
	{
		int x,y;
		cin >> x >> y;
		if(x < s && y > d)
		{
			cout << "Yes";
			return 0;
		}
	}

	cout << "No\n";

	return 0;
}

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

#if __has_include(<string_view>)
#include <string_view>
#endif

#if __has_include(<optional>)
#include <optional>
#endif

#if __has_include(<any>)
#include <any>
#endif

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

using namespace std;

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

template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template <class T>
istream& operator>>(istream& is, vector<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}

template <class T>
istream& operator>>(istream& is, valarray<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}

template <class T>
T peak_and_pop(std::queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.front());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::priority_queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::stack<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

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

void solution()
{
    int n,x;
    cin >> n >> x;
    string s;
    cin >> s;
    assert(s.length() == n);
    int score = x;
    for(char c : s){
        score = max(0, score + (c == 'o' ? 1 : -1));
    }
    cout << score << '\n';
}

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


#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using PLL = pair<LL,LL>;
using VPI = vector<PII>;
using VPL = vector<PLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)
#define RREP(i,m,n) for(int i=(m);i>=(n);i--)

int main(){
  LL n,k,ans=0;
  cin >> n >> k;

  REP(ab,2,2*n+1){
    LL cd = ab - k;
    if(2<=cd && cd<=2*n){
      LL count_ab = min(ab-1, 2*n-ab+1);
      LL count_cd = min(cd-1, 2*n-cd+1);
      ans += count_ab * count_cd;
    }
  }

  cout << ans << endl;

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug true
#define debug2 false

ll R,C;

class Dijkstra{
    /*
    Copyright (c) 2021 0214sh7
    https://github.com/0214sh7/library/
    */
    private:
    typedef std::pair<long long,int> P;
    std::vector<std::vector<P>> G;
    int V;
    //long long INF = (1LL<<61);
    std::priority_queue<P,std::vector<P>,std::greater<P>> que;

    public:
    void init(int N,std::vector<std::pair<std::pair<int,int>,long long>> edge){
        //頂点数を決定する
        V=N;

        //辺集合を扱いやすい形式に変換する
        G.resize(V);
        for(int i=0;i<edge.size();i++){
            int from=edge[i].first.first,to=edge[i].first.second;
            long long cost=edge[i].second;
            G[from].push_back({cost,to});
        }
    }

    Dijkstra(int N,std::vector<std::pair<std::pair<int,int>,long long>> edge){
        init(N,edge);
    }

    std::vector<long long> solve(int s){
        std::vector<long long> d;
        //INFで初期化する
        for(int i=0;i<V;i++){
            d.push_back(INF);
        }
        d[s]=0;
        que.push({0,s});
        //queは{cost,to}をコストが小さい順に出す
        while(!que.empty()){
            P p = que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            for(int i=0;i<G[v].size();i++){
                P e = G[v][i];
                if(d[e.second]>d[v]+e.first){
                    d[e.second] = d[v]+e.first;
                    que.push({d[e.second],e.second});
                }
            }

            //新造

            for(ll i=1;v-i*C>=0;i++){
                if(d[v-i*C]>d[v]+1+i){
                    d[v-i*C] = d[v]+1+i;
                    que.push({d[v-i*C],v-i*C});
                }
            }

        }
        return d;
    }
};

int main(void){

    vector<vector<ll>> A,B;

    cin >> R >> C;
    A.resize(R);
    B.resize(R-1);

    REP(i,R){
        REP(j,C-1){
            ll a;
            cin >> a;
            A[i].push_back(a);
        }
    }
    REP(i,R-1){
        REP(j,C){
            ll b;
            cin >> b;
            B[i].push_back(b);
        }
    }

    vector<pair<pair<int,int>,long long>> E;
    REP(i,R){
        REP(j,C-1){
            E.push_back({ {i*C+j,i*C+j+1},A[i][j]});
            E.push_back({ {i*C+j+1,i*C+j},A[i][j]});
        }
    }
    REP(j,C){
        REP(i,R-1){
            E.push_back({ {i*C+j,(i+1)*C+j},B[i][j]});
        }
    }

    Dijkstra dijkstra(R*C,E);
    vector<ll> D = dijkstra.solve(0);
    /*
    REP(i,R*C){
        cout << D[i] << " ";
        if((i+1)%C==0)cout << endl;
    }*/

    cout << D[R*C-1] << endl;

    return 0;
}


#include <iostream>
#include <string>
constexpr int MAX = 30;
long long dp[MAX + 1][MAX + 1];
std::string find_kth(int A, int B, long long K) {
    if (A == 0) {
        return std::string(B, 'b');
    }
    if (B == 0) {
        return std::string(A, 'a');
    }
    if (K <= dp[A - 1][B]) {
        return std::string("a") + find_kth(A - 1, B, K);
    }
    else {
        return std::string("b") + find_kth(A, B - 1, K - dp[A - 1][B]);
    }
}
int main() {
    int A, B;
    long long K;
    std::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];
            }
        }
    }
    std::cout << find_kth(A, B, K) << '\n';
    return 0;
}

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

// nCr
static long long Combination(int n, int r)
{
  if (n < r) return 0;
  if ((r * 2) > n) r = n - r;

  long long ans = 1;
  for (int up = 1, down = n; up <= r; up++, down--) {
    ans = ans * down / up;
  }
  return ans;
}

using namespace std;
int main(void) {
  int A, B;
  cin >> A >> B;
  long long K;
  cin >> K;

  int AB = A + B;
  int leftA = A;
  int pos = 0;
  string ans = "";
  long long anspos = 0;
  while (pos < AB) {

    if (leftA <= 0) {
      ans += 'b';
      pos++;
      continue;
    }
    long long low = Combination(AB - pos -1, leftA - 1);
    long long hi  = Combination(AB - pos -1, leftA);

    if (anspos + low < K) {
      anspos += low;
      ans += 'b';
    }
    else {
      ans += 'a';
      leftA--;
    }
    pos++;
  }
  cout << ans << endl;
  return 0;
}


#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#pragma comment(linker, "/stack:200000000")

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

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 998244353;
const int N = 2e5 + 5;

int i, n, a[N], b[N], p[N], vis[N];

void solve() {
    cin >> n;
    vpii w, ans;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        w.pb({a[i], i});
    }
    for (i = 1; i <= n; i++) {
        cin >> b[i];
    }
    map<int, int> have, mp;
    for (i = 1; i <= n; i++) {
        cin >> p[i];
        have[p[i]] = i;
        mp[i] = p[i];
    }
    for (i = 1; i <= n; i++) {
        if (i != p[i] && a[i] <= b[p[i]]) {
            cout << -1 << endl;
            return;
        }
    }
    int cnt = 0;
    for (i = 1; i <= n; i++) {
        if (!vis[i]) {
            int v = i;
            cnt++;
            while (!vis[v]) {
                vis[v] = 1;
                v = p[v];
            }
        }
    }
    cout << n - cnt << endl;
    sort(all(w));
    for (i = 1; i <= n; i++) {
        if (mp[w[i - 1].s] == w[i - 1].s) {
            continue;
        }
        int give = mp[w[i - 1].s], get = have[w[i - 1].s];
        ans.pb({w[i - 1].s, get});
        have[give] = get;
        mp[get] = give;
    }
    assert(sz(ans) == n - cnt);
    for (auto &i : ans) {
        cout << i.f << " " << i.s << endl;
    }
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t;
    //cin >> t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

/*
the vast starry sky,
bright for those who chase the light.
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mk make_pair
const int inf=(int)1e9;
const ll INF=(ll)5e18;
const int MOD=998244353;
int _abs(int x){return x<0 ? -x : x;}
int add(int x,int y){x+=y; return x>=MOD ? x-MOD : x;}
int sub(int x,int y){x-=y; return x<0 ? x+MOD : x;}
#define mul(x,y) (ll)(x)*(y)%MOD
void Add(int &x,int y){x+=y; if(x>=MOD) x-=MOD;}
void Sub(int &x,int y){x-=y; if(x<0) x+=MOD;}
void Mul(int &x,int y){x=mul(x,y);}
int qpow(int x,int y){int ret=1; while(y){if(y&1) ret=mul(ret,x); x=mul(x,x); y>>=1;} return ret;}
void checkmin(int &x,int y){if(x>y) x=y;}
void checkmax(int &x,int y){if(x<y) x=y;}
void checkmin(ll &x,ll y){if(x>y) x=y;}
void checkmax(ll &x,ll y){if(x<y) x=y;}
#define out(x) cerr<<#x<<'='<<x<<' '
#define outln(x) cerr<<#x<<'='<<x<<endl
#define sz(x) (int)(x).size()
inline int read(){
    int x=0,f=1; char c=getchar();
    while(c>'9'||c<'0'){if(c=='-') f=-1; c=getchar();}
    while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
const int N=500005;
int n,a[N],b[N],p[N],id[N],pos[N];
bool cmp(int x,int y){return a[x]<a[y];}
vector<pii> ans;

int main()
{
    n=read();
    for(int i=1;i<=n;i++) a[i]=read();
    for(int i=1;i<=n;i++) b[i]=read();
    for(int i=1;i<=n;i++) p[i]=read(),pos[p[i]]=i;
    for(int i=1;i<=n;i++) if(i!=p[i]&&a[i]<=b[p[i]]){puts("-1"); return 0;}
    for(int i=1;i<=n;i++) id[i]=i;
    sort(id+1,id+n+1,cmp);
    for(int i=1;i<=n;i++){
        int u=id[i];
        if(u==p[u]) continue;
        int from=pos[u];
        ans.push_back(mk(from,u));
        pos[p[u]]=from; swap(p[from],p[u]);
    }
    printf("%d\n",sz(ans));
    for(auto &u : ans) printf("%d %d\n",u.first,u.second);
    return 0;
}


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

string rev(string a){//aのAとBを反転させたやつを返す
  for(auto &p:a)p^='A'^'B';
  return a;
}

int main(){
  int n;cin>>n;
  vector<vector<string>> s(n+1);//s[i]:n=iの時の答え
  for(int i=0;i<n;i++){
    for(string p:s[i]){
      s[i+1].push_back(p+p);
      s[i+1].push_back(p+rev(p));
    }
    s[i+1].push_back(string(1<<i,'A')+string(1<<i,'B'));
  }
  cout<<s[n].size()<<endl;
  for(string p:s[n])cout<<p<<endl;
}

//#include <atcoder/math>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define INF_LL 100000000000000000LL
#define INF 2000000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};
typedef vector<vector<edge>> graph;

// using mint = modint998244353;

char inv(char c){
    if(c == 'A') return 'B';
    return 'A';
}

vector<string> solve(int n){
    if(n == 1){
        return {"AB"};
    }
    vector<string> t = solve(n - 1);
    vector<string> res(t.size() * 2 + 1);
    rep(i, t.size()){
        rep(j, t[i].size()){
            res[i * 2] += t[i][j];
            res[i * 2] += t[i][j];
            res[i * 2 + 1] += t[i][j];
            res[i * 2 + 1] += inv(t[i][j]);
        }
    }
    rep(i, t.size() * 2 + 2){
        int cnt = 0;
        rep(j, res.size() - 1){
            if(res[j][i] == 'A') cnt++;
        }
        if(cnt != t.size()){
            res[res.size()-1]+='A';
        }else{
            res[res.size()-1]+='B';
        }
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    vector<string> ans = solve(n);
    int k = ans.size();
    vector<vector<int>> c(ans[0].size(), vector<int>(ans[0].size()));
    cout << k << endl;
    rep(i, k){
        string res = ans[i];
        cout << res << endl;
        rep(i, res.size()) REP(j, i + 1, res.size()) {if(res[i] == res[j])c[i][j]++;}
    }
    // int t = c[0][1];
    // rep(i, n) REP(j, i + 1, n) {
    //     if(c[i][j] != t){
    //         cout << i << " " << j << " " << c[i][j] << endl;
    //     }
    // }
    return 0;
}


#include<cstdio>
#include<iostream>
using namespace std;
int n;
int x[101],y[101];
//int t[1001];
int t;
int maxn,minn=9999;
int main()
{
	scanf("%d",&n);
	for(int a=1;a<=n;a++)
	scanf("%d",&t),maxn=max(maxn,t);
	for(int a=1;a<=n;a++)
	scanf("%d",&t),minn=min(minn,t);
	/*for(int a=1;a<=n;a++)
	{
		t[x[a]]--;
		t[y[a]]++;
	}
	for(int a=1;a<=1000;a++)
	{
		//printf("t[%d]:%d\n",a,t[a]);
		t[a]+=t[a-1];
		if(t[a]==-n)
		{
			printf("%d",a);
			return 0;
		}
	}
	printf("0");
	*/
	printf("%d",(minn-maxn+1>=0)?(minn-maxn+1):0);
	return 0;
}

#include <bits/stdc++.h>
#define maxn 100086

using namespace std;

int a, b;

int main(){
	scanf("%d%d", &a, &b);
	if(a > b){
		int sum = 0;
		for(int i = 1;i <= a;i++) sum += i, printf("%d ", i);
		for(int i = 1;i < b;i++) sum -= i, printf("%d ", -i);
		printf("%d", -sum);
	}else{
		int sum = 0;
		for(int i = 1;i <= b;i++) sum += i, printf("%d ", -i);
		for(int i = 1;i < a;i++) sum -= i, printf("%d ", i);
		printf("%d", sum);
	}
}