#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
using namespace std;
const int mx=1e6+5;
inline int read() {
	int x=0,f=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*f;
}
int L,R,res;
int prime[mx],phi[mx],c[mx],num,cnt,tot;
void write(int x) {
	if(x<10) {
		putchar(x+'0');
		return;
	}
	write(x/10);
	putchar(x%10+'0');
}
void dfs(int x,int mul,int f,int m) {
	if(mul>m) return;
	if(x>num) {
		tot+=(m/mul)*f;
		return;
	}
	dfs(x+1,mul,f,m);
	dfs(x+1,mul*c[x],(f==1)?-1:1,m);
}
int solve(int n,int m) {
	if(n>m) swap(n,m);
	int sum=0;
	for(int i=2;i<=n;i++) {
		num=0; int tmp=i;
		for(int j=1;j<=cnt&&prime[j]<=sqrt(tmp);j++) {
			if(tmp%prime[j]==0) {
				c[++num]=prime[j];
				while(tmp%prime[j]==0) tmp/=prime[j];
			}
		}
		if(tmp>1) c[++num]=tmp;
		tot=0;
		for(int j=1;j<=num;j++) dfs(j+1,c[j],1,m);
		sum+=tot;
	}
	for(int i=2;i<=n;i++) {
		sum-=m/i;
	}
	for(int i=2;i<=m;i++) {
		sum-=n/i;
	}
//	printf("%lld %lld %lld\n",n,m,sum+n);
	return sum+(n-1);
}
signed main() {
	L=read(),R=read();
	for(int i=2;i<=R;i++) {
		if(!phi[i]) prime[++cnt]=i,phi[i]=i-1;
		for(int j=1;j<=cnt&&i*prime[j]<=R;j++) {
			if(i%prime[j]==0) {
				phi[i*prime[j]]=phi[i]*prime[j];
			}
			else {
				phi[i*prime[j]]=phi[i]*(prime[j]-1);
			}
		}
	}
	if(L==1) {
		res=solve(R,R);
	}
	else {
		res=solve(R,R)-2*solve(L-1,R)+solve(L-1,L-1);
	}
	write(res);
}

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

