#include "bits/stdc++.h"
#include <cmath>
#include <limits>

using namespace std;

#define int long long
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)

#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ld long double
#define pii pair<int, int>
#define vi vector<int>

ld x,y,r;
bool sarkha(ld a, ld b)
{
    return (a - b) <= std::numeric_limits<long double>::epsilon();
}

bool ander(int X, int Y)
{
	ld Xx = (x - X) * (x - X) + (y - Y) * (y - Y);
	ld Yy = r * r;
	return sarkha(Xx, Yy);
}

void solve()
{
	cin >> x >> y >> r;
	int A = 0;
	for(int X = -4e5 ; X <= 4e5 ; X++)
  {
		int LEFT = -1e9;
		int RIght = -1e9;
		int L = -2e6, H = 2e6;
		while(L <= H)
    {
			int Middd = (L + H)/2;
			if(ander(X, Middd))
      {
				H = Middd - 1;
				LEFT = Middd;
			}
			else
      {
				if(Middd < y)
        {
					L = Middd + 1;
				}
				else
        {
					H = Middd - 1;
				}
			}
		}

		L = -2e6, H = 2e6;
		while(L <= H)
    {
			int Middd = (L + H)/2;
			if(ander(X, Middd))
      {
				L = Middd + 1;
				RIght = Middd;
			}
			else
      {
				if(Middd < y)
        {
					L = Middd + 1;
				}
				else
        {
					H = Middd - 1;
				}
			}
		}

		if(LEFT != -1e9)
    {
			A += RIght - LEFT + 1;
		}
	}
	cout << A << "\n";
}

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

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF 1e17
#define zero (int)0
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
const int mod = 1e9+7; //may change to that 99.. number.
signed main()
{
	fast();
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = d*c-b;
	if(x <= 0)
	{
		cout << "-1\n";
		return 0;
	}
	int t = a/x;
	t+=(a%x>0);
	cout << t << "\n";
	return 0;
}


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

int main() {
  ll h,w,co=0;
  cin >> h >> w;
  vector <vector <char>>s(h,vector<char>(w));
  rep(i,h){
    rep(j,w){
           cin >> s.at(i).at(j);
    }
  }

  //cout << 1 << endl;
  rep(i,h){
    rep(j,w-1){
      if(s.at(i).at(j)=='.' && s.at(i).at(j+1)=='.'){
      	co++;
      }
    }
  }
 // cout << 1 << endl;

  rep(i,w){
    rep(j,h-1){
      if(s.at(j).at(i)=='.' && s.at(j+1).at(i)=='.'){
      	co++;
      }
    }
  }
  cout << co << endl;
}

#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>
#include <hash_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace std;

#define     lp(i,a,n)       for(ll i=a;i<n;i++)
#define     lp2(i,n,a)      for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<int,int>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            '\n'
#define     Endl            '\n'
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
#define     ordered_set     tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightX[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightY[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=1e6+1,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1e-9;

void solve(){
    int h,w;
    cin>>h>>w;
    char grid[h][w];
    lp(i,0,h){
        lp(j,0,w)
            cin>>grid[i][j];
    }
    int res=0;
    lp(i,0,h){
        lp(j,0,w){
            if(grid[i][j]!='.')continue;
            lp(k,0,4){
                int ti=i+dx[k],tj=j+dy[k];
                if(ti>=0&&ti<h&&tj>=0&&tj<w&&grid[ti][tj]=='.')
                    res++;
            }
        }
    }
    cout<<res/2<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using ll = long long;
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define ALL(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; i++)

#define INF (int)1e9
#define LLINF (long long)1e12
#define MOD (int)1e9 + 7
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define co cout <<
#define en << endl;
#define __MAGIC__              \
  ios::sync_with_stdio(false); \
  cin.tie(nullptr);

#define YESNO(T)           \
  if (T)                   \
  {                        \
    cout << "YES" << endl; \
  }                        \
  else                     \
  {                        \
    cout << "NO" << endl;  \
  }
#define yesno(T)           \
  if (T)                   \
  {                        \
    cout << "yes" << endl; \
  }                        \
  else                     \
  {                        \
    cout << "no" << endl;  \
  }
#define YesNo(T)           \
  if (T)                   \
  {                        \
    cout << "Yes" << endl; \
  }                        \
  else                     \
  {                        \
    cout << "No" << endl;  \
  }

#define Graph vector<vector<int>>
#define PII pair<int, int>
#define VI vector<int>
#define VL vector<long long>
#define VVI vector<vector<int>>
#define VPII vector<pair<int, int>>
#define VS vector<string>
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define DDD fixed << setprecision(10)

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/

/*.....................DEFINE FUNCTIONS ......................*/
double power(double a, ll n)
{
  double r;
  ll abs_n;

  r = 1;
  abs_n = n < 0 ? -n : n;
  while (abs_n > 0)
  {
    if (abs_n % 2 == 1)
    {
      r *= a;
    }
    a *= a;
    abs_n /= 2;
  }

  return n >= 0 ? r : 1 / r;
}

double nthroot(double a, ll n)
{
  double x, y;

  // if (a <= 0 || n < 0)
  // {
  //   return 0;
  // }
  // if (n == 0)
  // {
  //   return 1;
  // }

  /* a > 0 かつ n > 0 の場合 */
  y = (a > 1) ? a : 1;
  do
  {
    x = y;
    y = ((n - 1) * x + a / power(x, n - 1)) / n;
  } while (y < x);

  return y;
}

ll is_power(ll a)
{
  ll i;

  if (a == 1)
  {
    return 1;
  }

  for (i = 2; i <= floor(log2(a)); i++)
  {
    if (power(floor(nthroot(a, i)), i) == a)
    {
      return 1;
    }
  }

  return 0;
}

/*.........................kemkemG0...........................*/

signed main()
{
  __MAGIC__
  int m, h;
  cin >> m >> h;
  if (h % m == 0)
  {
    co "Yes" en
  }
  else
  {
    co "No" en
  }

  return 0;
}

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

int main(){
    long m, h;
    long A;
    cin >> m >> h;
    A = h % m;
    if(A == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///AtCoder Regular Contest 117
void YESNO(ll a){cout<<(a ? "YES" : "NO")<<"\n";}
int main(void){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    char arr[n];
    ll sum = 0;
    ll b = 1;
    ll num = n-1;
    ll posa[2] = {0};
    ll kato = 1;
    map<char,ll>mp;
    mp['B'] = 0;
    mp['W'] = 1;
    mp['R'] = 2;
    f(i,0,n){
        cin>>arr[i];
        ll bb = b;
        assert(posa[0] >= posa[1]);
        if(posa[0] != posa[1]){
            b = 0;
        }
        if(b < 0){
            b += 3;
        }
        sum += (mp[arr[i]] * b) % 3;
        sum %= 3;
        b = bb;
        ll NUM = num;
        while(NUM % 3 == 0 && NUM != 0){
            posa[0]++;
            NUM /= 3;
        }
        if(NUM % 3 == 2){
            b *= -1;
        }
        NUM = kato;
        while(NUM % 3 == 0 && NUM != 0){
            posa[1]++;
            NUM /= 3;
        }
        if(NUM % 3 == 2){
            b *= -1;
        }
        kato++;
        num--;
    }
    char ans[3] = {'B','W','R'};
    if(n % 2 == 0){
        sum = 3 - sum;
        sum %= 3;
    }
    cout<<ans[sum]<<"\n";
}

#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define ll long long
#define add(a,b) a=((a)+(b))%mod
#define mod 3
#define Mod 1
//#define file
using namespace std;

int n,i,j,k,l;
char st[400001];
int a[400001];
int ans;
ll Jc[3];

ll qpower(ll a,int b) {ll ans=1; while (b) {if (b&1) ans=ans*a%mod;a=a*a%mod;b>>=1;} return ans;}

ll cc(int n,int m)
{
	ll ans=1;
	int i;
	fo(i,1,m) ans=ans*(n-i+1)%mod;
	return ans*Jc[m];
}
ll C(int n,int m)
{
//	int s=1,s2=1;
//	fo(i,1,m) s=s*(n-i+1),s2=s2*i;
//	s/=s2;
//	return s%mod;

	if (n<m) return 0;
	if (m<3) return cc(n,m);
	return C(n/mod,m/mod)*C(n%mod,m%mod)%mod;
}

int turn(char ch)
{
	if (ch=='R') return 0;
	if (ch=='B') return 1;
	if (ch=='W') return 2;
}
char Turn(int t)
{
	if (t==0) return 'R';
	if (t==1) return 'B';
	if (t==2) return 'W';
}

int main()
{
	#ifdef file
	freopen("c.in","r",stdin);
	#endif

	Jc[0]=1;
	fo(i,1,2) Jc[i]=Jc[i-1]*qpower(i,Mod)%mod;
	scanf("%d",&n);
	scanf("%s",st+1);
	fo(i,1,n)
	a[i]=turn(st[i]),add(ans,C(n-1,i-1)*a[i]);
	ans=ans*qpower(2,n-1)%mod;

	ans=(ans+mod)%mod;
	cout<<Turn(ans)<<endl;

	fclose(stdin);
	fclose(stdout);
	return 0;
}


//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int>
#define all(v)          v.begin(),v.end()
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int dp[31][31];
int32_t main()
{
    FIO
    int a,b,c; cin>>a>>b>>c;
    dp[0][0]=1;
    fi(i,31){
        fi(j,31){
            if(i>0 || j>0)
            dp[i][j]=0;
            if(i>0) dp[i][j]+=dp[i-1][j];
            if(j>0) dp[i][j]+=dp[i][j-1];
        }
    }
    int x=a+b;
    while(a>0 && b>0){
        if(c>dp[a-1][b]){
            c=c-dp[a-1][b];
            cout<<'b';
            b--;
        }
        else{
            a--;
            cout<<'a';
        }
    }
    while(a>0) {
        cout<<'a';
        a--;
    }
    while(b>0){
        cout<<'b';
        b--;
    }
    cout<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI acos(-1)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define CY cout << "YES\n"
#define CN cout << "NO\n"
#define print(x) for(auto it:x) cout<<it<<' '; cout<<"\n";

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
ll fpower(ll x,ll y) // without mod
{
	if(!x)
		return x;
	if(!y)
		return 1;
	return (y&1) ? x*fpower(x*x,y>>1) : fpower(x*x,y>>1) ;
}
bool isWin(vector<ll>&arr1,vector<ll>&arr2)
{
	ll s1,s2;
	s1 = s2 = 0;
	ll i;
	f(i,1,10)
	{
		s1 += i*(fpower(10,arr1[i]));
		s2 += i*(fpower(10,arr2[i]));
	}
	if(s1>s2)
		return true;
	return false;
}

int main()
{
	FAST_IO ;
	ll i,j,k,n;
	cin >> k;
	n = k;
	string s,t;
	vector<ll>arr1(10,0),arr2(10,0),available(10,0);
	cin >> s >> t;
	f(i,0,s.size()-1)
		arr1[s[i]-'0']++;
	f(i,0,t.size()-1)
		arr2[t[i]-'0']++;
	for(i=1;i<=9;i++)
		available[i] = k - arr1[i] - arr2[i];
	// print(available);
	ll total = 0;
	ll win = 0;
	for(i=1;i<=9;i++)
	{
		for(j=1;j<=9;j++)
		{
			if(!available[i]||!available[j])
				continue;
			arr1[i]++;
			arr2[j]++;
			if(i==j)
				total += available[i]*(available[j]-1);
			else
				total += available[i]*available[j];
			if(isWin(arr1,arr2))
			{
				if(i==j)
					win += available[i]*(available[j]-1);
				else
					win += available[i]*available[j] ;
			}
			arr1[i]--;
			arr2[j]--;
		}
	}
	// cout << win sp << total endl;
	double ans;
	ans = win/(double)total;
	cout << setprecision(20) << ans endl;
	return 0;
}

/*
If u haven't come up with an approach yet ,skip this one
  Try this when feeling stuck -
  1. Int overflow, array bounds
  2. Special cases (n=1?)
  3. Prove your approach to yourself(mathematical induction,counter-intuitive or stronger test cases)
  4. Calm down and don't look at standings and stop thinking about rating and think about the question
  5. Just do it!
*/

//Benq's advice -
/*
	And following advices are must for me -
	* do something instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

//#define _GLIBCXX_DEBUG
// It will convert WA verdict to runtime error if that error is caused due to out of bound excess , declare it at the top
//#pragma GCC optimize "trapv"
// It will convert WA to runtime error if WA was caused due to int overflow error,declare it anywhere


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll  = vector<vll>;

int main()
{
    int n;
    ll w;
    cin >> n >> w;
    vll need(200000,0ll);
    for (int i = 0; i < n; i++)
    {
        int s,t;
        cin >> s >> t;
        ll p;
        cin >> p;
        need[s] += p;
        need[t] -= p;
    }
    for (int i = 1; i < n; i++)
    {
        need[i] += need[i-1];
    }
    string ans = "Yes";
    for (int i = 0; i < n; i++)
    {
        if (need[i] > w)
        {
            ans = "No";
        }
    }
    cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define int long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
#define N 400005
int s[N],t[N],w[N],n,m,r[N];
int sum[N];
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) s[i]=read(),t[i]=read(),w[i]=read();
	int cnt=0;
	for(int i=1;i<=n;i++) r[++cnt]=s[i],r[++cnt]=t[i];
	sort(r+1,r+cnt+1); int Q=unique(r+1,r+cnt+1)-r-1;
	for(int i=1;i<=n;i++) s[i]=lower_bound(r+1,r+Q+1,s[i])-r;
	for(int i=1;i<=n;i++) t[i]=lower_bound(r+1,r+Q+1,t[i])-r;
	for(int i=1;i<=n;i++) sum[s[i]]+=w[i],sum[t[i]]-=w[i];
	int maxn=0;
	for(int i=1;i<=Q;i++) sum[i]+=sum[i-1];
	for(int i=1;i<=Q;i++) maxn=max(maxn,sum[i]);
	if(maxn<=m) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


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

int main() {
  ll n, s, d;
  cin >> n >> s >> d;

  using pll = pair<ll, ll>;
  vector<pll> xy(n);
  for (int i = 0; i < n; i++) {
    cin >> xy.at(i).first >> xy.at(i).second;
  }

  bool judge = false;
  for (int i = 0; i < n; i++) {
    if (xy.at(i).first < s && xy.at(i).second > d) {
      judge = true;
      break;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
int main() {
	int n;int mn=INT_MAX;
	cin>>n;
	for (int i=0;i<n;i++){
		int a,p,x;
		cin>>a>>p>>x;
		//cout<<x<<" "<<a<<"\n";
		if (x-a>0)mn=min(p,mn);
	}
	if (mn!=INT_MAX)cout<<mn<<"\n";
	else cout<<"-1\n";
	return 0;
}


#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

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

int GCD(int x,int y){
  if(x<y){
    swap(x,y);
  }
  while(x%y!=0){
    int temp=x;
    x=y;
    y=temp%y;
  }
  return y;
}

int digitsum(int x){
  int sum=0;
  while(x>0){
    sum+=(x%10);
    x/=10;
  }
  return sum;
}

int main() {
  int t;
  cin>>t;
  for(int I=0;I<t;I++){
    string s;
    cin>>s;
    string temp=s;
    sort(temp.begin(),temp.end());
    reverse(temp.begin(),temp.end());
    if(temp<="atcoder"){
      cout<<-1<<endl;
      continue;
    }
    string b="atcoder";
    if(b<s){
      cout<<0<<endl;
      continue;
    }
    for(int i=0;i<s.size();i++){
      if(s[i]!='a'){
        if(s[i]<='t'){
          cout<<i<<endl;
        }
        else{
          cout<<i-1<<endl;
        }
        break;
      }
    }
  }
  return 0;
}

#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long
#define l long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define pf pop.front()
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " = " << x << endl;
#define lcm(a,b) a*b/__gcd(a,b)

using namespace std;
string s = "atcoder";

int solve()
{

string s1;
cin>>s1;

bool tr = false;
int n = s1.length();
int ans = 0;

for(int i=0;i<n;i++){
	if(s1[i]!= 'a')
	{
		tr = true;
	}
}

if(!tr )
return -1;

if(s < s1)
return 0;
int i;
for( i=0;i<n;i++){
	if(s1[i] != 'a')
	{
		break;
	}
}
if(s1[i] > 't')
		return i-1;

		return i;
}

int32_t main()
{
FAST
l T=1;
cin>>T;
while(T--)
{
cout<<solve()<<endl;
}
}


    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P=pair<ll,ll>;
    const int INF=1001001001;
    const int mod=1e9+7;

    void solve(){
      ll t,n;
      cin>>t>>n;
      int p=100+t;
      set<ll>st;
      rep(i,100){st.insert(p*i/100);}
      vector<ll>b;
      rep(i,p*100/100){
        if(!st.count(i)){
          b.push_back(i);
        }
      }
      ll sz=b.size();
      ll x=(n-1)/sz,y=(n-1)%sz;
      ll ans=p*x+b[y];
      cout<<ans<<endl;
    }
    int main(){
      solve();
      return 0;
    }

#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	int k[1001] = {};
	cin >> n;
	int ans, m, b;
	ans = m = b = 0;
	int aa = 0;
	for (int i = 1;i <= n;i++) {
		int a; cin >> a;
		aa = max(aa, a);
		int j = 2;
		while (1) {
			if (a%j == 0) {
				m = j, k[j]++;
				if (a / j == 1) break;
			}
			j++;
		}
		ans = max(ans, m);
	}
	int c = 0;
	for (int i = 2;i <= 1000;i++) {
		if (c <k[i])c = k[i], ans = i;
	}
	cout << ans << endl;
	return 0;
}


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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n;
	string s;
	cin >> s;
	vector <ll> dp (9*s.size()+2, -INF);
	for (i = 0; i < 1LL<<s.size(); ++i)
	{
		int cs = 0, ca = 0;
		for (j = 0; j < s.size (); ++j)
			cs += (i>>j&1)*(s[j] - '0'),
			ca += (i>>j&1);
		dp[cs] = ca;
	}
	ll ans = -1;
	for (i = 0; i < dp.size (); i += 3)
		ans = max (ans, dp[i]);
	if (ans == 0) cout << -1 << '\n';
	else cout << s.size () - ans << '\n';

	return 0;
}

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

int main() {

  string N;
  cin >> N;

  int l = N.size();

  int zero = 0, one = 0, two = 0;
  for (int i = 0; i < l; i++) {
    if (N[i]%3 == 1) one++;
    else if (N[i]%3 == 2) two++;
    else zero++;
  }

  if (one == 0 && two == 0) cout << 0 << endl;
  else if (zero == 0 && one <= 2 && two == 0) cout << -1 << endl;
  else if (two == 0) cout << one%3 << endl;
  else if (zero == 0 && one == 0 && two <= 2) cout << -1 << endl;
  else if (one == 0) cout << two%3 << endl;
  else if ((one-two)%3 == 0) cout << 0 << endl;
  else cout << 1 << endl;

return 0;
}


//REST IN THE END NOT IN THE MIDDLE
//CODE STARTS FROM HERE.
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    if(floor(1.08*n)<206){
        cout<<"Yay!";
    }
    if(floor(1.08*n)==206){
        cout<<"so-so";
    }
    if(floor(1.08*n) > 206){
        cout<<":(";
    }
return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+10;
const double eps = 0.01;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
inline ll pt(ll ans,ll f){
    printf("%lld",ans);
    if(f==1) putchar(' ');
    else putchar('\n');
}
ll n,k,m,tot;
ll a[N],c[N],vis[N];
int main()
{
//    freopen("../in.in","r",stdin);
    ll _;
    char ch[10];
    for(int i=0;i<3;i++){
        ch[i]=getchar();
    }
    putchar(ch[1]);
    putchar(ch[2]);
    putchar(ch[0]);
    putchar('\n');
    return 0;
}


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

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

#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 clr0(a) memset(a, 0, sizeof(a))

void solve() {
    char a[1010];
    cin >> a;
    ll n = strlen(a);
    bool ans = true;
    for0(i, n) {
        if (i%2==0) {
            if (a[i]<97 || a[i]>122) {
                ans = false;
                break;
            }
        }
        else {
            if (a[i]<65 || a[i]>90) {
                ans = false;
                break;
            }
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

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

    //testcase();
    solve();

    return 0;
}

#include <stdio.h>
int main()
{
	int i, j, N, A[100] = {}; //入力しないところ１にしておく
	int k, GCD, maxGCD = 0, ans = 0;

	scanf("%d", &N);//これの存在忘れてた。もっと簡単にできた

	for (i = 1; i <= N; i++) {
		scanf("%d", &A[i]);
	}

	for (k = 2; k <= 1000; k++) {  //ここたぶんあほ

		GCD = 0; //GCD reset
		for (j = 1; j <= N; j++) {

			if (A[j] % k == 0) { //もし割り切れたら
				GCD = GCD + 1; //GCD度
			}

		}
		if (maxGCD < GCD) {
			maxGCD = GCD;
			ans = k; //そのときのk
		}
	}
	printf("%d", ans);
	return(0);
}

//問題点　kの扱い　二重ループにしたらタイムアウトするに違いない
//二重ループで書いてみる


// Rishabh Singhal
#include<bits/stdc++.h>
#define w(x)            int x; cin>>x; for(int tc=1;tc<=x;tc++)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back
#define endl "\n"
#define mod 1000000007
#define f first
#define s second
#define inf 1e18

using namespace std;
bool cmp(vector<int>a, vector<int>b) {
	if (a[1] == b[1]) {
		return a[2] < b[2];
	} else
		return a[1] < b[1];
}
void solve(int tc) {
	int n;
	cin >> n;
	vector<vector<int>>vec;
	int a, b, c;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c;
		vec.push_back({a, b, c});
	}
	sort(vec.begin(), vec.end(), cmp);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int type = vec[i][0];
		int x = vec[i][1];
		int y = vec[i][2];
		for (int j = i + 1; j < n; j++) {
			if (type == 1 or type == 3) {
				if (vec[j][1] > y) {

				} else if (vec[j][1] == y) {
					if (vec[j][0] == 1 or vec[j][0] == 2) {
						ans++;
					}
				} else {
					ans++;
				}
			} else {
				if (vec[j][1] < y) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

int32_t main() {
	FIO
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	// w(x) {
	solve(1);
// }
	return 0;
}

//mistakes
// debug fast don't be lazy
// always check for n = 1 condition
// clear the graph -- check index 1 based or 0 based
// set vis to 0
// check constraints of graph question
// use map and set wherever need

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<double,double> pdd;
#define forn(i,x,n) for(int i = x;i <= n;++i)
#define forr(i,x,n) for(int i = n;i >= x;--i)
#define Angel_Dust ios::sync_with_stdio(0);cin.tie(0)
#define x first
#define y second

const int N = 2005;
pdd a[N];

int main()
{
    int n;scanf("%d",&n);
    forn(i,1,n)
    {
        int t,l,r;scanf("%d%d%d",&t,&l,&r);
        a[i] = {l,r};
        if(t == 2)  a[i].y -= 0.1;
        if(t == 3)  a[i].x += 0.1;
        if(t == 4)  a[i].x += 0.1,a[i].y -= 0.1;
    }

    int res = 0;
    forn(i,1,n) forn(j,i + 1,n)
    {
        if(min(a[i].y,a[j].y) < max(a[i].x,a[j].x)) continue;
        ++res;
    }
    printf("%d\n",res);

    return 0;
}


// Problem: B - Hydrate
// Contest: AtCoder - AtCoder Beginner Contest 207
// URL: https://atcoder.jp/contests/abc207/tasks/abc207_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

//The code written by Javokhir Akramjonov

#include <bits/stdc++.h>

using namespace std;

//#define file
#define int long long
#define ff first
#define ss second
#define N 111111
#define pb push_back
#define eb emplace__back
#define pii pair<int, int>
#define vi vector<int>
#define rep(i, a, b) for(int i = a; i < b; i ++)
#define trav(x, a) for(auto &x : a)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int M = 1e9 + 7;

void solution()
{
    /*a + bx <= dcx
    x >= a / (dc-b);*/
    int a, b, c, d;
    cin >> a >> b >> c >> d;
	if(d * c > b)
	{
		if(a % (d * c - b) == 0)
			cout << a / (d * c - b);
		else
			cout << a / (d * c - b) + 1;
	}
	else if(d * c == b)
	{
		if(a > 0)
			cout << -1;
		else
			cout << 0;
	}
	else
	{
		if(a == 0)
			cout << 0;
		else
			cout << -1;
	}
}

signed main()
{
	#ifdef file
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
    ios;
    int t = 1;
	//cin >> t;
    while(t--)
        solution();
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define Bs binary_search
#define In insert
#define Mp make_pair
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second

const int mx1 = 65;
const int mx2 = 205;
const int mx3 = 2005;
const int mx4 = 30005;
const int mx5 = 100005;
const int mx6 = 1000005;

typedef vector<int> Vi;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vi> VVi;
typedef pair<int, int> Pii;
typedef pair<DD, DD> Pdd;
typedef vector<Pii> Vpi;
typedef vector<Pdd> Vpd;
typedef queue<int> Qi;
typedef stack<int> Si;
typedef deque<int> Di;

int _toggle(int N, int pos) {return N = N ^ (1 << pos);}
int _set(int N, int pos) {return N = N | (1 << pos);}
int _reset(int N, int pos) {return N = N & ~(1 << pos);}
bool _check(int N, int pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///******************************************************///

int n;
string s, t;
set<int> st;

void solve()
{
    cin >> n >> s >> t;
    for(int i = 0; i < n; i++){
        if(s[i] == '1'){
            st.In(i);
        }
    }
    LL ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '1' && t[i] == '0'){
            st.erase(i);
            auto j = st.Lb(i);
            if(j == st.end()){
                cout << -1 << '\n';
                return;
            }
            ans += (*j - i);
            s[*j] = '0';
            st.erase(j);
        }
        if(s[i] == '0' && t[i] == '1'){
            auto j = st.Lb(i);
            if(j == st.end()){
                cout << -1 << '\n';
                return;
            }
            ans += (*j - i);
            s[*j] = '0';
            st.erase(j);
        }
    }
    cout << ans << '\n';
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    int tc = 1;
    //cin >> tc;
    while(tc--){
        solve();
    }
}


#include <bits/stdc++.h>

long long extGCD(long long a, long long b, long long c, long long &x, long long &y){
    long long a_gcd = a;
    long long b_gcd = b;
    std::vector< long long > A, B;
    A.push_back(a_gcd);
    B.push_back(b_gcd);

    while(b_gcd != 0){
        long long tmp = a_gcd % b_gcd;
        a_gcd = b_gcd;
        b_gcd = tmp;
        A.push_back(a_gcd);
        B.push_back(b_gcd);
    }

    if(c % a_gcd != 0){
        x = -1e18;
        y = -1e18;
        return -1;
    }

    std::vector< long long > X(A.size()), Y(A.size());
    X[A.size() - 1] = c / a_gcd;
    Y[A.size() - 1] = 0;
    for(int i=A.size()-2; i>=0; i--){
        X[i] = Y[i+1];
        Y[i] = X[i+1] - (A[i] / B[i]) * X[i];
    }

    x = X[0];
    y = Y[0];

    b /= a_gcd;

    if(x >= 0){
        return x % b;
    }else{
        long long ret;
        ret = b - std::abs(x) % b;
        if(ret == b){
            ret = 0;
        }
        return ret;
    }

}

int main(){
    int T;
    std::cin >> T;
    std::vector< long long > ans(T);

    for(int t=0; t<T; t++){
        long long X, Y, P, Q;
        std::cin >> X >> Y >> P >> Q;

        long long min = 9223372036854775807;
        for(int p=P; p<P+Q; p++){
            for(int x=X; x<X+Y; x++){
                long long ret1, ret2;
                long long tmp = extGCD(P+Q, 2*(X+Y), x-p, ret1, ret2);
                if(tmp != -1){
                    min = std::min(min, p + (P+Q) * tmp);
                }
            }
        }

        ans[t] = min;

    }

    for(int i=0; i<T; i++){
        if(ans[i] == 9223372036854775807){
            std::cout << "infinity" << std::endl;
        }else{
            std::cout << ans[i] << std::endl;
        }
    }

    return 0;

}

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

using namespace std;

using ll = int64_t;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

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

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

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

#if 1

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll extGCD(ll a, ll b, pll& out) {
  ll l = a, r = b;
  ll la = 1, lb = 0, ra = 0, rb = 1;

  while (true) {

    // l / r = c ... d
    ll c = l / r, d = l - r * c;

    if (!d) {
      out = { ra,rb };
      return r;
    }

    la = la - ra * c;
    lb = lb - rb * c;
    swap(la, ra);
    swap(lb, rb);
    l = r; r = d;
  }
}

ll mod(ll a, ll b) {
  a %= b;
  if (a < 0) a += b;
  return a;
}

ll solve() {
  ll X, Y, P, Q;
  cin >> X >> Y >> P >> Q;

  /*
  i = [0,Y)
  j = [0,Q)
  2(X+Y)a+X + i == (P+Q)b+P + j

  (P+Q)b + P+j == X+i mod 2(X+Y)
  (P+Q)b == X+i-P-j mod 2(X+Y)

  */

  ll a = 2 * (X + Y), c = (P + Q);

  pll out;
  ll g = extGCD(a, c, out);
  //show(g);
  //show(out);
  a /= g; c /= g;
  // mod a における c の逆数
  ll e = out.second;
  if (e < 0) e = (-e * (a - 1)) % a;
  //cout << "1 / " << c << " = " << e << " mod " << a << newl;

  ll re = INT64_MAX;
  F0R(i, Y) {
    F0R(j, Q) {
      ll f = X + i - P - j, b;
      if (!f) b = 0;
      else if (f % g) continue;
      else {
        f /= g;
        if (f < 0) f += (-f+a-1)/a*a; // -f//a*a
        b = (f * e) % a;
      }
      chmin(re, (c * b)*g + P + j);
    }
  }

  return re >= INT64_MAX ? -1 : re;
}

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

  int T; cin >> T;
  F0R(i, T) {
    auto re = solve();
    if (re < 0) {
      cout << "infinity";
    }
    else {
      cout << re;
    }
    cout << newl;
  }
}
#endif


//Code by Ritik Agarwal
    #include<bits/stdc++.h>
    using namespace std;
    #define sz(x) (int)(x).size()
    #define int long long int
    #define loop(i,a,b) for(int i=a;i<b;i++)
    #define scan(arr,n) for (int i = 0; i < n; ++i) cin >> arr[i]
    #define vi vector<int>
    #define si set<int>
    #define pii pair <int, int>
    #define sii set<pii>
    #define vii vector<pii>
    #define mii map <int, int>
    #define pb push_back
    #define ff first
    #define ss second
    #define all(aa) aa.begin(), aa.end()
    #define rall(a) a.rbegin() , a.rend()
    #define read(a,b) int a,b;  cin>>a>>b
    #define readt(a,b,c) int a,b,c; cin>>a>>b>>c
    #define readf(a,b,c,d) int a,b,c,d; cin>>a>>b>>c>>d;
    #define print(v) for(auto x:v) cout<<x<<" ";cout<<endl
    #define printPair(res) for(pair<int,int>& p:res) cout<<p.first<<" "<<p.second<<endl;
    #define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    //*****  Constants  *****
    const int mod = 1000000007; /* 1e9 + 7*/
    const int MAXN = 1000005; /*1e6 +5 */
    const int mod1= 998244353;
     int vis[MAXN]={0};
    int fac[300001];
    void fact(int m){fac[0]=1;for(int i=1;i<=300000;i++) fac[i]=(fac[i-1]%m * i%m)%m;}
    /* Iterative Function to calculate (x^y)%p in O(log y)*/
     long long power( long long x,  int y, int p){   long long res = 1;
     x = x % p; while (y > 0) { if (y & 1)  res = (res * x) % p;  y = y >> 1; x = (x * x) % p;} return res;}
    // Returns n^(-1) mod p
     long long modInverse( long long n, int p) {  return power(n, p - 2, p); }
     long long nCr( long long n,int r, int p) { if (r == 0) return 1; if(n<r) return 0;
      return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; }

     int binarySearch(vi arr, int l, int r, int x) {
       if (r >= l) { int mid = l + (r - l) / 2; if (arr[mid] == x) return mid;
       if (arr[mid] > x)  return binarySearch(arr, l, mid - 1, x);
       return binarySearch(arr, mid + 1, r, x); } return -1; }

    const int NAX=3E5+5;
    int BIT[NAX];
    int getSum( int index)
    {
        int sum=0;
        while(index>0)
        {
            sum+=BIT[index];
            index -=index & (-index);
        }
        return sum;
    }

    void update(int  n , int index , int val)
    {
        while(index<=n)
        {
            BIT[index]+=val;
            index += index & (-index);
        }
    }

    void convert(int arr[], int n)
{
    // Create a copy of arrp[] in temp and sort the temp array
    // in increasing order
    int temp[n];
    for (int i=0; i<n; i++)
        temp[i] = arr[i];
    sort(temp, temp+n);

    // Traverse all array elements
    for (int i=0; i<n; i++)
    {
        // lower_bound() Returns pointer to the first element
        // greater than or equal to arr[i]
        arr[i] = lower_bound(temp, temp+n, arr[i]) - temp + 1;
    }
}

    void solve(int test)
    {
        int n;cin>>n;
        vi arr(n);
        scan(arr,n);
        sort(all(arr));
        if(n&1) cout<<"Second\n";
        else
        {
            int f=0;
            for(int i=-0;i<n;i+=2)
            {
                if(arr[i]!=arr[i+1])
                    f=1;
            }
            if(f==1)
                cout<<"First\n";
            else
                cout<<"Second\n";
        }
    }

    int32_t main()
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        #endif
        faster;//fact(mod1);
        int t=1;
        cin>>t;
        for(int test=1;test<=t;test++)
        {
            solve(test);
        }
    }

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

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

void solve() {
    ll n;
    cin >> n;
    vec<ll> a(n);
    map<ll, ll> mp;
    REP(i, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    if(n % 2) {
        cout << "Second" << en;
    } else {
        bool flag = true;
        for(auto i : mp) {
            if(i.second % 2)
                flag = false;
        }
        if(flag)
            cout << "Second" << en;
        else
            cout << "First" << en;
    }
}

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

    ll t;
    cin >> t;
    while(t--)
        solve();

    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define INF 3000000000000001 // 3e15
#define ll_max 9000000000000000000
#define PI 3.14159265358979323846L
#define fill(a, n, x) for(int i = 0; i < n; i++) a[i] = x;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll N = 200011;
const ll M = log2(N) + 1;

struct point
{
    ll x, y;
};

template<typename T>
T fast_exp(T x,T n)
{
    if(n == 0) return 1;
    T ans = 1;
    if( n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans % mod;
    }
    else ans = fast_exp(x, n - 1) * x % mod;
    return ans;
}

ll fact[N], infac[N];
void work()
{
    fact[0] = 1;
    infac[0] = 1;
    for(ll i = 1; i < N; i++)
    {
        fact[i] = fact[i - 1] * i % mod;
        infac[i] = fast_exp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return fact[n] * infac[n - r] % mod * infac[r] % mod;
}

ll depth[N], anc[N][M];
set<ll> val[N][M];
void dfs(vector<int> tree[], vector<ll> lab[], int x, int p, int d = 0)
{
    depth[x] = d;
    if(lab[p].size() > 0)
    {
        for(auto i:lab[p]) val[x][0].insert(i);
    }
    if(lab[x].size() > 0)
    {
        for(auto i:lab[x]) val[x][0].insert(i);
    }
    anc[x][0] = p;
    for(int i = 1; i < M; i++)
    {
        anc[x][i] = anc[anc[x][i - 1]][i - 1];
        set<ll> &v1 = val[x][i - 1];
        set<ll> &v2 = val[anc[x][i - 1]][i - 1];
        for(auto j:v1)  val[x][i].insert(j);
        for(auto j:v2)  val[x][i].insert(j);
        while(val[x][i].size() > 10)
            val[x][i].erase(val[x][i].begin());
    }
    for(auto i:tree[x])
    {
        if(i != p)
            dfs(tree, lab, i, x, d + 1);
    }
}

set<ll> LCA(ll l, ll r, ll g)
{
    set<ll> s;
    if(depth[l] != depth[r])
    {
        if(depth[l] > depth[r])
        swap(l, r);
        ll x = depth[r] - depth[l];
        for(int i = M - 1; i > -1; i--)
        {
            if(x & (1ll << i)) {
                for(auto j:val[r][i]) s.insert(j);
                r = anc[r][i];
            }
        }
    }
    if(l == r) return s;
    for(int i = M - 1; i > -1; i--)
    {
        if(anc[l][i] != anc[r][i])
        {
            for(auto j:val[r][i]) s.insert(j);
            for(auto j:val[l][i]) s.insert(j);
            l = anc[l][i];
            r = anc[r][i];
        }
    }
    for(auto j:val[l][0]) s.insert(j);
    while(s.size() > g)
            s.erase(s.begin());
    return s;
}

bool solve(vector<int> tree[], ll x, ll p, ll tar, vector<ll> lab[], set<ll> &s)
{
    bool ans = 0;
    if(x == tar)
        ans = 1;
    for(auto i:tree[x])
    {
        if(i != p)
        {
            ans = ans | solve(tree, i, x, tar, lab, s);
        }
    }
    if(ans)
    {
        for(auto i:lab[x]) s.insert(i);
    }
    return ans;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    int test = 0;
    while(_--)
    {
        test++;
        ll n, m, x, y, ans = 0, k;
        cin >> n >> m;
        ll a[n + 1], b[m + 1];
        for(int i = 1; i <= n; i++) cin >> a[i];
        for(int i = 1; i <= m; i++) cin >> b[i];
        ll dp[n + 1][m + 1];
        for(int i = 0; i <= n; i++)
        {
            for(int j = 0; j <= m; j++)
                dp[i][j] = i + j - min(i, j);
        }
        dp[0][0] = 0;
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= m; j++)
            {
                if(a[i] == b[j]) dp[i][j] = dp[i - 1][j - 1];
                dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + 1);
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
            }
        }
        cout << dp[n][m] << "\n";
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
#define mkunique(a) a.resize(unique(a.begin(),a.end())-a.begin());
const ll mod=1e9+7;

const int N=1010;
ll dp[N][N], n, m;
vector<ll> a,b;

ll go(ll l, ll r){
    if(l==n)
        return m-r;
    if(r==m)
        return n-l;
    if(dp[l][r]!=-1)
        return dp[l][r];
    ll ans=mod;
    if(a[l]==b[r])
        ans=min(ans,go(l+1,r+1));
    else
        ans=min(ans,1+go(l+1,r+1));
    ans=min(ans,1+go(l+1,r));
    ans=min(ans,1+go(l,r+1));
    //cout<<l<<" "<<r<<" "<<ans<<"\n";
    return dp[l][r]=ans;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    cin>>n>>m;
    a.assign(n,0);
    b.assign(m,0);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll i=0;i<m;i++)
        cin>>b[i];
    memset(dp,-1,sizeof(dp));
    cout<<go(0,0);

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}


//There are no beautiful surface without a terrible depth

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[1002],b[1002];
int main(){
      ll n,m,t,f=0,charge=0;
      cin>>n>>m>>t;

      charge=n;
      forn(i,m){
            cin>>a[i]>>b[i];
      }
      charge-=(a[0]);
      forn(i,m){
            if(charge<=0){
                  f=1;
                  break;
            }
            charge+=(b[i]-a[i]);
            charge=min(charge,n);
            if(i!=m-1) charge-=(a[i+1]-b[i]);
            else charge-=(t-b[i]);
            if(charge<=0){
                  f=1;
                  break;
            }
            //cout<<charge<<" ";
      }
      if(f==0)cout<<"Yes";
      else cout<<"No";
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define n_l '\n'
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef double db;
typedef vector<vi> vvi;
const ll mod=1000000007;
const ll N=200005; //check this
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powb(ll a,ll b) {ll res=1;a ; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

bool cmp(pair<ll,ll> a, pair<ll,ll> b){
	return (a.fi)*2 + a.se > (b.fi)*2 + b.se;

}

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

    int t=1;
    // cin>>t;
    while(t--){
    	int n;cin >> n;
    	vector<pair<ll,ll>> a(n);
    	forn(i,n)cin >> a[i].fi >> a[i].se;
    	sort(all(a),cmp);
    	vector<ll> suf(n+2,0);
    	for(int i = n-1;i>=0;i--){
    		suf[i] = suf[i+1] + a[i].fi;
    	}
    	int ans = n;
    	ll sum = 0;
    	for(int i = 0;i < n; i++){
    		sum += a[i].fi + a[i].se;
    		if(sum > suf[i+1]){
    			ans = i + 1;
    			break;
    		}
    	}
    	cout << ans;
    }
}


#include <cmath>
#include <iostream>

using namespace std;
using ll = long long;

int main (int argc, char* argv[]) {
  ll s, p;
  cin >> s >> p;

  auto flag = false;

  for (auto i = 1; i < sqrt (p + 1); i++) {
    auto j = p / i;
    if (i * j != p) continue;
    if (i + j == s) {
      flag = true;
      break;
    }
  }

  cout << (flag ? "Yes" : "No") << endl;

  return 0;
}

/**
 * author: BueVonHun 🐼🎋
 * More Info: https://github.com/Bue-von-hon
**/

#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>
#include <tuple>
#include <set>
#include <map>
#include <bitset>
#include <sstream>

typedef long long ll;
using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'
#define mp make_pair
#define pii pair<int,int>
#define piii pair<int,pii>
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define X first
#define Y second

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

template <class T> T _min(T a,T b){return (a<b ? a : b);}
template <class T> T _max(T a,T b){return (a>b ? a : b);}
template<class T> void read(T& x) {cin >> x;}
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a / GCD(a, b) * b; }

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
//#define XOX;
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
int INF = numeric_limits<int>::max();
int mod=1e9+7;

inline ll power(ll a, ll n) {
    if (n==1) return a;
    if (n==0) return 1;
    ll ret=1;
    if (n%2!=0) ret=(ret*a)%mod;
    ll tmp = power(a, n/2);
    ll tmp2 = tmp*tmp%mod;
    return (ret*tmp2)%mod;
}
inline int MOD(long long n){
    if(n >= 0) return n % mod;
    return ((-n/mod+1)*mod + n) % mod; // 음수일 경우
}
vt<int> A, B;
int main(void) {
    fast_cin();
    int n;read(n);

    rep(i, n) {
        int tmp;read(tmp);
        A.pb(tmp);
    }
    rep(i, n) {
        int tmp;read(tmp);
        B.pb(tmp);
    }
    ll ans = 0;
    rep(i, n) {
        ans += A[i]*B[i];
    }
    if (ans==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
int a[103];
int f[103][103];
signed main()
{
	int n=read(),x=read();
	int M=0;
	for(int i=1; i<=n; i++) a[i]=read(),M=max(M,a[i]);
	int ans=x-M;
	for(int i=2; i<=n; i++)
	{
		//use i elements
		int t=x%i;
		//the goal
		memset(f,-1,sizeof(f));
		f[0][0]=0;
		for(int j=1; j<=n; j++)
		{
			int g=a[j]%i;
			for(int A=j; A>=1; A--)
			for(int k=0; k<i; k++) if(f[A-1][k]!=-1)
			{
				f[A][(k+g)%i]=max(f[A][(k+g)%i],f[A-1][k]+a[j]);
			}
		}
		if(f[i][t]!=-1) ans=min(ans,(x-f[i][t])/i);
	}
	printf("%lld\n",ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef pair<int, int> pii;
#define ll long long
#define ar array
const int mxN=1e5+1;
const int mod=1e9+7;
const ll INF=1e18;
#define what_is(x) cerr << #x << " is " << x << endl;
vector<int> adj[mxN];
ll dp[(1<<18)][18];
ll d[19][mxN];
ll c[19];
int n,m;
void bfs(int cur,int src){
	for(int i=0;i<=n;i++){
		d[cur][i]=INF;
	}
	d[cur][src]=0;
	queue<int> q;
	q.push(src);
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int v:adj[u]){
			if(d[cur][v] == INF){
				d[cur][v]=d[cur][u]+1;
				q.push(v);
			}
		}
	}
}
void solve(){

	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;--x,--y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int k; cin>>k;
	for(int i=0;i<k;i++){
		cin>>c[i]; c[i]--;
		bfs(i,c[i]);
	}

	for(int mask=1;mask<(1<<k);mask++){
		// initialize mask
		if(__builtin_popcount(mask)==1){
			for(int i=0;i<k;i++){
				if((1<<i)&mask){
					dp[mask][i]=1;
				}else{
					dp[mask][i]=INF;
				}
			}
			continue;
		}

		for(int i=0;i<k;i++){
			// i is my left edge which I want to add
			dp[mask][i]=INF;
			if(mask&(1<<i)){
				// pick all other active bit in mask except i  (mask^(1<<i))
				for(int j=0;j<k;j++){
					if((1<<j)&(mask^(1<<i))){
						dp[mask][i]=min(dp[mask][i],dp[mask^(1<<i)][j]+d[i][c[j]]);
					}
				}
			}
		}
	}

	ll ans=INF;
	for(int i=0;i<k;i++){
		ans=min(ans,dp[(1<<k)-1][i]);
	}
	if(ans==INF){
		ans=-1;
	}
	cout<<ans<<endl;

}

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

    int t=1;
    // cin>>t;
    while(t--)
    	solve();
	return 0;

}


#include <bits/stdc++.h>

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

constexpr int MAX_V = 130000;

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

  int n, k, m;
  cin >> n >> k >> m;

  auto dp = Make2DVector<int>(n, MAX_V + 1, 0);
  dp[0][0] = 1;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= MAX_V; j++) {
      if (dp[i - 1][j] == 0) continue;
      for (int l = 0; l <= k; l++) {
        if (j + i * l > MAX_V) break;
        dp[i][j + i * l] += dp[i - 1][j];
        if (dp[i][j + i * l] >= m) {
          dp[i][j + i * l] -= m;
        }
      }
    }
  }

  for (int x = 1; x <= n; x++) {
    int a = n - x;
    int b = x - 1;
    int64 ans = 0;
    for (int v = 0; v <= MAX_V; v++) {
      ans += static_cast<int64>(dp[a][v]) * static_cast<int64>(dp[b][v]);
      ans %= m;
    }
    ans *= k + 1;
    // ans -= 1;
    ans += m - 1;
    ans %= m;
    cout << ans << endl;
  }
}