int main() {
    int h,w;
    cin>>h>>w;

    vector<string>s(h);
    rep(i,h)cin>>s[i];

    int cnt=0;
    rep(i,h){
        rep2(j,0,w-2){
            if(s[i][j]=='.'&&s[i][j+1]=='.'){
                cnt++;
            }
        }
    }

    rep(i,w){
        rep2(j,0,h-2){
            if(s[j][i]=='.'&&s[j+1][i]=='.'){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}


#include    <bits/stdc++.h>
using       namespace std;
#define     endl "\n"
#define     pb push_back
#define     ll long long
#define     int ll
#define     mod 1000000007
#define     DEBUG cout<<"Hello1\n";
#define     all(v) (v).begin(),(v).end()
#define     deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int   N = 1e6 + 5;
const ll    inf = 1e18 + 5;
typedef     pair<int, int> pii;
void        fileIO();

template<class T> void print_container(T &container);
template<class T> void print_pair_container(T &container);
template<class T> void printArr(T &a, int n);
template<typename T> void debug(string s, T x);
template<typename T, typename... Args>
void debug(string s, T x, Args... args);

int n, m;

void solve(int tc = 0) {
	cin >> n;

	if (n % 2) {
		cout << "Odd\n";
	} else {
		if ((n / 2) % 2 == 0) {
			cout << "Even\n";
		} else {
			cout << "Same\n";
		}
	}
}

int32_t main()
{
	fileIO();

	int t = 1; cin >> t; for (int i = 1; i <= t; i++)
		solve();

	return 0;
}

void fileIO() {

	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}

template<typename T> void debug(string s, T x)
{
	cout << s << " = " << x << "\n";
}
template<typename T, typename... Args> void debug(string s, T x, Args... args)
{
	cout << s.substr(0, s.find(',')) << " = " << x << " | ";
	debug(s.substr(s.find(',') + 2), args...);
}

template<class T> void print_container(T &container)
{
	for (auto &t : container)
	{
		cout << t << " ";
	}
	cout << endl;
}
template<class T> void print_pair_container(T &container)
{
	for (auto &t : container)
	{
		cout << t.first << " " << t.second << endl;
	}
	cout << endl;
}
template<class T> void printArr(T &a, int n)
{
	for (int i = 0; i < n; i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}

#define _CRT_SECURE_NO_WARNINGS
#define fast ios::sync_with_stdio(false); cin.tie(0)
#define foru(i, k, n) for (ll i = k; i < n; i++)
#define ford(i, k, n) for (ll i = k; i >= n; i--)
#define pb push_back
#define ff first
#define ss second

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;

int main() {
	fast;
	int t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		int cnt = 0;
		while (n % 2 == 0) {
			n /= 2;
			cnt++;
		}
		if (cnt == 0)cout << "Odd\n";
		else if (cnt == 1)cout << "Same\n";
		else cout << "Even\n";
	}
	return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define rf(i, a, b) for (ll i = a; i >= b; i--)
typedef std::vector<long long> vi;
#define F first
#define S second
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(), a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
const ll INF = LLONG_MAX / 2;
const ll N = 2e5 + 1;
using namespace std;
ll n, maxid = 0, m;
ll pow1(ll n, ll p)
{
    if (p == 0)
        return 1;
    ll x = pow1(n, p / 2);
    if (x > m || x >= 1000000001)
        return INF;
    x = (x * x);
    if (x > m)
        return INF;
    if (p % 2 == 0)
        return x;
    else
    {
        if (x * n > m)
            return INF;
        return (x * n);
    }
}
string x;
bool check(ll k)
{
    ll j = 0, ans = 0;
    rf(i, n - 1, 0)
    {
        if (pow1(k, j) == INF)
            return false;
        if (pow1(k, j) + ans > m || ans > m)
            return false;
        ans += (pow1(k, j) * ((ll)(x[i] - '0')));
        j++;
    }
    if (ans > m)
        return false;
    return true;
}
int main()
{
    fast;
    ll t = 1;
    // std::cin >> t;
    while (t--)
    {
        cin >> x;
        n = x.length();
        cin >> m;
        if (x.length() == 1)
        {
            ll c = x[0] - '0';
            if (m < c)
                cout << 0 << "\n";
            else
                cout << 1 << "\n";
            continue;
        }
        fr(i, 0, n)
            maxid = max(maxid, (ll)(x[i] - '0'));
        ll l = maxid + 1, r = m + 1;
        // cout << l << "\n";
        // cout << maxid << "\n";
        while (l <= r)
        {
            ll mid = (l + r) / 2;
            if (check(mid))
            {
                l = mid + 1;
            }
            else
            {
                r = mid - 1;
            }
        }
        cout << l - 1 - maxid << "\n";
    }
}

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

typedef unsigned long long ull;
typedef __int128 ll;
string x;
ull m;

bool check(ull mid)
{
	ll ans=0;
	int flag=1;
	for(int i=0;i<x.size();i++)
	{
		ans=ans*mid+ll(x[i]-'0');
		if(ans>m)
		{
			flag=0;
			break;
		}
	}
	return flag;
}

int main()
{
	char c='0';
	cin>>x>>m;
	for(int i=0;i<x.size();i++)
	{
		c=max(c,x[i]);
	}
	ull t=c-'0';
	if(x.size()==1)
	{
		if(t<=m) cout<<1<<endl;
		else cout<<0<<endl;
	}
	else
	{
		ull l=0,r=1e18;
		while(l<r)
		{
			ull mid=(l+r+1)>>1;
			if(check(mid)) l=mid;
			else r=mid-1;
		}
		if(l<t) cout<<0<<endl;
		else cout<<l-t<<endl;
	}

	return 0;
}


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

#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
//#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

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

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

int main()
{fast;
 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 #endif
 int t=1,n;
 //cin>>t;
 while(t--)
 {cin>>n;
  string a,b;
  cin>>a>>b;
  queue<int> q1,q2;
  rep(i,0,n){
    if(a[i]=='0'){
        q1.push(i);
    }
    else{
        q2.push(i);
    }
  }
  int zero=0,one=0;
  rep(i,0,n){
    if(b[i]=='0') zero++;
    else one++;
  }
  if(zero!=q1.size()||one!=q2.size()){
    cout<<-1<<endl;
    continue;
  }
  int ans=0;
  int i=n-1;
  while(i>=0){
    if(a[i]==b[i]){
        i--;
        continue;
    }
    if(a[i]=='1'){
        int j=i;
        while(a[j]!='0'){
            j--;
        }
        swap(a[i],a[j]);
        i--;
    }
    else{
        int k=i;
        while(b[k]!='0'){
            k--;
        }
        swap(b[i],b[k]);
        i--;
    }
    //cout<<i<<" "<<a<<" "<<b<<endl;
    ans++;
  }
  cout<<ans<<endl;
 }
 return 0;
}

#include <bits/stdc++.h>

#define int long long

using namespace std;

#ifdef LOCAL
#include "/media/brayand/BrayanD/debugger.h"
#else
#define db(...) false
#define dbl(...) false
#define dbg(...) false
#define dbm(...) false
#define dbs(...) false
#define dbas(...) false
#endif

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

    int N;
    cin >> N;

    string A, B;
    cin >> A >> B;

    vector<int> v1, v2;

    for(int i = 0 ; i < N ; i++)
    {
    	if(A[i] == '1')
 		{
 			v1.push_back(i);
 		}
 		if(B[i] == '1')
 		{
 			v2.push_back(i);
 		}
    }

    if(v1.size() != v2.size())
    {
    	cout << -1 << '\n';
    	return 0;
    }

    int tam = v1.size();

    int res = 0;

    for(int i = 0 ; i < tam ; i++)
    {
    	if(v1[i] == v2[i])continue;
    	if(v1[i] < v2[i])
    	{
    		if(i != tam-1)
    		{
    			if(v1[i+1] <= v2[i])
    			{
    				// db(1);
    				res += v1[i+1]-v1[i]-1;
    			}
    			else
    			{
    				res += v2[i]-v1[i];
    			}
    		}
    		else
    		{
    			res += v2[i]-v1[i];
    		}
    	}
    	if(v1[i] > v2[i])
    	{
    		if(i != 0)
    		{
    			if(v1[i-1] >= v2[i])
    			{
    				res += v1[i]-v1[i-1]-1;
    			}
    			else
    			{
    				res += v1[i]-v2[i];
    			}
    		}
    		else
    		{
    			res += v1[i]-v2[i];
    		}
    	}
    }

    cout << res << '\n';

    return 0;
}


#include<bits/stdc++.h> // 54 71 "Baklol, Take it easy"
using namespace std;
using ll = long long int;
using ld = long double;

#define rep(x, k, n)        for(int x = (k); x <= (n); ++x)
#define rept(x, k, n)       for(int x = (k); x < (n); ++x)
#define repr(x, k, n)       for(int x = (k); x >= (n); --x)
#define pb                  push_back
#define siz(x)              ((int)(x).size())
#define o2(x)               ((x) * (x))
#define all(x)              (x).begin(), (x).end()
#define clr(x, k)           memset(x, k, sizeof(x)) // 0, -1
#define printv(v, k, n)     rep(i, k, n) cout << v[i] << " \n"[i==n];
#define print2dv(V,k,n,m)   rep(j, k, n) printv(V[j], k, m);
#define out(x)              cout << ((x) ? "Yes" : "No") << '\n'
#define setbits(x)          __builtin_popcountll(x)
#define inf                 INT_MAX
#define ninf                INT_MIN
#define int                 long long // "be carefull"

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

template <typename Arg1>
void debug_out(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1  << " ]" << "\n";
}

template <typename Arg1, typename... Args>
void debug_out(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << ",";
    debug_out(comma+1, args...);
}

#ifndef ONLINE_JUDGE
#define deb(...) cerr << "[ ", debug_out(#__VA_ARGS__, __VA_ARGS__)
#define debv(v, k, n)       rep(i, k, n) cerr << v[i] << " \n"[i==n];
#define deb2dv(V, k, n, m)  rep(j, k, n) debv(V[j], k, m);
#define line                rep(i, 0, 50){ cerr << '-'; } cerr << '\n'
#else
#define deb(...)
#define debv(v, k, n)
#define deb2dv(V, k, n, m)
#define line
#endif

const int mod = 1e9 + 7; // 998244353;
const int N = 2e5 + 5, M = 2e5 + 5;

/*/------------------------------ CODE BEGINS ------------------------------/*/

int k;

void Solve_main() {

    cin >> k;
    int res = 0;
    rep(a, 1, N){
        if(a > k) break;
        rep(b, 1, N){
            if((a * b) > k) break;
            rep(c, 1, N){
                if((a * b * c) > k) break;
                res++;
            }
        }
    }
    cout << res << '\n';
}

/*/------------------------------- CODE ENDS -------------------------------/*/

int32_t main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    // cout << setprecision(12) << fixed;
    int tc = 1;
    // cin >> tc;
    for(int i = 1; i <= tc; i++) {
        Solve_main();
        // BRUTE_FORCE();
    }

    cerr << "[time:" << 1.0*clock()/CLOCKS_PER_SEC << "s] ";
    return 0;
}

/*
-> edge cases, n = 1 ?
-> Submit - right file.
-> Move on - if completely_stuck > 30 minute.
-> entire input - multiple testcases.
-> time complexity - 1 sec : 4e8 will work but risky.
-> space complexity - 256 mb : 6e7(int), 3e7(ll), 2e8(bool, char), will work.
-> mod : sort ?, mint, remove #define int.
-> builtin fuction - add ll.
-> Iterative > Recursive.
-> clear - global variables.
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int a[200000];

signed main() {
	int i;

	cin >> n;
	rep(i, n) cin >> a[i];

	int asum = 0, amax = 0;
	int res1 = 0;
	rep(i, n) {
		asum += a[i];
		amax = max(amax, a[i]);
		res1 += asum;
		int ans = res1 + (i + 1) * amax;
		cout << ans << endl;
	}

	return 0;
}


const bool isDebugMode = true;
int testcase = 1;
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
    using namespace atcoder;
#endif
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const int SHOWSIZE = 1 << 5;
const long long MOD = 1000000007; //998244353;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
const string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
long long power(long long a, long long n){long long res = 1; while(n > 0){if(n & 1)res = res * a; a = a * a; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void enu(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void enu2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, min(v.size(), SHOWSIZE)) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, min(v.size(), SHOWSIZE)){rep(j, min(v[i].size(), SHOWSIZE)) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b, a % b) : b;}
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template <typename T, typename U, typename... V> typename enable_if<is_same<T, U>::value != 0>::type fill_v(U &u, const V... v) { u = U(v...); }
template <typename T, typename U, typename... V> typename enable_if<is_same<T, U>::value == 0>::type fill_v(U &u, const V... v){for (auto &e : u) fill_v<T>(e, v...);}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

void solve();

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin >> testcase;
    while(testcase--) solve();
    return 0;
}

void solve(){
    ll L, R; cin >> L >> R;
    if(R < 2 * L) pt(0);
    else pt((R - 2 * L + 1) * (R - 2 * L + 2) / 2);
}

#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
vector<ll> solve(ll t, vector<ll> l, vector<ll> r) {
    vector<ll> res(t);

    for(ll i = 0ll; i < t; i++) {
        ll count = max(r[i] - 2ll * l[i] + 1ll, 0ll);
        res[i] = count * (count + 1ll) / 2ll;
    }
    return res;
}
int main()
{
	std::ios::sync_with_stdio(false);
	ll t;
    cin >> t;
    vector<ll> l(t), r(t);
    for(int i = 0; i < t; i++) {
        cin >> l[i] >> r[i];
    }
    vector<ll> res =  solve(t, l, r);
    for(ll i=0ll;i<t; i++) {
        cout << res[i] << endl;
    }
	return 0;
}


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

int main()
{
    int N,M;
    int x,y;
    string A[800];
    int score[800]={0};
    char dna[20][20];

    cin >> N >> M;

    for(int i=0; i<M; i++) {
        string a;
        cin >> a;

        bool iscontain=false;
        int conv=0;
        int convj=0;
        for( int j=0; j<i; j++)
            if(A[j].find(a)!=string::npos) {
                iscontain=true;
                if(score[j]>conv) {
                    conv=score[j];
                    convj=j;
                }
                break;
            }
        if(iscontain!=true) {
            A[i]=a;
            score[i]++;
        } else {
            score[convj]++;
            A[i]="";
        }
    }

    bool convine=true;

    while(convine) {
        convine=false;
        for(int i=0; i<M; i++) {
            if(A[i].size()>2){
                string b=A[i].substr(A[i].size()-2);
                for(int j=0; j<M; j++) {
                    if( i==j ) continue;
                    if( A[j][0]==b[0] && A[j][1]==b[1] ){
                        if( A[i].size()+A[j].size()-2 <= N) {
                            A[i] = A[i] + A[j].substr(2);
                            A[j] ="";
                            score[i]+=score[j];
                            score[j]=0;
                            convine=true;
                            break;
                        }
                    }
                }
            }
        }
    }

    convine=true;

    while(convine) {
        convine=false;
        for(int i=0; i<M; i++) {
            if(A[i].size()>2 && A[i].size()<N){
                for(int j=0; j<M; j++) {
                    if( i==j ) continue;
                    if( (A[j].size() > 2) && ((A[i].size()+A[j].size()) <= N) ){
                        A[i] = A[i] + A[j];
                        A[j] ="";
                        score[i]+=score[j];
                        score[j]=0;
                        convine=true;
                        break;
                    }
                }
            }
        }
    }

    for(int i=0; i<M; i++){
        int max=score[i];
        int maxj=i;
        for(int j=i; j<M; j++){
            if(score[j]>max) {
                max=score[j];
                maxj=j;
            }
        }
        if( i!=maxj){
            string tmp;
            tmp=A[maxj];
            A[maxj]=A[i];
            A[i]=tmp;
            int ti=score[maxj];
            score[maxj]=score[i];
            score[i]=ti;
        }
    }

    for(int i=0; i<N; i++) {
        if(A[i].size() < 20) A[i]+="....................";
    }

    for(int i=0; i<N; i++) {
        cout << A[i].substr(0,20) << endl;
    }
};

#include <iostream>
#include <cmath>
#include <vector>
int main(void)
{
  size_t N, M;
  std::cin >> N >> M;

  std::vector<int> A(M);
  std::vector<int> B(M);
  for (size_t i = 0; i < M; i++) {
    std::cin >> A[i] >> B[i];
  }

  size_t K;
  std::cin >> K;

  std::vector<int> C(K);
  std::vector<int> D(K);
  for (size_t i = 0; i < K; i++) {
    std::cin >> C[i] >> D[i];
  }

  int count = 0;
  size_t KK = (size_t)std::pow(2, K);
  for (size_t j = 0; j < KK; ++j) {
    bool n[N+1] = {};
    for (size_t i = 0; i < K; i++) {
      n[j&(1<<i) ? C[i] : D[i]] = true;
    }
    int c = 0;
    for (size_t i = 0; i < M; i++) {
      if (n[A[i]] && n[B[i]]) {
        c++;
      }
    }
	count = std::max(count, c);
  }

  std::cout << count;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
#define lin(x) ll x; cin>>x;
#define stin(x) string x; cin>>x;
#define yn(x)  if(x) {  cout<<"Yes"<<endl;   }    else {    cout<<"No"<<endl;   }
#define YN(x)  if(x) {  cout<<"YES"<<endl;   }    else {    cout<<"NO"<<endl;   }
#define co(x) cout<<x<<endl;
using ll=long long;
using ld=long double;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll mod=998244353;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
    return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
    return ((a > b) ? (a = b, true) : (false));
}
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

  mint x=1;
  x=A*(A+1)*B*(B+1)*C*(C+1);
  x=x/8;
  co(x);

}

#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <fstream>
using namespace std;
#define LL long long
LL a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, n = 0, m = 0, x = 0, y = 0;
string s;
vector<LL> v;
array<array<bool, 100005>, 105> dp;
struct Data
{
};
LL all = 0;
int main(void)
{
	cin >> n;
	v.resize(n);
	for (auto& i : v) {
		cin >> i;
		all += i;
	}
	dp[0][0] = true;
	dp[0][v[0]] = true;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < all; j++) {
			if (dp[i - 1][j]) {
				dp[i][j] = true;
				dp[i][j + v[i]] = true;
			}
		}
	}
	int ans = all;
	for (int i = (all + 1) / 2; i <= all; i++) {
		if (dp[n - 1][i]) {
			cout << i;
			return 0;
		}
	}
	return 0;
}


#include"iostream"
#include"cstdio"
#include"cmath"
#include"cstring"
#include"algorithm"
#include"stack"
#include"queue"
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define MOD 998244353
#define MAXN 15

int n;
ll k;
ll e[MAXN][MAXN];
int f[MAXN];
int ans=0;

int main()
{
	read(n),readl(k);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++) readl(e[i][j]);
		f[i]=i;
	}
	do
	{
		int lst=1;
		ll now=0;
		for(int i=2;i<=n;i++)
		{
			now+=e[lst][f[i]];
			lst=f[i];
		}
		now+=e[lst][1];
		if(now==k) ans++;
	}while(next_permutation(f+2,f+n+1));
	printf("%d\n",ans);
	return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
#include <complex>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; }
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; }

typedef long long ll;

template<class T> using vvec = vector<vector<T>>;
template<class T> using vvvec = vector<vvec<T>>;

constexpr ll INF = 1e14; //32 ~2*10^10 //64 ~9*10^19
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-6;

struct Edge {
	Edge(int _s, int _t, ll f, ll _cost = 1) : from(_s), to(_t), cost(_cost), fee(f) {};
	int from, to;
	ll cost;
	ll fee;
};

typedef vector<vector<Edge>> Graph;

void add_edge(Graph& g, int from, int to, ll fee, ll cost = 1) {
	g[from].push_back(Edge(from, to, fee, cost));
}

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

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

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

	ll h,w; cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s[i];

	ll ans = 0;
	rep(i, h) rep(j, w) {
		if (s[i][j] == '.') {
			if (i+1 < h && s[i+1][j] == '.') ++ans;
			if (j + 1 < w && s[i][j+1] == '.') ++ans;
		}
	}

	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long n , a [200005] , num , did [200005] , f = 1;
set < pair < int , int > > s;
vector < int > v;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin >> n;
    for ( int i = 1 ; i <= n ; i ++ )
    {
        cin >> a [i];
        s . insert ( { a [i] , i } );
    }
    while ( s . size () )
    {
        pair < int , int > p = * -- s . end ();
        s . erase ( -- s . end () );
        int x = p . first , y = p . second;
        if ( x == y ) continue;
        num ++;
        if ( x > y )
        {
            if ( did [y] )
            {
                f = 0;
                break;
            }
            did [y] = 1;
            s . erase ( s . lower_bound ( { a [ y + 1 ] , y + 1 } ) );
            swap ( a [y] , a [ y + 1 ] );
            s . insert ( { a [y] , y } );
            s . insert ( { a [ y + 1 ] , y + 1 } );
            v . push_back ( y );
        }
        else
        {
            if ( did [ y - 1 ] )
            {
                f = 0;
                break;
            }
            did [ y - 1 ] = 1;
            s . erase ( s . lower_bound ( { a [ y - 1 ] , y - 1 } ) );
            swap ( a [y] , a [ y - 1 ] );
            s . insert ( { a [y] , y } );
            s . insert ( { a [ y - 1 ] , y - 1 } );
            v . push_back ( y - 1 );
        }
    }
    if ( f == 0 )
    {
        cout << -1;
        return 0;
    }
    if ( v . size () == n - 1 ) for ( int i = 0 ; i < v . size () ; i ++ ) cout << v [i] << endl;
    else cout << -1;
}

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

class BIT{
public:
  ll n,bit[555555];
  BIT(){fill(bit,bit+555555,0);}
  void add(ll i,ll x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  ll sum(ll i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
};

BIT b=BIT();

void Main() {
  ll n;
  R n;
  vector<ll> a(n);
  rep(i,n) R a[i];
  {
    b.n=n+1;
    ll ans=0;
    rep(i,n) {
      b.add(a[i],1);
      ans+=b.sum(n+1)-b.sum(a[i]);
    }
    if(ans!=n-1) {
      pr(-1);
      return;
    }
  }
  rep(i,n) a[i]--;
  ll c[n];
  rep(i,n) c[a[i]]=i;
  vector<ll> v;
  rep(i,n) {
    while(c[i]!=i) {
      v.pb(c[i]);
      ll x=a[c[i]],y=a[c[i]-1];
      swap(a[c[i]],a[c[i]-1]);
      c[x]--;
      c[y]++;
    }
  }
  rep(i,v.size()) pr(v[i]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

void solve(long long*arr1 , long long*arr2 , long long n)
{
long long sum = 0;
for(int i = 0 ; i < n ; i++)
{
    sum+=(arr1[i]*arr2[i]);
}
if(sum==0)
{cout << "Yes" << endl;}
else
{
    cout << "No" << endl;
}
return;
}

int32_t main()
{
    ios::sync_with_stdio(0);

	cin.tie(0);
	cout.tie(0);
 long long n;
 cin >> n;
 long long*arr = new long long[n];
 long long*arrw = new long long[n];

 for(int i = 0 ; i  < n; i++)
 {
    cin >> arr[i];
 }
 for(int i = 0 ; i  < n; i++)
 {
    cin >> arrw[i];
 }
 solve(arr,arrw ,n);
 return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <deque>
#include <bitset>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#define ll              long long
#define ull             unsigned long long
#define pii             pair<int, int>
#define PLL             pair<ll,ll>
#define rep(i,a,b)      for(int  i=a;i<=b;i++)
#define dec(i,a,b)      for(int  i=a;i>=b;i--)
#define forn(i, n)      for(int i = 0; i < int(n); i++)
using namespace std;
int dir[4][2] = { { 1,0 },{ 0,1 } ,{ 0,-1 },{ -1,0 } };
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-6;

inline ll read()
{
    ll x = 0; bool f = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); }
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

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

ll qpow(ll m, ll k, ll mod)
{
    ll res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % mod;
        t = t * t % mod;
        k >>= 1;
    }
    return res;
}
/**********************************************************/
const ll mod = 998244353;
const int N = 1e5 + 5;
ll a[N], b[N];
int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;

    rep(i, 1, n)
        cin >> a[i];
    rep(i, 1, n)
        cin >> b[i];
    ll ans = 0;
    rep(i, 1, n)
        ans += a[i] * b[i];
    if (ans)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}


#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
typedef long long ll;
string num;
int rn[200005];
int k;
int n;
int dp[200005][20];
ll dfs(int x,ll now,bool zero,bool flag)
{
    int cnt=0;
    for(int i=0;i<16;i++)
    {
        if(now&(1<<i))cnt++;
    }
    if(x>=n)return cnt==k;
    if(cnt>k)return 0;
    if(!flag&&zero&&dp[x][cnt]!=-1)return dp[x][cnt];
    ll ans=0;
    int lim=flag?rn[x]:15;
    for(int i=0;i<=lim;i++)
    {
        int tmp;
        if(!zero&&i==0)tmp=now;
        else tmp=now|(1<<i);
        ans+=dfs(x+1,tmp,zero||(i!=0),flag&&(i==lim));
        ans%=mod;
    }
    if(!flag&&zero)dp[x][cnt]=ans;
    return ans;
}
int main()
{
    cin>>num>>k;
    n=num.size();
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        if(num[i]>='0'&&num[i]<='9')rn[i]=num[i]-'0';
        else rn[i]=num[i]-'A'+10;
    }
    printf("%lld\n",dfs(0,0,0,1));
    return 0;
}


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