//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,k,m,ans[105],f[240005],a[105];
int main(){
	srand(time(0));
	scanf("%d%d%d",&n,&k,&m);
	for(int i=1;i*2-1<=n;++i){
		memset(f,0,sizeof(f));
		f[120000]=1;
		for(int j=1;j<=n;++j)a[j]=j-i;
		random_shuffle(a+1,a+n+1);
		for(int j=1;j<=n;++j){
			int t=a[j];
			if(!t) continue;
			if(t>0){
				int T=t*k;
				for(int s=230000;s>230000-t;--s){
					int o=0;
					for(int I=0;I<k;++I){
						o+=f[s-I*t];
						if(o>=m)o-=m;
					}
					for(int q=s;q>=10000;q-=t){
						o+=f[q-T]-f[q];
						if(o<0)o+=m;
						else if(o>=m)o-=m;
						f[q]+=o;
						if(f[q]>=m)f[q]-=m;
					}
				}
			}
			else{
				t=-t;
				int T=t*k;
				for(int s=10000;s<10000+t;++s){
					int o=0;
					for(int I=0;I<k;++I){
						o+=f[s+I*t];
						if(o>=m)o-=m;
					}
					for(int q=s;q<=230000;q+=t){
						o+=f[q+T]-f[q];
						if(o<0)o+=m;
						else if(o>=m)o-=m;
						f[q]+=o;
						if(f[q]>=m)f[q]-=m;
					}
				}
			}
		}
		ans[i]=ans[n+1-i]=(f[120000]*1ll*(k+1ll)-1ll)%m;
	}
	for(int i=1;i<=n;++i)printf("%d\n",ans[i]);
    return 0;
}


#include <vector>
#include <array>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;

    vector<pair<int,int>> S(n);
    vector<pair<int,int>> T(n);

    for (int i = 0; i < n; ++i) {
        cin >> S[i].first >> S[i].second;
    }
    for (int i = 0; i < n; ++i) {
        cin >> T[i].first >> T[i].second;
    }

    auto dis2 = [&](const pair<int,int>& P) {
        long long x = P.first, y = P.second;
        return x * x + y * y;
    };

    auto dis = [&](const pair<int,int>& A, const pair<int,int>& B) {
        long long x = A.first - B.first;
        long long y = A.second - B.second;
        return x * x + y * y;
    };

    auto crossProduct = [&](pair<int,int>& A, pair<int,int>& B) {
        return A.first * B.second - A.second * B.first;
    };

    auto cmp = [&](const pair<int,int>& l, const pair<int,int>& r) {
        auto L = atan2(l.second, l.first);
        auto R = atan2(r.second, r.first);
        if (L == R) {
            return dis2(l) < dis2(r);
        } else {
            return L < R;
        }
    };
    auto build = [&](int s, vector<pair<int,int>>& P) {
        int n = P.size();
        vector<pair<int,int>> res;
        for (int i = 0; i < n; ++i) {
            if (i == s) {
                continue;
            }
            int x = P[i].first - P[s].first;
            int y = P[i].second - P[s].second;
            res.emplace_back(x, y);
        }
        sort(res.begin(), res.end(), cmp);
        return res;
    };

    auto check = [&](vector<pair<int,int>>& A, vector<pair<int,int>>& B) {
        int n = A.size();
        if (n == 0) {
            return true;
        }
        for (int i = 0; i < n; ++i) {
            if (dis2(A[0]) != dis2(B[i])) {
                continue;
            }
            bool ok = true;
            for (int j = 1; j < n; ++j) {
                int k = (i + j) % n;
                if (dis2(A[j]) != dis2(B[k])) {
                    ok = false;
                }
                if (dis(A[j], A[0]) != dis(B[k], B[i])) {
                    ok = false;
                }
                if (crossProduct(A[j], A[0]) != crossProduct(B[k], B[i])) {
                    ok = false;
                }
                if (!ok) {
                    break;
                }
            }
            if (ok) {
                // for (auto& p : A) {
                //     cout << p.first << ',' << p.second << endl;
                // }
                // cout << i << " " << endl;
                // for (auto& p : B) {
                //     cout << p.first << "," << p.second << endl;
                // }
                // cout << "-----" <<endl;
                return true;
            }
        }
        return false;
    };

    bool res = false;
    for (int i = 0; i < n; ++i) {
        auto A = build(i, S);
        for (int j = 0; j < n; ++j) {
            auto B = build(j, T);
            if (check(A, B)) {
                res = true;
                break;
            }
        }
        if (res) {
            break;
        }
    }

    if (res) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