int dist[1005][1005];
int A[1005],B[1005];
char C[1005];
vector<pair<int,int> > G[1005];

main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int N,M;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>A[i]>>B[i]>>C[i];
		G[A[i]].push_back(make_pair(B[i],C[i]));
		G[B[i]].push_back(make_pair(A[i],C[i]));
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) dist[i][j] = (1 << 29);
	}
	queue<pair<int,int > > Q;
	dist[1][N]=0;
	Q.emplace(1,N);
	while(Q.size()){
		auto [pos1,pos2]=Q.front();
		Q.pop();
		for(pair<int,int> e1:G[pos1]){
			for(pair<int,int> e2:G[pos2]){
				if(e1.second!=e2.second)continue;
				if(dist[e1.first][e2.first]==(1<<29)){
					dist[e1.first][e2.first]=dist[pos1][pos2]+1;
					Q.emplace(e1.first,e2.first);
				}
			}
		}
	}
	int ans=(1<<29);
	for(int i=1;i<=N;i++){
		ans=min(ans,2*dist[i][i]);
	}
	for(int i=0;i<M;i++){
		ans=min(ans,2*dist[A[i]][B[i]]+1);
		ans=min(ans,2*dist[B[i]][A[i]]+1);
	}
	if(ans!=(1<<29))cout<<ans<<endl;
	else cout<<-1<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll rd() {
	ll x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d rd()
ll a,b,k,aa,bb;
ll yh[65][65];
ll now,ans;
int main(){
	a=aa=d,b=bb=d,k=d;
	yh[0][0]=1,yh[1][0]=yh[1][1]=1;
	f(i,2,61){
		yh[i][0]=yh[i][i]=1;
		f(j,1,i-1)yh[i][j]=yh[i-1][j]+yh[i-1][j-1];
	}
	f(i,1,a+b){
		if(!aa)bb--,cout<<"b";
		else if(!bb)cout<<"a",aa--;
		else if(now+yh[aa+bb-1][aa-1]<k)now+=yh[aa+bb-1][aa-1],bb--,cout<<"b";
		else cout<<"a",aa--;
	}
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i] << " "
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF = (1LL<<60)-1;
const int maxN = 1000001;
int countFreq(string &pat, string &txt)
{
    int M = len(pat);
    int N = len(txt);
    int res = 0;
    for (int i = 0; i <= N - M; i++){
        int j;
        for (j = 0; j < M; j++)
            if (txt[i+j] != pat[j])
                break;
        if (j == M)
        {
           res++;
           j = 0;
        }
    }
    return res;
}

int32_t main(){
    SPEED;
    int a, b;
    cin >> a >> b;
    cout << (a + b)/2 << " " << a - (a + b)/2 ;
}

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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
    int a,b;
  cin>>a>>b;
  for(int i=-1000;i<=1000;i++){
    for(int j=-1000;j<=1000;j++){
    if(i+j==a && i-j==b){
      cout<<i<<" "<<j<<endl;
      return 0;
      }
  }
  }

    return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
    if(p==0) return 1;
    if(p%2==0){
        long long a=modpow(n,p/2,mod);
        return a*a%mod;
    }
    if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
    cerr<<"ERROR"<<endl;
    return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
    return modpow(n,mod-2,mod);
}

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

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