#include <bits/stdc++.h>
#define lc (o<<1)
#define rc ((o<<1)|1)
using namespace std;
#define DebugP(x) cout << "Line" << __LINE__ << " " << #x << "=" << x << endl

typedef long long LL;
typedef complex<double> Comp;

const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
const int modu = 1e9 + 7;

template<class T>
inline void read(T &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch<'0'||ch>'9')  {f|=(ch=='-');ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    x=f?-x:x;
    return;
}

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

struct Edge {
	int u, v;
	LL T, K;
	Edge(int u=0, int v=0, LL T=0, LL K=0):
		u(u), v(v), T(T), K(K) {}
};

vector<Edge> edges;
vector<int> G[maxn];

int n, m, x, y;

void addEdge(int u, int v, LL T, LL K) {
	edges.push_back(Edge(u, v, T, K));
	G[u].push_back(edges.size()-1);
}

LL dist[maxn];

struct Node {
	LL d;
	int id;
	Node(LL d=0, int id=0):
		d(d), id(id) {}
	bool operator<(const Node &op) const {
		return d > op.d;
	}
};

priority_queue<Node> Q;
bool vis[maxn];

int main() {
	// freopen("input.txt", "r", stdin);
	read(n, m, x, y);
	for (int i = 0; i < m; ++i) {
		int a, b, c, d;
		read(a, b, c, d);
		addEdge(a, b, c, d);
		addEdge(b, a, c, d);
	}
	memset(vis, 0, sizeof(vis));
	memset(dist, 0x3f, sizeof(dist));
	dist[x] = 0;
	Q.push(Node(dist[x], x));
	while (!Q.empty()) {
		while (!Q.empty() && vis[Q.top().id]) Q.pop();
		if (Q.empty()) break;
		int u = Q.top().id;
		Q.pop();
		vis[u] = 1;
		for (int i: G[u]) {
			Edge &e = edges[i];
			if (dist[e.v] > (dist[u]/e.K + (dist[u]%e.K > 0))*e.K + e.T) {
				dist[e.v] = (dist[u]/e.K + (dist[u]%e.K > 0))*e.K + e.T;
				Q.push(Node(dist[e.v], e.v));
			}
		}
	}
	if (dist[0] == dist[y]) printf("-1\n");
	else printf("%lld\n", dist[y]);
	return 0;
}