#include <bits/stdc++.h>

using namespace std;

//# define M_PI           3.14159265358979323846

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x0, y0, xn, yn;
  cin >> n >> x0 >> y0 >> xn >> yn;
  pair<double, double> c = {((double)(x0+xn)) /2., ((double)(y0+yn)) /2.};
  pair<double, double> v = {x0 - c.first, y0 - c.second};
  double r = sqrt(v.first * v.first + v.second * v.second);
  double alpha;
  if (x0 != xn) {
    alpha = atan(v.second/v.first);
    if (v.first < 0) {
      alpha += M_PI;
    }
  } else {
    alpha = M_PI/2.;
    if (v.second < 0) {
      alpha += M_PI;
    }
  }
  pair<double, double> v1 = {r * cos(alpha + 2.*M_PI/n), r * sin(alpha + 2.*M_PI/n)};
  cout << c.first + v1.first << " " << c.second + v1.second << endl;
  return 0;
}
// go through problem examples
// for A, B: local structure, brute force
// unit test problem mechanics
// sums, multiplication -> long long
// lcm, gcd -> prime factorization -> first figure for one factor
// expectation, count -> sumation order
// max -> greedy, binsearch, dp
// bit operations -> figure of single bits


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }
template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << fixed << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n, t;
    cin >> n >> t;
    vector<vector<int>> T;
    init(T, 0, n, n);
    FOR(i, n) FOR(j, n) cin >> T[i][j];

    int cnt = 0;
    vector<int> v(n);
    iota(v.begin(), v.end(), 0);
    do{
        if (v[0] != 0) break;
        ll time = 0;
        FOR(i, n-1)
            time += T[v[i]][v[i+1]];
        time += T[v[n-1]][0];
        cnt += time == t;
    }while(next_permutation(v.begin(), v.end()));
    cout << cnt << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll N,K;
	cin >> N >> K;
	vector<vector<int>> T(N,vector<int>(N));
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cin >> T.at(i).at(j);
		}
	}
	vector<int> perm(N - 1);
	ll count = 0;
	ll time;
	for(int i = 0; i < N - 1; i++){
	       	perm.at(i) = i + 1;
	}
	do{
		time = T.at(0).at(perm.at(0));
		for(int i = 0; i < N - 2; i++){
			time += T.at(perm.at(i)).at(perm.at(i + 1));
		}
		time += T.at(perm.at(N - 2)).at(0);
		if(time == K) count++;
	}while(next_permutation(perm.begin(),perm.end()));
	cout << count << endl;
}


// Username: WillTheBill
// Time of creation: 2020-11-22 13:51
// Original filename: m.cp.cpp

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

// shortcuts
#define pb push_back
#define fi first
#define se second
#define all(_v) _v.begin(),_v.end()
#define ll long long

// IO
#define multitest signed __T; cin >> __T; while(__T--)
template<typename T>
void _read(T& t);
template<typename T>
void _read(vector<T>&v);
template<typename T1, typename T2>
void _read(pair<T1,T2>&p);
template<typename T>
void _read(T& t){cin >> t;}
template<typename T>
void _read(vector<T>&v){for(unsigned _i=0;_i<v.size();_i++)_read(v[_i]);}
template<typename T1, typename T2>
void _read(pair<T1,T2>&p){_read(p.first);_read(p.second);}
void _masterread(){}
template<typename T,typename... V>
void _masterread(T& t, V&... v){_read(t);_masterread(v...);}
#define re(...)_masterread(__VA_ARGS__)

template<typename T>
void _print(T t);
template<typename T>
void _print(vector<T>&v);
template<typename T1, typename T2>
void _print(pair<T1,T2>&p);
template<typename T>
void _print(T t){cout<<t;}
template<typename T>
void _print(vector<T>&v){for(unsigned _i=0;_i<v.size();_i++)_print(v[_i]),cout<<(_i==v.size()-1?"":" ");}
template<typename T1, typename T2>
void _print(pair<T1,T2>&p){_print(p.first);cout<<" ";_print(p.second);}
void _masterprint(){cout<<endl;}
template<typename T,typename... V>
void _masterprint(T t, V... v){_print(t);if(sizeof...(v))cout<<" ";_masterprint(v...);}
#define pr(...)_masterprint(__VA_ARGS__)

// DEBUG
// colored output???
template <typename T> // start forward declaration
void _debug(T t);
template<typename T1,typename T2>
void _debug(pair<T1,T2> p);
template<typename T>
void _debug(vector<T>v);
template <typename T> // end forward declaration
void _debug(T t){cerr<<t;}
template<typename T1,typename T2>
void _debug(pair<T1,T2> p){cerr<<"{";_debug(p.first);cerr<<", ";_debug(p.second);cerr<<"}";}
template<typename T>
void _debug(vector<T>v){cerr<<"(";for(unsigned _i=0;_i<v.size();_i++)_debug(v[_i]),cerr<<(_i==v.size()-1?"":", ");cerr << ")";}
void _masterdebug(){cerr<<"]\n";}
template<typename T,typename... V>
void _masterdebug(T t,V... v){_debug(t);if(sizeof...(v))cerr<<", ";_masterdebug(v...);}
#ifdef __local__
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"] = [";_masterdebug(__VA_ARGS__)
#else
#define debug(...)
#endif

// TYPES
// #define int long long

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    vector<vector<vector<double>>> dp (101, vector<vector<double>> (101, vector<double> (101, 0.0)));
	int A,B,C; re(A,B,C);
	dp[A][B][C] = 1.0;
	double sum = 0;
	double propsum = 0;
	for(int i = 0; i <= 100; i++){
		for(int j = 0; j <= 100; j++){
			for(int k = 0; k <= 100; k++){
				if(i == A && j == B && k == C) continue;
				int s = i + j + k;
				if(s <= 1) continue;
				if((i == 100 && j == 100) || (i == 100 && k == 100) || (j == 100 && k == 100)) continue;
				if(i > 0 && j != 100 && k != 100) dp[i][j][k] += dp[i-1][j][k] * (i-1) / ((double)(s-1));
				if(j > 0 && i != 100 && k != 100) dp[i][j][k] += dp[i][j-1][k] * (j-1) / ((double)(s-1));
				if(k > 0 && i != 100 && j != 100) dp[i][j][k] += dp[i][j][k-1] * (k-1) / ((double)(s-1));
				if(dp[i][j][k] < 0){
					debug(i,j,k);
				}
				if(i == 100 || j == 100 || k == 100){
					int amount = i - A + j - B + k - C;
					if(amount < 0) continue;
					debug(dp[i][j][k], i, j, k, amount);
					sum += amount * dp[i][j][k];
					propsum += dp[i][j][k];
				}
			}
		}
	}
	debug(dp[99][99][99]);
	debug(sum, propsum);
	cout << setprecision(10) << fixed;
	pr(sum / propsum);
}

#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
using P = pair<int,int>;
const char EOLN = '\n';
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define int long long
// DP
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

// 定数
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による
const double pi = 3.14159265359;

// メモ
// vector二次元配列
// vector<vector<ll>> cnt(h,vector<ll> (w));
// bit演算
// for (int bit = 0; bit < (1<<k); ++bit)
// bit & (1 << i)
// 複数変数をいっきに代入
// tie(a,b,c) = make_tuple(10, 7.7, "hello");

//大きい配列はglobalで宣言しておいた方が良い
//3次元はvectorだと面倒だから配列で。
const int x=100;
double dp[x+1][x+1][x+1];