/******************************************************/
/******************************************************/
/**                                                  **/
/**            BISMILLAHIR RAHMANIR RAHIM            **/
/**         REAZ AHAMMED CHOWDHURY - reaziii         **/
/**  Department of Computer Science and Engineering  **/
/*         INSTITUTE OF SCIENCE AND TECHNOLOGY       **/
/**                                                  **/
/******************************************************/
/******************************************************/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pcase(x)     printf("Case %d: ",x++)
#define fri(f)       for(int i=0;i<f;i++)
#define frj(f)       for(int j=0;j<f;j++)
#define reset(x)     memset(x,-1,sizeof(x))
#define all(x)       x.begin(),x.end()
#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout)
#define infi         INT_MAX
#define linfi        LLONG_MAX
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define mgraph       map<int,vector<int> >
#define pb           push_back
#define clr(x)       memset(x,0,sizeof(x))
#define fro(i,x,y)   for(int i=x;i<y;i++)
#define ech(x,a)     for(auto &x : a)
#define ff           first
#define ss           second
#define vi           vector<int>
#define vl           vector<ll>
#define pi           acos(-1.0)

using namespace std;
using namespace __gnu_pbds;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> void read(T& x) {cin >> x;}
template<class H, class... T> void read(H& h, T&... t) {read(h); read(t...);}
template<class A> void read(vector<A>& x) {for (auto &a : x) read(a);}
template<class H> void print(vector<H> &x) {ech(a, x) cout << a << " "; cout << endl;}
template<class P> void debug(P h) {
#ifndef ONLINE_JUDGE
	cerr << h << " ";
#endif
}
template<class W, class... V> void debug(W h, V... t) {
#ifndef ONLINE_JUDGE
	debug(h);
	debug(t...);
	cerr << endl;
#endif

}

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;

bool checkbitt(ll num, int pos) {return (num >> pos) & 1;}
ll setbitt(ll num, ll pos) {return (1 << pos) | num;}
ll resetbitt(ll num, int pos) {if (!checkbitt(num, pos)) return num; else return (1 << pos)^num;}
ll bigmod(ll a, ll b, ll mod) {if (b == 0) return 1; if (b == 1) return a; if (b & 1) {return ((a % mod) * (bigmod(a, b - 1, mod) % mod)) % mod;} ll x = bigmod(a, b / 2, mod); return (x * x) % mod;}
ll geti() {ll x; read(x); return x;}
const ll mod =  1e9 + 7;
const ll N   =  2e5 + 10;
int dx[4] = { +0, +0, +1, -1};
int dy[4] = { -1, +1, +0, +0};

//................................___Start from here___...............................//
//................................_____________________..............................//

int solve() {
	int n, k;
	string s;
	read(n, k, s);

	fri(n) {
		if (s[i] == 'o') k++;

		else {
			k--;
			k = max(0, k);
		}

	}
	cout << k << endl;

	return 0;
}
int main(int argc, char* argv[]) {

	if (argc <= 1) {
#ifndef ONLINE_JUDGE
		input;
		output;
#endif
#ifdef ONLINE_JUDGE
		ios_base::sync_with_stdio(false);
		cin.tie(0);
#endif
	}

	int cs = 1, cn = 1;
	// read(cs);
	while (cs--) {
		solve();

	}
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=2e5+5,M=2e5,mod=998244353;
ll n,m,mi[N],jc[N*2],s[N],ans,save[N],inv[N*2],jcinv[N*2];
ll qpow(ll n,ll k){
    ll t=1;
    while(k){
        if(k&1)t=t*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return t;
}
// ll C(ll n,ll m){
//     return jc[n]*qpow(jc[m],mod-2)%mod*qpow(jc[n-m],mod-2)%mod;
// }
ll C(ll n,ll m){
    return jc[n]*jcinv[m]%mod*jcinv[n-m]%mod;
}
ll solve(ll x){
    ll t=x,sum=1;
    while(t!=1){
        ll c=0,p=mi[t];
        while(t%p==0)t/=p,c++;
        sum=sum*s[c]%mod;
    }
    return sum;
}
int main()
{
    ll i,j,x;
    cin>>m>>n;m--;
    for(i=2;i<=M;i++){
        if(mi[i])continue;
        for(j=i;j<=M;j+=i)
            if(!mi[j])mi[j]=i;
    }
    jc[0]=jc[1]=1;
    inv[1]=1;
    jcinv[1]=jcinv[0]=1;
    for(i=2;i<=n+m;i++)jc[i]=jc[i-1]*i%mod;
    for(i=2;i<=n+m;i++)inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    for(i=2;i<=n+m;i++)jcinv[i]=jcinv[i-1]*inv[i]%mod;
    for(i=1;i<=n;i++)s[i]=C(i+m-1,m-1);
    for(i=1;i<=n;i++)save[i]=solve(i);
    for(i=2;i<=n;i++)save[i]+=save[i-1];
    for(i=1;i<=n;i++){
        x=n/i;
        ans=(ans+save[x])%mod;
    }
    cout<<ans;
}


#include <iostream>
#include <bits/stdc++.h>
#define For(i,x,y) for(int i = (x);  i <= (y); i ++ )
#define fori(i,x,y) for(int i = (x); i < (y); i ++ )
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define endl '\n'
#define all(x) a.begin(), a.end()
#define mst(x,a) memset(x, a, sizeof x)
#define debug(a) cout<< #a <<": " << a << endl
using namespace std;

typedef long long LL;
typedef pair<int,int>pa;

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 2e5+10;
const int maxm = 1e6+10;
const int N = 1e6+10;

int dp[maxn][20][2][2];
int a[maxn], n, k;
int dfs(int x, int sta, bool lead = true, bool limit = true){
    int cnt = __builtin_popcount(sta);
    int& ans  = dp[x][cnt][lead][limit];
    if(~ans) return ans;
    if(cnt > k) return ans = 0;
    if(x==n) return cnt==k;
    int up = limit?a[x]:15;
    ans = 0;
    For(i,0,up){
        int add = dfs(x+1, (lead&&!i) ? sta : sta|1<<i, !i&&lead, limit && i == up);
        ans = (LL)ans + add;
        if(ans >= mod) ans -= mod;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    string s;
    cin>>s>>k;
    mst(dp,-1);
    n = sz(s);
    fori(i,0,n)a[i] = isdigit(s[i])?s[i]-'0':s[i]-'A'+10;
    printf("%d\n", dfs(0,0));
    return 0;
}

#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
using namespace std;
#define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
typedef long long ll;
#define N 200005
ll p=1e9+7;
ll n,m,f[N][17][17]={0},v[22]={0},sm;
char a[N];
int main()
{
	ll i,j,k,a1,a2,an=0;
	scanf("%s",a+1);
	n=strlen(a+1);
	for(ll i=1;i<=n;i++)
		if(a[i]>='0'&&a[i]<='9')
			a[i]-='0';
		else
			a[i]-='A'-10;
	scanf("%lld",&m);
	for(ll i=0;i<=m;i++)
		f[0][i][i]=1;
	for(ll i=1;i<=n;i++)
		for(ll j=1;j<=m;j++)
			for(ll k=j;k<=m;k++)
				f[i][j][k]=((ll)f[i-1][j][k-1]*(17ll-k)+(ll)f[i-1][j][k]*k)%p;
	for(ll i=1;i<=n;i++)
		an=(an+15ll*f[i-1][1][m])%p;
	// for(ll i=1;i<=n;i++)
	// {
	// 	for(ll j=1;j<=m;j++)
	// 		for(ll k=j;k<=m;k++)printf("%lld\n",f[i][j][1]);
	// }
	for(ll i=1;i<=n;i++)
	{
		for(ll j=a[i]+1;j<=15;j++)
			an=(an-f[n-i][sm+(!v[j])][m]+p)%p;
		//printf("%lld\n",an);
		sm+=!v[a[i]];
		v[a[i]]=1;
	}
	printf("%lld",an);
}


/**************************************************************
 * Problem:
 * Author: Vanilla_chan
 * Date:
**************************************************************/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<limits.h>
#define IL inline
#define re register
#define LL long long
#define ULL unsigned long long
#ifdef TH
#define debug printf("Now is %d\n",__LINE__);
#else
#define debug
#endif
#ifdef ONLINE_JUDGE
char buf[1<<23],* p1=buf,* p2=buf,obuf[1<<23],* O=obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#endif
using namespace std;

template<class T>inline void read(T& x)
{
	char ch=getchar();
	int fu;
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') fu=-1,ch=getchar();
	x=ch-'0';ch=getchar();
	while(isdigit(ch)) { x=x*10+ch-'0';ch=getchar(); }
	x*=fu;
}
inline int read()
{
	int x=0,fu=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') fu=-1,ch=getchar();
	x=ch-'0';ch=getchar();
	while(isdigit(ch)) { x=x*10+ch-'0';ch=getchar(); }
	return x*fu;
}
int G[55];
template<class T>inline void write(T x)
{
	int g=0;
	if(x<0) x=-x,putchar('-');
	do { G[++g]=x%10;x/=10; } while(x);
	for(int i=g;i>=1;--i)putchar('0'+G[i]);putchar('\n');
}
#define N 110
LL gcd(LL a,LL b)
{
	if(b) return gcd(b,a%b);
	return a;
}
int n,x[N];
bool book[N];
int prime[N],cnt;
void init()
{
	book[1]=1;
	for(int i=2;i<=50;i++)
	{
		if(!book[i])
		{
			prime[++cnt]=i;
			for(int j=2;i*j<=50;j++) book[i*j]=1;
		}
	}
}
bool y[N];
LL ans=1e18+5;
LL check()
{
	LL tmp=1;
	for(int i=1;i<=cnt;i++) if(y[i]) tmp*=prime[i];
	for(int i=1;i<=n;i++)
	{
		if(gcd(tmp,x[i])==1) return 0;
	}
	return tmp;
}
void dfs(int p)
{
	LL t;
	if(t=check())
	{
		ans=min(ans,t);
		return;
	}
	if(p==cnt+1) return;
	dfs(p+1);
	y[p]=1;
	dfs(p+1);
	y[p]=0;
}
int main()
{
	n=read();
	init();
	for(int i=1;i<=n;i++) x[i]=read();
	dfs(1);
	write(ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

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

	ll x[n];
	rep(i, n) cin >> x[i];

	vector<int> ps{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};

	ll ans = LLINF;
	rep(ni, 1<<ps.size()){
		vector<int> use(15);
		int ii = ni;
		rep(iii, 15){
			use[iii] = ii&1;
			ii >>= 1;
		}

		ll tmp = 1;
		rep(i, 15){
			if(use[i]==1) tmp *= ps[i];
		}

		bool ok = true;
		rep(i, n){
			if(__gcd(tmp, x[i])==1) ok = false;
		}
		if(ok) chmin(ans, tmp);
	}

	cout << ans << endl;
	// printf("%d\n", N);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> Vll;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   string s;
   cin >> s;
   ll cnto=0;
   ll cntx=0;
   ll cnt=0;
   rep(i,10){
       if(s[i]=='o')cnto++;
       else if(s[i]=='x')cntx++;
       else cnt++;
   }
   ll ans=1;
   if(cnto>4 || cntx==10)ans=0;
   else if(cnto==4){
       ans=4*3*2*1;
   }
   else if(cnto==3){
       ans=36+4*3*2*1*cnt;
   }
   else if(cnto==2){
       ans=14+cnt*6*4+cnt*cnt*12;
   }
   else if(cnto==1){
       ans=1+cnt*4+cnt*cnt*6+cnt*cnt*cnt*4;
   }
   else{
       ans=cnt*cnt*cnt*cnt;
   }
   cout << ans << endl;
}

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

int main(){
   string s;
   cin >> s;
   ll knt = 0;

   for(int i = 0;i < 10;i++){
       for(int j = 0;j < 10;j++){
          for(int k = 0;k < 10;k++){
              for(int l = 0;l < 10;l++){
                string t = s;
                bool flag = true;
                if(t.at(i) == 'x') flag = false;
                if(t.at(j) == 'x') flag = false;
                if(t.at(k) == 'x') flag = false;
                if(t.at(l) == 'x') flag = false;
                t.at(i) = 'x';
                t.at(j) = 'x';
                t.at(k) = 'x';
                t.at(l) = 'x';
                rep(y,10){
                    if(t.at(y) == 'o') flag = false;
                }
                if(flag) knt++;

             }
          }
       }
   }

   cout << knt << endl;
}


#include <bits/stdc++.h>
using namespace std;
using C = complex<double>;

C unko(){
    double x,y;
    cin>>x>>y;
    return C(x,y);
}
int main(void){
    int n;
    cin>>n;
    C s=unko();
    C t=unko();
    C o=(s+t)/2.0;
    double PI=acos(-1);
    double rad=2*PI/n;
    C r(cos(rad),sin(rad));
    C ans=o+r*(s-o);
    cout<<fixed<<setprecision(10)<<ans.real()<<" "<<ans.imag()<<endl;
    return 0;
}

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = long long; using ull = unsigned long long; using pll = pair<ll,ll>; const ll INF = 4e18;
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<fixed<<setprecision(15)<<head;print0(tail...);}
void print() { print0("\n"); }
template<typename Head,typename... Tail>void print(Head head,Tail... tail){print0(head);if(sizeof...(Tail)>0)print0(" ");print(tail...);}
// clang-format on

int main() {
    ll t;
    cin >> t;
    for (ll i = 0; i < t; i++) {
        ll l, r;
        cin >> l >> r;
        ll mn = l + l;
        ll mx = r;
        if (mn > mx) {
            print(0);
            continue;
        }
        ll n = mx - mn + 1;
        print(n * (n + 1) / 2);
    }
}


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

struct {
        int x, y, z;
}city[18], a, b;
int drum[18][18], total_cost = INT_MAX, cities, t, cost[(1 << 18)][18];

int distance(int i, int  j) {
        a = city[i];
        b = city[j];
        return abs(b.x - a.x) + abs(b.y - a.y) + max(0, b.z - a.z);
}

int main() {
        cin >> cities;
        for (int i = 1; i <= cities; i++)
                cin >> city[i].x >> city[i].y >> city[i].z;
        for (int i = 1; i <= cities; i++)
                for (int j = 1; j <= cities; j++)
                        drum[i][j] = distance(i, j);
        int maxim = (1 << cities);
        for (int i = 1; i <= maxim; i++)
            for (int j = 1; j <= cities; j++)
                cost[i][j] = 1000000000;
        cost[1][1] = 0;
        for (int i = 1; i < maxim; i++)
                for (int j = 1; j < cities; j++)
                        if (i & (1 << j))
                                for (int x = 1, exc = (i - (1 << j)); x <= cities; x++)
                                        cost[i][j + 1] = min(cost[i][j + 1], cost[exc][x] + drum [x][j + 1]);

        for (int i = 2; i <= cities; i++)
                total_cost = min(total_cost, cost[maxim - 1][i] + drum[i][1]);
        cout << total_cost;
}

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

vector<int> x,y,z;

int dist(int a,int b){
  return abs(x[b]-x[a])+abs(y[b]-y[a])+max(0,z[b]-z[a]);
}

void infout(int a){
  if(a == 1e9) cout << "INF";
  else cout << a;
  cout << ",";
}

void chmin(int& a, int b){
  a = min(a,b);
}

int main(){

  int n;
  cin >> n;
  x.resize(n);
  y.resize(n);
  z.resize(n);
  rep(i,n) cin >> x[i] >> y[i] >> z[i];
  vector<vector<int>> dp(1<<n,vector<int>(n,1e9));
  rep(i,n){
    if(i == 0) continue;
    dp[1<<i][i] = dist(0,i);
  }
  rep(i,1<<n){
    //from where?
    rep(from,n){
      //to where?
      rep(to,n){
        chmin(dp[i|1<<to][to],dp[i][from]+dist(from,to));
      }
    }
  }
  cout << dp[(1<<n)-1][0] << endl;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<stack>
#include<set>
#define iss ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 7;
const int mod = 998244353;
int head[maxn],num,fa[maxn],n,m,ans[maxn];
struct node{
    int  v,w,next;
}e[maxn];
void add(int u,int v,int w){
    e[num].next = head[u];
    e[num].v = v;
    e[num].w = w;
    head[u] = num ++;
}
int Find(int x){
    if(fa[x] != x) fa[x] = Find(fa[x]);
    return fa[x];
}
void dfs(int u,int pre){
    for(int i = head[u];i != -1;i = e[i].next){
        int to = e[i].v,w = e[i].w;
        if(to == pre) continue;
        if(w == ans[u]){
           if(w == n) ans[to] = 1;
           else ans[to] = w + 1;
        }
        else ans[to] = w;
        dfs(to,u);
    }
}
int main (){
    scanf("%d%d",&n,&m);
    memset(head,-1,sizeof(head));
    for(int i = 1; i <= n; i ++){
        fa[i] = i;
    }
    for(int i = 1,u,v,w; i <= m; i ++){
        scanf("%d%d%d",&u,&v,&w);
        int x = Find(u);
        int y = Find(v);
       // printf ("%d %d..\n",x,y);
        if(x == y) continue;
        fa[x] = y;
       // printf ("%d %d %d\n",u,v,w);
        add(u,v,w);
        add(v,u,w);
    }
    ans[1] = 1;
    dfs(1,-1);
    for(int i = 1; i <= n; i ++){
        printf ("%d\n",ans[i]);
    }

}

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

#define ll long long
#define forin(in ,n) for(ll i=0; i<n; i++) cin>>in[i]
#define forout(out) for(ll i=0; i<(ll)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep_up(i, a, n) for (ll i = a; i < n; ++i)
#define rep_down(i, a, n) for (ll i = a; i >= n; --i)
#define P pair<ll, ll>

#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>
#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>

constexpr ll INF = (1ll << 60);
constexpr ll mod = 1000000007;
//constexpr ll mod = 998244353;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
void pt(T val) {
    cout << val << "\n";
}
template <typename T>
void pt_vll(vector<T> &v) {
    ll vs = v.size();
    rep(i, vs) {
        cout << v[i];

        if (i == vs - 1)
            cout << "\n";
        else
            cout << " ";
    }
}
ll mypow(ll a, ll n) {
    ll ret = 1;
    if(n==0) return 1;
    if(a==0) return 0;
    rep(i, n) {
        if (ret > (ll)(1e18 + 10) / a) return -1;
        ret *= a;
    }
    return ret;
}
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;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

struct Edge{
    ll to;
    ll co;
};

int main() {
    ll n,m,x=0,y=0,z=0,k,cnt=1,ans=0;
    cin>>n>>m;
    vector<vector<Edge>> G(n);
    vll color(n);
    rep(i,m){
        cin>>x>>y>>z;
        x--;y--;
        G[x].push_back({y,z});
        G[y].push_back({x,z});
    }
    queue<ll> que;
    que.emplace(0ll);
    color[0]=1;
    while(!que.empty()){
        ll state=que.front();
        que.pop();
        for(auto e:G[state]){
            if(color[e.to]>0) continue;
            if(color[state]==e.co){
                color[e.to]=(e.co)%n+1;
            }else{
                color[e.to]=e.co;
            }
            que.emplace(e.to);
        }
    }
    rep(i,n){
        cout<<color[i]<<endl;
    }
}


#define LOCAL

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

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

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define uniq(x) sort(all(x)); x.resize(unique(all(x))-x.begin());
#define sz(x) (int)x.size()
#define pw(x) (1LL<<x)

using pii = pair<int, int>;
using ll = long long;
const ll MOD = 998244353LL;
const long double PI = acos(-1.0);

int popcount(int x) {
	int cnt = 0;
	while(x>0) {
		if(x&1)
			cnt += 1;
		x/=2;
	}
	return cnt;
}

void solve() {
	int n; cin >> n;
	cout << (1<<n) - 1<< "\n";
	int x=1<<(n-1) ;
	for(int i=1 ; i<=(1<<n)-1 ; i++) {
		string s = "";
		for(int j=0 ; j<(1<<n) ; j++) {
			s+="A";
		}
		for(int j=0 ; j<(1<<n) ; j++) {
			if(popcount(i&j)&1)
				s[j]='B';
		}
		cout << s << "\n";
	}
}

int main() {
	IOS;
	int t = 1;
	while(t--)
		solve();
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int main(){
	int n, nn; cin >> n; nn = 1 << n;
	cout << nn-1 << "\n";
	for(int bt=1; bt<nn; bt++){
		rep(i,nn) cout << (char)(__builtin_parity(bt&i) + 'A');
		cout << "\n";
	}
}


#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define endl "\n"
using namespace std;

const int max_n = 1e5+10;
const int inf = 1e18;

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    string s;cin>>s;
    s.pb(s[0]);
    for(int i=1;i<s.size();i++){
        cout<<s[i];
    }
    cout<<endl;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    cout<< (N-1) <<endl;
	return 0;
 }


#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=1;i<=(n);++i)
#define rep3(i,i0,n) for(ll i=i0;i<(n);++i)
#define rrep(i,n) for(ll i=((n)-1); i>=0; --i)
#define rrep2(i,n) for(ll i=(n); i>0; --i)
#define pb push_back
#define mod 998244353
#define fi first
#define se second
#define len(x) ((ll)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
using Pi = pair< ll, ll >;
using vl = vector<ll>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<Pi>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

const ll INF = 1LL << 60;
const ld PI = 3.1415926535897932385;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
void printb(ll N,ll d=16){
    rep(i,d){
        cout<<(N/(1<<(d-i-1)))%2;
    }
    cout<<endl;

}
void printv(vector<ll>a){
    rep(i,a.size()){
        if(i==a.size()-1){
            cout<<a[i]<<endl;
        }else{
            cout<<a[i]<<" ";
        }
    }
}
bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;

    }else{
        return a.second < b.second;
    }
}

//const vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1};
//const vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
using mint = modint<mod>;
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    ll N;
    cin>>N;
    vl A(N);

    rep(i,N){
        cin>>A[i];
    }

    sort(all(A));

    mint ans=0;
    mint now=0;
    ll flag=0;
    rep(i,N){

        ans+=(now+A[i])*A[i];
        now*=2;
        now+=A[i];

        //cout<<now.a<<endl;
        //cout<<ans.a<<endl;

    }

    cout<<ans.a<<endl;
    return 0;

}

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

const int mod=998244353;

int pw(int a,int t=mod-2){
    int x=1;
    while(t>0){
        if(t&1)x=1ll*x*a%mod;
        a=1ll*a*a%mod,t>>=1;
    }
    return x;
}
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    int a[n],sum=0;
    for(int i=0;i<n;i++){
    	cin >> a[i];
    	sum=(sum+1ll*a[i]*a[i])%mod;
    }
    sort(a,a+n);
    int x=0,y=0,ans=0;
    for(int i=0;i<n;i++){
    	y=(1ll*pw(pw(2,n-i))*a[i]%mod)%mod;
    	ans=(ans+1ll*x*y%mod)%mod;
    	x=(x+1ll*pw(pw(2,i+1))*a[i]%mod)%mod;
    }
    ans=1ll*ans*pw(2,n)%mod;
    ans=(ans+sum)%mod;
    cout << ans;
}