signed main()
{
    int a,b,c;
    cin >> a >> b >> c;
    for(int i=x-1; i>=0; --i){
        for(int j=x-1; j>=0; --j){
            for(int k=x-1; k>=0; --k){
                if(i+j+k == 0) continue;
                double now = 0;
                now += dp[i+1][j][k]*i;
                now += dp[i][j+1][k]*j;
                now += dp[i][j][k+1]*k;
                dp[i][j][k] = now/(i+k+j) + 1;
            }
        }
    }
    double ans = dp[a][b][c];
    //少数の出力はprintfで指定するのが良い
    printf("%.10f\n",ans);

    return 0;
}


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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int A, B, X, Y;
    cin >> A >> B >> X >> Y;
    int N = 200;
    vector<vector<pair<int, int>>> list(N);
    for (int i = 0; i < 100; i++)
    {
        list[i].push_back({i + 100, X}), list[i + 100].push_back({i, X});
        if (i != 99)
        {
            list[i + 1].push_back({i + 100, X}), list[i + 100].push_back({i + 1, X});
            list[i].push_back({i + 1, Y}), list[i + 1].push_back({i, Y});
            list[i + 100].push_back({i + 101, Y}), list[i + 101].push_back({i + 100, Y});
        }
    }

    vector<int> length(N, MOD); //始点からの距離
    queue<int> que;             //訪問予定
    int search, now;

    que.push(A - 1);
    length[A - 1] = 0;
    while (!que.empty())
    {
        int now = que.front();
        que.pop();
        for (int i = 0; i < list[now].size(); i++)
        {
            auto search = list[now][i];
            int to = search.first;      //目的地
            int Length = search.second; //距離
            if (length[to] > length[now] + Length)
            {
                length[to] = length[now] + Length;
                que.push(to);
            }
        }
    }
    cout << length[B + 99];
}

/*
   Three things which are very important --
   Violence - Speed - Momentum
*/
#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 oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define setbits(x)      __builtin_popcountll(x)
#define leadzero(x)     __builtin_clz(x)
#define trailzero(x)    __builtin_ctz(x)
#define bitsparity(x)   __builtin_parity(x)
#define mod             1000000007
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll              long long
#define pre(y,x)        fixed<<setprecision(y)<<x
#define dbg1(x)         cerr << "|" << #x << ": " << (x) << "|\n";
#define dbg2(x,y)       cerr << "|" << #x << ": " << (x) << "|" << #y << ": " << (y) << "|\n";
#define dbg3(x,y,z)     cerr << "|" << #x << ": " << (x) << "|" << #y << ": " << (y) << "|" << #z << ": " << (z) << "|\n";
#define ff              first
#define ss              second
#define pb              push_back
#define eb              emplace_back
#define popb            pop_back
#define endl            '\n'
#define all(v)          v.begin(), v.end()
#define sz(x)           ((int)((x).size()))
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
ll power(ll a, ll b) {
	if(b<0) return 1;
	ll res=1;
	while(b) {
		if(b&1)
			res = (res*a);//%mod;
		a = (a*a);//%mod;
		b >>= 1;
	}
	return res;
}
bool ispoweroftwo(ll x){ return (x&&!(x&(x-1)));}
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
const int inf = 1e9;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
char MV[] = {'U', 'R', 'D', 'L'};
//integer to char always remember (char+'0')
const double pi = acos(-1);
const ll INF = 1e18;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
	FIO;
	int a, b, x, y;
	cin >> a >> b >> x >> y;

	int diff = abs(a-b);

	if(diff == 0) {
		cout << x;
	}
	else if(diff == 1) {
		if(a > b) {
			cout << x;
		} else {
			cout << min(diff*3*x-(diff-1)*x, x + diff*y);
		}
	} else {
		if(a > b) {
			cout << min(2*diff*x-x, x + (diff-1)*y);
		} else {
			cout << min(diff*3*x-(diff-1)*x, x + diff*y);
		}
	}
}
/*

*/


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

using namespace __gnu_pbds;
using namespace std;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcountll(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pii,vector<pii>,greater<pii> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator
#define E 0.0000001

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}

typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int32_t main()
{
	fast;
	string s;cin>>s;
	int ans=0;
	for(int i=0;i<=9999;i++)
	{
		string cur=tostring(i);
		reverse(all(cur));
		while(cur.size()<4)
			cur+='0';
		reverse(all(cur));

		mii exist;
		for(int j=0;j<4;j++)
			exist[cur[j]]++;

		bool flag=true;
		for(int j=0;j<10;j++)
		{
			if(s[j]=='o' and !exist.count((j+'0')))
				flag=false;
			if(s[j]=='x' and exist.count((j+'0')))
				flag=false;

		}

		ans+=(flag);
	}
	cout<<ans;
}

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

int main() {
    string s;
    cin >> s;
    int count = 0;
    bool flag;
    for (int i = 0; i < 10000; i++) {
        flag = true;
        vector<int> m(10);
        int x = i;
        for (int j = 0; j < 4; j++) {
            m[x%10] = 1;
            x /= 10;
        }
        for (int k = 0; k < 10; k++) {
            if (s[k] == 'o' && m[k] != 1) flag = false;
            if (s[k] == 'x' && m[k] != 0) flag = false;
        }
        if (flag) count++;
    }

    cout << count << endl;
}


/* by Hyperhydrochloric Acid */
#include <bits/stdc++.h>
using namespace std;
#define SZ(x)               ((int)(x).size())
#define all(x)              (x).begin(), (x).end()
#define loop(i, n)          for(int i = 0; i < (n); ++i)
#define cont(i, n)          for(int i = 1; i <= (n); ++i)
#define circ(i, a, b)       for(int i = (a); i <= (b); ++i)
#define range(i, a, b, c)   for(int i = (a); ((c) > 0 ? i <= (b) : i >= (b)); i += (c))
#define foreach(it, v)      for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it)
#define y0          y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1          y1II11II11III11I1III11II111IIII1II1I1
#define pub         push_back
#define pob         pop_back
#define mak         make_pair
typedef long long   ll;
typedef long double lf;
const int   Inf = 0x3f3f3f3f;
const ll    INF = 0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

const int jt = 1000000007;
int n;
char aa, ab, ba, bb;
int fib[1005];

int main() {
	scanf("%d", &n);
	scanf(" %c %c %c %c", &aa, &ab, &ba, &bb);
	aa -= 'A'; ab -= 'A'; ba -= 'A'; bb -= 'A';
	if((!ab && !aa) || (ab && bb)) {
		// 固定
		puts("1");
	} else if((!ab && aa && ba) || (ab && !ba && !bb)) {
		// 打印机
		int cnt = 1;
		cont(i, n - 3) (cnt *= 2) %= jt;
		printf("%d\n", cnt);
	} else {
		// 漏墨打印机
		fib[1] = 0; fib[2] = 1;
		circ(i, 3, n) fib[i] = (fib[i - 1] + fib[i - 2]) % jt;
		printf("%d\n", fib[n]);
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
  int N;
  cin >> N;
  ll m = 1e9 + 7;
  char a, b, c, d;
  cin >> a >> b >> c >> d;
  if (b == 'A') {
    if (a == 'A') {
      cout << 1 << endl;
      return 0;
    }
    if (c == 'B') {
      ll ret = 1;
      for (int i = 0; i < N - 3; i ++) {
        ret *= 2;
        ret %= m;
      }
      cout << ret << endl;
      return 0;
    }
    ll ans[1010];
    ans[2] = ans[3] = 1;
    for (int i = 4; i <= N; i ++) {
      ans[i] = ans[i - 1] + ans[i - 2];
      ans[i] %= m;
    }
    cout << ans[N] << endl;
  } else {
    if (d == 'B') {
      cout << 1 << endl;
      return 0;
    }
    if (c == 'A') {
      ll ret = 1;
      for (int i = 0; i < N - 3; i ++) {
        ret *= 2;
        ret %= m;
      }
      cout << ret << endl;
      return 0;
    }
    ll ans[1010];
    ans[2] = ans[3] = 1;
    for (int i = 4; i <= N; i ++) {
      ans[i] = ans[i - 1] + ans[i - 2];
      ans[i] %= m;
    }
    cout << ans[N] << endl;
  }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using LD = long double;

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; }
void yes(bool ok = true){ cout << (ok ? "yes" : "no") << endl; }
void Yes(bool ok = true){ cout << (ok ? "Yes" : "No") << endl; }
void YES(bool ok = true){ cout << (ok ? "YES" : "NO") << endl; }

void Main(){
    const ll INF = 1e18;
    ll n; cin >> n;
    vll pow3(40, 3), pow5(30, 5);

    rep(i, 40) {
        if(pow3[i] > INF/3) break;
        pow3[i+1] = 3 * pow3[i];
    }
    rep(i, 30) {
        if(pow5[i] > INF/5) break;
        pow5[i+1] = 5 * pow5[i];
    }

    rep(i, 40) rep(j, 30){
        if(n == pow3[i] + pow5[j]){
            cout << i+1 << " " << j+1 << endl;
            return;
        }
    }
    cout << -1 << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    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()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll 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; cin >> N;
    vector<ll> cnt(200);
    rep(i,N) {
        ll a; cin >> a;
        cnt[a%200]++;
    }

    ll ans = 0;
    for (ll v : cnt) {
        ans += v*(v-1)/2;
    }

    cout << ans << endl;
}


#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(){
  long double X,Y,A,B; cin>>X>>Y>>A>>B;
  ll count = 0;
  long double col;
  while(X < Y){
    if( (X*A < X+B) && (X*A < Y) ){
      X *= A;
      count++;
    }
    else if(X+B < Y){
      col = (Y-X) / B;
      count += ceil(col)-1;
      break;
    }
    else break;
  }
  cout<<count;
}

#include<bits/stdc++.h>

using namespace std;

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

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

const ll   N     =  2e6+5;
const ll   mod   =  998244353;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   LEVEL =  log2(N)+1;

ll n, m;

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

void solve(){
	cin >> n >> m;
	deb1(fastmod(10, n, m * m) / m)
}

int main(){
	GODSPEED;
	int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[10][10],num[10];
int main()
{
	ll n,k,res=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
		num[i]=i;
	do
	{
		ll last,now,sum=0;
		for(int i=1;i<n;i++)
		{
			last=num[i];
			now=num[i+1];
			sum=sum+a[last][now];
		}
		sum=sum+a[1][num[n]];
		if(sum==k)
			res++;
	}while(next_permutation(num+2,num+1+n));
	cout<<res;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define length size()
#define int long long
#define ll long long
#include <cstdint>
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
const int MOD = 1000000007;
const int mod = 1000000007;
const int MAX = 510000;
const double inf = 900719925474099;
template<typename T> string join(vector<T> &vec ,const string &sp){
    int si = vec.length;
    if(si==0){
        return "";
    }else{
        stringstream ss;
        rep(i,si-1){
            ss << vec[i] << sp;
        }
        ss << vec[si - 1];
        return ss.str();
    }
}
vector<vector<int>> ruiseki2d(vector<vector<int>> vec){
    rep(i,vec.size()-1){
        rep(j,vec[0].size()-1){
            vec[i+1][j+1] = vec[i][j+1]+vec[i+1][j]-vec[i][j]+vec[i+1][j+1];
        }
    }
    return vec;
}
vector<int> ruiseki(vector<int> vec){
    rep(i,vec.size()-1){
        vec[i+1] += vec[i];
    }
    return vec;
}
int t,s;
int solve(int a){
    return (a<0)?a*s:a*t;
}
signed main(void){
    int n,k;
    cin >> n >> k;
    vector<int> vec(n-1);
    vector<vector<int>> town(n,vector<int>(n));
    rep(i,n-1){
        vec[i] = i+1;
    }
    rep(i,n){
        rep(j,n){
            cin >> town[i][j];
        }
    }
    int ans = 0;
    do {
        //cout << join(vec," ") <<endl;
        int sum = 0;
        int now = 0;
        for(int i=0;i<n-1;i++){
            int next = vec[i];
            sum += town[now][next];
            now = next;
        }
        sum += town[now][0];
        if(sum == k) ans++;
    }while (std::next_permutation(vec.begin(),vec.end()));
    cout << ans << endl;
}


#include<bits/stdc++.h>
#define int long long
#define ld long double
#define fi first
#define se second
#define vll vector<int>
#define pii pair<int,int>
#define pb push_back
#define sz(v) (int)(v).size()
#define inf (int)(1e18)
#define md (int)(1e9+7)
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;

const int M = 2e5 + 10;

#define K 101

int ex(int a,int b=md-2){
	int ans=1;
	while(b) {
		if(b&1) ans=(ans*a)%md;
		a=(a*a)%md,b/=2;
	}
	return ans;
}
inline int add(int a,int b){
	a+=b;
	if(a>=md) a-=md;
	return a;
}
inline int sub(int a,int b){
	a-=b;
	if(a<0) a+=md;
	return a;
}
inline int mul(int a,int b){
	return (a*b)%md;
}

int f[M],iv[M];
int C(int n,int r){
	if(n<r) return 0;
	return mul(f[n],mul(iv[r],iv[n-r]));
}

void init(){
	f[0]=1;
	for(int i=1;i<M;++i) {
		f[i]=mul(i,f[i-1]);
	}
	iv[M-1]=ex(f[M-1]);
	for(int i=M-2;i>=0;--i) {
		iv[i]=mul(i+1,iv[i+1]);
	}
}

struct mat{
	int data[K][K]={0};
};

mat operator*(mat &a, mat &b){
	mat c;
	for(int i=0;i<K;++i)for(int j=0;j<K;++j){
		c.data[i][j]=0;
		for(int k=0;k<K;++k) {
			c.data[i][j]+=(a.data[i][k]*1ll*b.data[k][j])%md;
			if(c.data[i][j]>=md) c.data[i][j]-=md;
		}
	}
	return c;
}

mat operator^(mat &a,int b){
	mat c;
	for(int i=0;i<K;++i)for(int j=0;j<K;++j) c.data[i][j]=(i==j);
	while(b){if(b&1)c=c*a;a=a*a;b/=2;}
	return c;
}

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

   	int n,m,k;
   	cin>>n>>m>>k;
   	mat A;
   	int a[n];
   	rep(i,0,n) cin>>a[i];
   	int p=ex(mul(m,2));
   	rep(i,0,n)rep(j,0,n) {
   		A.data[i][j]=i==j;
   	}
   	rep(i,0,m) {
   		int u,v;
   		cin>>u>>v;
   		u--,v--;
   		A.data[u][v]=add(A.data[u][v],p);
   		A.data[v][u]=add(A.data[v][u],p);
   		A.data[u][u]=sub(A.data[u][u],p);
   		A.data[v][v]=sub(A.data[v][v],p);
   	}
   	A=A^k;
   	mat B;
   	rep(i,0,n) {
   		rep(j,0,n) B.data[i][j]=a[j];
   	}
   	A=B*A;
   	rep(i,0,n) cout<<A.data[i][i]<<"\n";

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define uint unsigned int
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=(y);x<=(z);x++)
#define Red(x,y,z) for(int x=(y);x>=(z);x--)
using namespace std;
const int MAXN=100005;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,m,a[MAXN],b[MAXN],c[MAXN],vis[MAXN],ans[MAXN];
vector<int>G[MAXN];
void dfs(int x){
	vis[x]=1;
	for(auto o:G[x]){
		int y=a[o]+b[o]-x;
		if(~ans[o])continue;
		ans[o]=(y==a[o]);
		if(vis[y])continue;
		dfs(y);
	}
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),m=read(),memset(ans,-1,sizeof(ans));
	Rep(i,1,m)a[i]=read(),b[i]=read();
	Rep(i,1,n)c[i]=read();
	Rep(i,1,m)if(c[a[i]]==c[b[i]])
		G[a[i]].pb(i),G[b[i]].pb(i);
	Rep(i,1,n)if(!vis[i])dfs(i);
	Rep(i,1,m){
		if(c[a[i]]==c[b[i]])puts(ans[i]?"<-":"->");
		else puts(c[a[i]]<c[b[i]]?"<-":"->");
	}
	return 0;
}

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

#define rep(type, val, n) for(type val = 0; val < n; ++val)
#define repi(type, val, init, end) for(type val = init; val < end; ++val)

using Int = long long;
using uInt = unsigned long long;

int main() {
    uInt n, ans[100005] = { 0 };
    cin >> n;

    rep (int, i, n + 1) ans[i] = 1;
    repi(int, i, 2, n + 1) {
        if (ans[i] == 1) {
            for (uInt check_pow = i; check_pow < n + 1; check_pow *= i)
                for (uInt add_i = check_pow << (check_pow == i ? 1 : 0); add_i < n + 1; add_i += check_pow) {
                    ans[add_i]++;
                }

            ans[i]++;
        }
        else {}
    }
    repi (int, i, 1, n)
        cout << ans[i] << " ";
    cout << ans[n] << endl;

    return 0;
}


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

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

using namespace std;
typedef long long ll;

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

//fake_name
#include<bits/stdc++.h>
using namespace std ;
#define int long long int
#define F first
#define S second

int MOD = 998244353 ;
int mod = 1e9 + 7 ;
int inf = 1e18 ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int n ;
    cin >> n ;
    int a[n] , b[n] ;
    for( int i = 0 ; i < n ; i++ )
        cin >> a[i] >> b[i] ;
    int ans = inf ;
    for( int i = 0 ; i < n ; i++ ){
        for( int j = 0 ; j < n ; j++ )
            if( i == j )
                ans = min( ans , a[i]+b[j] ) ;
            else
                ans = min( ans , max( a[i] , b[j] ) ) ;
    }
    cout << ans ;

    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}


#include <iostream>
using namespace std;
int main() {
    int x,y;
    cin >> x >> y;
    if(x==y) {
        cout << x << endl;
        return 0;
    }
    else{
        cout << 3-x-y << endl;
        return 0;
    }
}

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define endl '\n'
#define pb push_back
#define conts continue
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define ff first
#define ss second
#define ceil2(x,y) (x+y-1) / y

#ifndef ONLINE_JUDGE
#define debug(x) cout << #x <<" = "; print(x); cout << endl;
#else
#define debug(x)
#endif

bool iseven(ll n) {if ((n & 1) == 0) return true; return false;}

void print(ll t) {cout << t;}
void print(int t) {cout << t;}
void print(string t) {cout << t;}
void print(char t) {cout << t;}
void print(double t) {cout << t;}
void print(ld t) {cout << t;}

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

void solve()
{
    ll a,b; cin >> a >> b;
    if(a == b){
        cout << a << endl;
    }
    else{
        if(a > b){
            swap(a,b);
        }

        if(a == 0 && b == 1){
            cout << 2 << endl;
        }
        else if(a == 0 && b == 2){
            cout << 1 << endl;
        }
        else if(a == 1 && b == 2){
            cout << 0 << endl;
        }
    }
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("D:/Competitive Programming/input.txt", "r", stdin);
    freopen("D:/Competitive Programming/output.txt", "w", stdout);
#endif
    fastio;
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long

const int MAX_N = 1e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

void solve() {
    int n, m; cin >> n >> m;
    int f[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            char c; cin >> c;
            f[i][j] = (c == '+' ? 1 : -1);
        }
    }
    int dp[n][m]; // (Takahashi - Aoki)
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            if (i == n - 1 && j == m - 1) { // base case
                dp[i][j] = 0;
            } else if ((i + j) % 2) {
                dp[i][j] = INF;
                if (i + 1 < n) dp[i][j] = min(dp[i][j], dp[i + 1][j] - f[i + 1][j]);
                if (j + 1 < m) dp[i][j] = min(dp[i][j], dp[i][j + 1] - f[i][j + 1]);
            } else {
                dp[i][j] = -INF;
                if (i + 1 < n) dp[i][j] = max(dp[i][j], dp[i + 1][j] + f[i + 1][j]);
                if (j + 1 < m) dp[i][j] = max(dp[i][j], dp[i][j + 1] + f[i][j + 1]);
            }
        }
    }
    if (dp[0][0] == 0) {
        cout << "Draw\n";
    } else {
        cout << (dp[0][0] > 0 ? "Takahashi" : "Aoki") << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int tc = 1;
    // cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
}