#include <bits/stdc++.h>
 using namespace std;
    void solve ()
    {
        char x,y;
        cin>>x;
        cin>>y;
        if(x=='Y' )
        {
            char ans=toupper(y);
            cout<<ans;
        }
        else if(x=='N')
        {
            cout<<y;
        }
    }

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

#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main() {
    char s, t;
    cin >> s >> t;
    if (s == 'Y') {
        t -= 32;
    }
        cout << t << '\n';
}


#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <cctype>
#include <climits> // INT_MAX ...
#include <cstring> //

using namespace std;

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

  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  int ans = 3;
  if (r1 == r2 && c1 == c2) {
    ans = 0;
  } else if (r1 + c1 == r2 + c2 || r1 - c1 == r2 - c2 ||
             abs(r1 - r2) + abs(c1 - c2) <= 3) {
    ans = 1;
  } else if ((r1 + c1) % 2 == (r2 + c2) %2 || abs(r1 - r2) + abs(c1 - c2) <= 6 ||
             abs((r1 - r2) + (c1 - c2)) <= 3 || abs((r1 - r2) - (c1 - c2)) <= 3) {
    ans = 2;
  }
  cout << ans << '\n';

  return 0;
}

//#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9+7; //998244353;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

//using mint = modint1000000007;

vector<string> ff(vector<string> iv, int c){
	int h=iv.size(), w=iv[0].size();
	auto rt=iv;
	if(c%2) rt.assign(w, string(h, ' '));
	if(c==1) rep(i,h) rep(j,w) rt[j][h-1-i] = iv[i][j];
	if(c==2) rep(i,h) rep(j,w) rt[h-1-i][w-1-j] = iv[i][j];
	if(c==3) rep(i,h) rep(j,w) rt[w-1-j][i] = iv[i][j];
	return rt;
}
void f3(vector<string>& iv){
	int h=iv.size(), w=iv[0].size();
	int lsw=0;
	rep(i, h){
		int lsw=0;
		rep(j ,w){
			if(iv[i][j]=='P') lsw=1;
			if(iv[i][j]=='B') lsw=0;
			if(lsw && iv[i][j]=='.') iv[i][j] ='T';
		}
	}
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w, n ,m;
	cin >>h >>w >>n >>m;
	vector<string> ba(h, string(w, '.'));
	rep(i, n){
		int a, b; cin >>a >>b;
		ba[a-1][b-1] ='P';
	}
	rep(i, m){
		int c, d; cin >>c >>d;
		ba[c-1][d-1] = 'B';

	}
	rep(i, 4){
		f3(ba);
		ba = ff(ba, 1);
	}

	ll ans =0;
	for(auto& xl: ba) for(auto x :xl) if(x=='P'||x=='T') ans++;
	cout << ans <<"\n";
	return 0;
}


#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vf = vector<float>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using sl = stack<ll>;
using ql = queue<ll>;

const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

int binary_search(ll x, vl a){
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin() ;
    } else {
        return -1;
    }

}

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

int main() {
    ll N;
    cin >> N;
    if(N % 2 == 0) {
        cout << "White" << endl;
    }  else {
        cout << "Black" << endl;
    }
    return 0;
}

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

int main()
{
    int n;
    scanf("%d",&n);
    puts(n%2?"Black":"White");
}


#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int n;
    scanf("%d",&n);
    ll a[200100];
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+n+1,cmp);
    ll sum[200100];
    sum[1]=a[1];
    for(int i=2;i<=n;i++)
        sum[i]=sum[i-1]+a[i];
    ll ans=0;
    for(int i=1;i<n;i++)
        ans+=sum[n-i]-(sum[n]-sum[i]);
    printf("%lld",ans);
    return 0;
}

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

ll Solve(int n, vector<ll> a)
{
  sort(a.begin(), a.end());
  ll sum = 0;
  for (ll i = n - 1; 0 <= i; --i)
  {
    sum += (i * a[i]) - (n - 1 - i) * a[i];
  }
  return sum;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,0,n-1) cin >> a[i];
  cout << Solve(n, a) << endl;
  return 0;
}