#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int h, w;
char a[2009][2009];
int dp[2009][2009];

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

    cin >> h >> w;

    rep(i, h) cin >> a[i];

    FORR(i, h) FORR(j, w) {
        if(i + 1 < h || j + 1 < w) dp[i][j] = -1e9;
        if(i + 1 < h)
            chmax(dp[i][j], -dp[i + 1][j] + (a[i + 1][j] == '+' ? 1 : -1));
        if(j + 1 < w)
            chmax(dp[i][j], -dp[i][j + 1] + (a[i][j + 1] == '+' ? 1 : -1));
    }

    if(dp[0][0] < 0) cout << "Aoki\n";
    if(dp[0][0] == 0) cout << "Draw\n";
    if(dp[0][0] > 0) cout << "Takahashi\n";

    return 0;
}


#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert
#define nl "\n"

const ll MOD = 998244353;

ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}

template<typename T> T signum(T a) {
    return (a > 0) - (a < 0);
}

template<typename T> T cmp(T a, T b) {
    return signum(a-b);
}

template<typename T> bool mins(T& lhs , T& rhs) {
    if (rhs < lhs) {
        lhs = rhs;
        return true;
    }

    return false;
}

template<typename T> bool maxs(T& lhs , T& rhs) {
    if (rhs > lhs) {
        lhs = rhs;
        return true;
    }

    return false;
}

const int MAX = INT_MAX;

void gks(int tc) {
    printf("Case #%d: ", tc);
};

int main() {
    string s1, s2, s3;
    cin>>s1;
    cin>>s2;
    cin>>s3;
    string p = "0123456789";

    set<char> a;
    for (auto x : s1) a.insert(x);
    for (auto x : s2) a.insert(x);
    for (auto x : s3) a.insert(x);
    if (a.size() >= 11)        {
        cout<<"UNSOLVABLE";
        return 0;
    }

    bool f = false;
    do {

        map<char, int> my_map;
        //if (p[0] == '0') continue;
        int i = 0;
        for (auto x : a) {
            my_map[x] = p[i++];
        }

        string i1;
        for (auto x : s1) {
            i1.append(1, my_map[x]);
        }

        if (i1 == "0") continue;
        string i2;
        for (auto x : s2) {
            i2.append(1, my_map[x]);
        }

        if (i2 == "0") continue;
        string i3;
        for (auto x : s3) {
            i3.append(1, my_map[x]);
        }

        if (i3 == "0") continue;

        ll j1 = stoll(i1);
        ll j2 = stoll(i2);
        ll j3 = stoll(i3);

        /*
        if (p == "0267495183") {
            cout<<j1<<nl<<j2<<nl<<j3<<nl;
        }
        */

        if (j1 + j2 == j3 && i1[0] != '0' && i2[0] != '0' && i3[0] != '0') {
            f = true;
            cout<<j1<<nl<<j2<<nl<<j3<<nl;
            break;
        }

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

    if (!f) {
        cout<<"UNSOLVABLE"<<nl;
    }

   return 0;
}

// doot diddly donger cuckerino Hahahahahah

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
//#pragma GCC optimize("unroll-loops")

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

using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vi = vector<int>;

#define all(x)  (x).begin(), (x).end()
const ld PI = acos(-1);

template <typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template <typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T, typename U>
std::ostream& operator<<(std::ostream& stream, const pair<T, U>& p) {
  return stream << p.first << " " << p.second;
}
template <typename T>
std::ostream& operator<<(std::ostream& out, const vector<T>& vec) {
  for (const T& x: vec) out << x << ' ';
  return out;
}
template <typename T>
std::istream& operator>>(std::istream& in, vector<T>& vec) {
  for (auto& x: vec) in >> x;
  return in;
}

class MEX {
  struct MEXNode {
    MEXNode *children[2];
    bool is_full = false;
    int cnt = 0;

  public:
    MEXNode() {
      children[0] = nullptr;
      children[1] = nullptr;
    }
  };
private:

  inline MEXNode *nonnull(MEXNode *& n) {
    if (!n) n = new MEXNode();
    return n;
  }

  void insert(int val, int level, MEXNode *n) {
    if (level == -1) {
      n->cnt++;
      n->is_full = true;
      return;
    }

    int cur_bit = (val & (1 << level)) >> level;
    insert(val, level - 1, nonnull(n->children[cur_bit]));

    n->is_full = nonnull(n->children[0])->is_full && nonnull(n->children[1])->is_full;
    n->cnt = nonnull(n->children[0])->cnt + nonnull(n->children[1])->cnt;
  }

  // Remove an integer from the set
  void remove(int val, int level, MEXNode *n) {
    if (level == -1) {
      n->cnt--;
      n->is_full = n->cnt > 0;
      return;
    }

    int cur_bit = (val & (1 << level)) >> level;
    remove(val, level - 1, nonnull(n->children[cur_bit]));

    n->is_full = nonnull(n->children[0])->is_full && nonnull(n->children[1])->is_full;
    n->cnt = nonnull(n->children[0])->cnt + nonnull(n->children[1])->cnt;
  }

  // Find the minimum element >=x that isn't present in the set
  int get(int val, int level, MEXNode *n) {
    if (n->is_full) {
      return -1;
    } else if (n->cnt == 0) {
      return val;
    }

    int cur_bit = (val & (1 << level)) >> level;
    int ans = get(val, level - 1, nonnull(n->children[cur_bit]));
    if (cur_bit == 0 && ans == -1) {
      ans = get((val >> level << level) | (1 << level), level - 1, nonnull(n->children[1]));
    }

    return ans;
  }

  MEXNode root_node;
public:

  void insert(int x) {
    insert(x, 31, &root_node);
  }
  void remove(int x) {
    remove(x, 31, &root_node);
  }
  int get(int x) {
    return get(x, 31, &root_node);
  }
};

class CNeqMin {
public:

  void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    MEX mex;
    for (int i = 0; i < n; ++i) {
      int x;
      cin >> x;
      mex.insert(x);
      cout << mex.get(0) << '\n';
    }
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	CNeqMin solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=1e5+5;
ll f[maxn][2],g[maxn];
int main()
{

    ll ans=0,x;
    int n;
    scanf("%d",&n);
    ll tot=2*n-3+(n-3)*(n-4)/2;
    tot%=mod;
    // 0 -  1 +
    f[0][1]=1; g[0]=1;
    for(int i=1;i<=n;i++)
    {
        f[i][0]=f[i-1][1];
        f[i][1]=(f[i-1][0]+f[i-1][1])%mod;
        g[i]=(f[i][0]+f[i][1])%mod;
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        x%=mod;
        ll plus=0,multi=0;
        plus=g[n-i];
        if(i>=2) plus=g[i-2]*plus%mod;
        if(i!=1) multi=1;
        if(i>=3) multi=g[i-3];
        if(i!=n) multi=g[n-i-1]*multi%mod;
        ans=(ans+1LL*x*(plus-multi+mod)%mod)%mod;
    }
    printf("%lld",(ans+mod)%mod);
    return 0;
}

#pragma GCC optimize("Ofast")
 #include <bits/stdc++.h>
#define ll         long long int
#define umap       unordered_map
#define mod        1000000007ll
#define pb         push_back
#define all(x)     (x).begin(), (x).end()
#define rall(x)    (x).rbegin(), (x).rend()
#define MN(a,b,c)  min(a,min(b,c))
#define MX(a,b,c)  max(a,max(b,c))
#define pr1         pair<ll,ll>
#define F          first
#define S          second
#define mP         make_pair
#define f(i,n)     for(ll i=0;i<n;i++)
#define f1(i,x,y)  for(ll i=x;i<=y;i++)
#define f2(i,x,y)  for(ll i=x;i>=y;i--)
#define yes        cout<<"YES"<<"\n"
#define no         cout<<"NO"<<"\n"
#define modsum(a,b)  ((a%mod)+(b%mod))%mod
#define modpro(a,b)  ((a%mod)*(b%mod))%mod
#define moddif(a,b)  ((a%mod)-(b%mod)+mod)%mod
#define modsumt(a,b,c) modsum(a,modsum(b,c))
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes
//__builtin_ctz(x)      to count the number of trailing zeroes
//__gcd(a,b)
// Binary Search
// TO AVOID GETTING INFINITE LOOP
// mid = (l+r)/2      l=mid+1   r=mid
// mid = (l+r+1)/2    l=mid     r=mid-1
using namespace std;
ll fac[200005];
/*void calc_pow2()
{
    pow2[0]=1;
    for(ll i=1;i<63;i++) pow2[i]=2*pow2[i-1];
}*/
ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=modpro(result,x);
        x=modpro(x,x);
        n=n/2;
    }
    return result;
}
ll binaryExponentiation(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}
ll pow1(ll x,ll y)
{
    ll z=1;
    while(y--){z=z*x;}
    return z;
}
/*bool isprime(ll n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}*/
// Returns n^(-1) mod p
ll  modInverse(ll n, ll p)
{
    return modularExponentiation(n, p - 2, p);
}
// Returns nCr % p using Fermat's little
// theorem.
unsigned long long nCrModPFermat(unsigned long long n,
                                 ll r, ll p)
{
    // Base case
    if (r == 0)
        return 1;

    // Fill factorial array so that we
    // can find all factorial of r, n
    // and n-r
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}
ll check(ll x,ll y)
{
    ll z=1;
    ll ans=0;
    while(z<x){ans++;z*=y;}
    return ans;
}

ll countbits(ll n)
{
    ll x=0;
    while(n>0)
    {
        x++;
        n=(n&(n-1));
    }
    return x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;cin>>n;
    vector <ll> a(n);
    f(i,n) cin>>a[i];
    if(n==1) cout<<a[0];
    else
    {
    ll dp[n][2];
    ll countp[n];
    ll countn[n];
    countp[1]=countn[1]=1;
    dp[1][0]=a[1];
    dp[1][1]=-1*a[1];
    ll sum=0;
    for(ll i=2;i<n;i++)
    {
        countp[i]=modsum(countp[i-1],countn[i-1]);
        countn[i]=countp[i-1];
        dp[i][0]=modsum(sum,modpro(countp[i],a[i]));
        dp[i][1]=moddif(dp[i-1][0],modpro(countn[i],a[i]));
        sum=modsum(dp[i][0],dp[i][1]);
        //cout<<dp[i][0]<<' '<<dp[i][1]<<' '<<sum<<"\n";
    }
    ll num=modsum(countp[n-1],countn[n-1]);
    num=modpro(num,a[0]);
    sum=modsum(sum,num);
    cout<<sum;
    }
}


// Problem : D - Let's Play Nim
// Contest : AtCoder - AtCoder Regular Contest 105
// URL : https://atcoder.jp/contests/arc105/tasks/arc105_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

int T;
int N;
int arr[100005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> T;
	while(T--){
		cin >> N;
		for(int i = 1; i<=N; i++){
			cin >> arr[i];
		}
		sort(arr+1, arr+1+N);
		if(N%2 == 1){
			cout << "Second\n";
		}
		else{
			bool secondwin = 1;
			for(int i = 2; i<=N; i+=2){
				if(arr[i] != arr[i-1]){
					secondwin = 0;
				}
			}
			if(secondwin){
				cout << "Second\n";
			}
			else{
				cout << "First\n";
			}
		}
	}
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n; cin >> n;
  map<int, int> mp;
  vector<int> v(1 << n, 0);
  for (int i = 0; i < 1 << n; i ++ )
  {
    int x; scanf("%d", &x);
    v.push_back(x);
    mp[x] = i;
  }
  for (int i = 0; i < n - 1; i ++ )
  {
    vector<int> a;
    for (int j = 0; j < v.size(); j += 2)
      a.push_back(max(v[j], v[j + 1]));
    v = a;
  }
  cout << mp[min(v[v.size() - 2], v[v.size() - 1])] + 1 << endl;
  return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define Rint register int
#define INF 0x3f3f3f3f
using namespace std;
typedef long long lxl;
const int maxn=1e5+5;

template <typename T>
inline void read(T &x)
{
	x=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	x*=f;
}

int n,k;
lxl ans;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
#endif
	read(n),read(k);
	for(int i=2;i<=(n<<1);++i)
	{
		int j=i-k;
		if((j<2)||(j>(n<<1))) continue;
		ans+=1ll*(2*min(n,i-1)-i+1)*(2*min(n,j-1)-j+1);
	}
	printf("%lld\n",ans);
	return 0;
}

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

int64_t solve(int64_t X) {
    // TODO: edit here
    return 100-X%100;
}

// generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int64_t X;
    cin >> X;
    auto ans = solve(X);
    cout << ans << endl;
    return 0;
}


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

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

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

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

class ops
{
    public:
    ll cx, cy, sx, sy;
    bool sw;

    ops()
    {
        cx = 0, cy = 0, sx = 1, sy = 1;
        sw = 0;
    }

    void t1()
    {
        swap(cx,cy);
        swap(sx,sy);
        sy = -sy;
        sw^=1;
        cy = -cy;
    }

    void t2()
    {
        swap(cx,cy);
        swap(sx,sy);
        sx = -sx;
        sw^=1;
        cx = -cx;
    }

    void t3(ll p)
    {
        sx = -sx;
        cx = -cx + 2*p;
    }

    void t4(ll p)
    {
        sy = -sy;
        cy = -cy + 2*p;
    }

    pii get(pii pt)
    {
        if(sw)
            swap(pt.ff, pt.ss);
        pt.ff = pt.ff*sx + cx;
        pt.ss = pt.ss*sy + cy;
        return pt;
    }

    void conv(ll ty, ll p = -1)
    {
        if(ty == 1)
            t1();
        else if(ty == 2)
            t2();
        else if(ty == 3)
            t3(p);
        else t4(p);
    }
};

int main()
{
  FAST/**/

  ll n;
  cin>>n;
  pii arr[n];
  rep(n)
        cin>>arr[i].ff>>arr[i].ss;

  ll m;
  cin>>m;
  pii op[m];
  rep(m)
  {
      cin>>op[i].ff;

      if(op[i].ff>2)
            cin>>op[i].ss;
  }

  ll q;
  cin>>q;

  pair<pii,ll> quer[q];
  rep(q)
        cin>>quer[i].ff.ff>>quer[i].ff.ss, quer[i].ss = i;
  ops ds;
  sort(quer,quer+q);
  ll ptr = 0;
  pii ans[q];
  rep(q)
  {
      while(ptr<m && quer[i].ff.ff-1>=ptr){
          //cout<<"applying "<<ptr+1<<' '<<op[ptr].ff<<'\n';
          ds.conv(op[ptr].ff, op[ptr].ss), ptr++;
          //cout<<ds.cx<<" "<<ds.cy<<" "<<ds.sx<<" "<<ds.sy<<'\n';
      }
      pii pt = ds.get(arr[quer[i].ff.ss-1]);
      ans[quer[i].ss] = pt;
  }

  rep(q)
        cout<<ans[i].ff<<" "<<ans[i].ss<<'\n';

  return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

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

int dp[1 << 17][17];

int main() {
    int n;
    int x[17], y[17], z[17], d[17][17];

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> z[i];
    }

    fill(d[0], d[n], INF);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            d[i][j] = abs(x[i] - x[j]) + abs(y[i] - y[j]) + max(0, z[j] - z[i]);
        }
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    fill(dp[0], dp[1 << n], INF);
    dp[0][0] = 0;
    for (int i = 0; i < (1 << n); ++i) {
        for (int u = 0; u < n; ++u) {
            for (int v = 0; v < n; ++v) {
                if (!(i >> v & 1)) {
                    chmin(dp[i | (1 << v)][v], dp[i][u] + d[u][v]);
                }
            }
        }
    }

    cout << dp[(1 << n) - 1][0] << endl;

    return 0;
}


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

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FastIO()            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define read()              freopen("in.txt","r",stdin)
#define write()             freopen("out.txt","w",stdout)

typedef long long           ll;
typedef unsigned long long  ull;
typedef double              dbl;
typedef float               flt;

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

typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef vector<pii>         vpii;
typedef vector<pl>          vpl;

#define pie                 acos(-1)

#define mp                  make_pair
#define pb                  push_back
#define eb                  emplace_back
#define ff                  first
#define ss                  second

#define MAX                 300005
#define MOD                 1000000007
#define INF                 1000000100

#define for0(i, n)          for(ll i=0; i<n; i++)
#define for1(i, n)          for(ll i=1; i<=n; i++)
#define forab(i, a, b)      for(ll i=a; i<=b; i++)
#define forabx(i, a, b, x)  for(ll i=a; i<=b; i+=x)
#define forinv(i, a, b)     for(ll i=a; i>=b; i--)

#define clr0(a)             memset(a, 0, sizeof(a))
#define ceil(x, y)          (x+y-1) / (y)
#define max3(a, b, c)       max(a, max(b, c))
#define min3(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 sort1(a, x, y)      sort(a+x, a+y+1)
#define debug(x)            cout << "DEBUG " << x << endl;

#define Y()                 cout << "YES" << endl;
#define N()                 cout << "NO" << endl;
#define inArr(a, x, y)      forab(i, x, y) { cin >> a[i]; }
#define outArr(a, x, y)     forab(i, x, y) { cout << a[i] << " "; } cout << endl;

void solve() {
    ll n;
    cin >> n;
    ll t[n+10], l[n+10], r[n+10];
    for1(i, n) {
        cin >> t[i] >> l[i] >> r[i];
    }
    ll ans = 0;
    for1(i, n-1) {
        forab(j, i+1, n) {
            ll l1, r1, l2, r2;
            if (t[i]==1) {
                l1 = l[i]*10;
                r1 = r[i]*10;
            }
            else if (t[i]==2) {
                l1 = l[i]*10;
                r1 = r[i]*10 - 1;
            }
            else if (t[i]==3) {
                l1 = l[i]*10 + 1;
                r1 = r[i]*10;
            }
            else if (t[i]==4) {
                l1 = l[i]*10 + 1;
                r1 = r[i]*10 - 1;
            }

            if (t[j]==1) {
                l2 = l[j]*10;
                r2 = r[j]*10;
            }
            else if (t[j]==2) {
                l2 = l[j]*10;
                r2 = r[j]*10 - 1;
            }
            else if (t[j]==3) {
                l2 = l[j]*10 + 1;
                r2 = r[j]*10;
            }
            else if (t[j]==4) {
                l2 = l[j]*10 + 1;
                r2 = r[j]*10 - 1;
            }

            if ( (l1>=l2 && l1<=r2) || (l2>=l1 && l2<=r1) || (r1>=l2 && r1<=r2) || (r2>=l1 && r2<=r1) ) {
                ans ++;
                //cout << "ANSWER ++ FOR " << i << " " << j << endl;
            }
        }
    }

    cout << ans << endl;
}

void testcase() {
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
}

int main () {
    FastIO()

    //testcase();
    solve();

    return 0;
}

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

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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 998244353//1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
int fact[300000];
int binExp(int x,int n)
{
    int res=1;
    while(n)
    {
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}
int modInv(int i) {return binExp(i,mod-2);}
int ncr(int n,int r) {return (n>=r?(fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod:0);}

signed main()
{
    fast

   int a,b,c,d;
   cin>>a>>b>>c>>d;
   cout<<a*d-b*c;
}