#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <tuple>

template <class E> struct FenwickTree {
    int _n;
    std::vector<E> data;

    FenwickTree(int n) : _n(n), data(n) { }

    void add(int p, E x) {
        ++p;
        while (p <= _n) {
            data[p - 1] += x;
            p += p & -p;
        }
    }
    E sum(int r) const {
        E s = 0;
        while (r > 0) {
            s += data[r - 1];
            r -= r & -r;
        }
        return s;
    }
    E sum(int l, int r) const {
        return sum(r) - sum(l);
    }
};

long long proc(
    std::vector<int>             &cur,
    int                          x,
    int                          y,
    FenwickTree<int>             &ftcnt0,
    FenwickTree<long long>       &ftsum0,
    const FenwickTree<int>       &ftcnt1,
    const FenwickTree<long long> &ftsum1,
    const std::vector<int>       &arr)
{
    int v = cur[x];
    long long dem = (long long)ftcnt1.sum(0, v) * arr[v];
    long long cre = (long long)ftcnt1.sum(0, y) * arr[y];
    long long adj = (long long)ftsum1.sum(y, v);

    ftsum0.add(v, -arr[v]);
    ftcnt0.add(v, -1);
    cur[x] = y;
    ftsum0.add(y, arr[y]);
    ftcnt0.add(y, 1);

    return cre + adj - dem;
}

int main(int argc, char **argv)
{
    int n, m, q;
    std::cin >> n >> m >> q;
    std::vector<std::tuple<int, int, int>> txy;
    std::set<int> s = { 0 };

    for (int i = 0; i < q; i++) {
        int t, x, y;
        std::cin >> t >> x >> y;
        txy.push_back(std::make_tuple(t, x - 1, y));
        s.insert(y);
    }
    std::vector<int> arr(s.begin(), s.end());
    std::map<int, int> map;
    int ll = s.size();

    for (int i = 0; i < ll; i++) map.emplace(arr[i], i);

    FenwickTree<long long> ftsuma(ll);
    FenwickTree<long long> ftsumb(ll);
    FenwickTree<int>       ftcnta(ll);
    FenwickTree<int>       ftcntb(ll);
    std::vector<int> cura(n);
    std::vector<int> curb(m);
    ftcnta.add(0, n);
    ftcntb.add(0, m);
    long long sum = 0;

    for (const auto&e : txy) {
        int cy = map[std::get<2>(e)];
        sum += (std::get<0>(e) == 1) ? proc(cura, std::get<1>(e), cy, ftcnta, ftsuma, ftcntb, ftsumb, arr)
                                     : proc(curb, std::get<1>(e), cy, ftcntb, ftsumb, ftcnta, ftsuma, arr);
        std::cout << sum << std::endl;
    }
    return 0;
}

#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++)
#define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(int)(n);k++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define vector3d(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=(ll)1<<60;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}
template<class T> void chmax(T &a,const T b){if(b>a)a=b;}
template<class T> void chmin(T &a,const T b){if(b<a)a=b;}

//各桁の数の和を求める
template <typename T>
T digitsum(T n){
    string s=to_string(n);
    T sum=0;
    T d=1;
    for(T e=0;e<s.length();e++){
        sum+=(n/d)%10;d*=10;
    }
    return sum;
}

int main(){
    INT(a,b);
    a=digitsum(a);
    b=digitsum(b);
    out(max(a,b));
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define sz(x) int(x.size())
// #define show(x) {for(auto i:x){cout << i << " ";} cout << endl;}
#define isin(x,l,r) ((l)<=(x) && (x)<(r))
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<typename T>bool chmin(T&x,const T&y) {if(x>y){x=y;return true;} else return false;}
template<typename T>bool chmax(T&x,const T&y) {if(x<y){x=y;return true;} else return false;}

void show(vector<int> A) {
    for (int a : A) {
        if (a==0) cout << 'A';
        else cout << 'B';
    }
    cout << '\n';
}

int main() {
    int N;
    cin >> N;
    int M = 1 << N;
    cout << M-1 << '\n';
    for (int i = 1; i < M; i++) {
        vector<int> A(M);
        for (int j = 0; j < M; j++) {
            int p = __builtin_popcountll(i&j);
            if (p&1) A[j] = 1;
        }
        show(A);
    }
    return 0;
}

///In the name of GOD
//#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 5000 + 10;
ll k, n;
ll ans;
vector<string> ANS;
string t, one;
void Print(){
    cout << ans << '\n';
    for(auto X : ANS){
        cout << X << '\n';
    }
    exit(0);
}
string Rev(const string& s){
    t = s;
    reverse(t.begin(), t.end());
    return t;
}
string Not(const string& s){
    t = "";
    for(int i = 0; i < int(s.size()); i ++){
        if(s[i] == 'A') t += "B";
        else            t += "A";
    }
    return t;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> k, n = (1LL << k);
    ans = 1;
    ANS.push_back("AB");
    one = "A";
    for(int i = 1; i < k; i ++){
        for(int j = 0; j < ans; j ++){
            ANS.push_back(ANS[j] + Not(ANS[j]));
            ANS[j] = ANS[j] + ANS[j];
        }
        one = one + one;
        ANS.push_back(one + Not(one));
        ans = int(ANS.size());
    }
    Print();
    return 0;
}
/*!
    HE'S AN INSTIGATOR,
    ENEMY ELIMINATOR,
    AND WHEN HE KNOCKS YOU BETTER
    YOU BETTER LET HIM IN.
*/
//! N.N


#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>
#include <limits>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD 998244353

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
const ld eps = 1.0e-10; // 許容される誤差

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

bool comp(pair<int,pair<int,int>> a, pair<int, pair<int, int>> b){
	return a.first <= b.first;
}

ld mysqrtl(ld x)
{
	ld a = sqrt((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a*a) > eps);
	return a;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);

	int n;
	//*
	cin >> n;

	vector<int> x = vector<int>(n);
	REP(i, n) {
		cin >> x[i];
	}
	/*/
	n = 100000;
	vector<int> x = vector<int>(n, 100000);
	//*/

	ll mh = 0;
	REP(i, n) {
		mh += abs(x[i]);
	}
	cout << mh << endl;

	ld tmpEu = 0;
	REP(i, n) {
		tmpEu += x[i] * (ll)x[i];
	}
	cout << sqrt(tmpEu) << endl;

	int ch = 0;
	REP(i, n) {
		chmax(ch, abs(x[i]));
	}
	cout << ch << endl;
}

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <limits>
using namespace std;

int main() {
  long long N; cin >> N;
  long long x[N];
  for (int i = 0; i < N; i++) cin >> x[i];

  long long ans1 = 0;
  for (int i = 0; i < N; i++) ans1 += abs(x[i]);
  double ans2 = 0;
  for (int i = 0; i < N; i++) ans2 += x[i] * x[i];
  ans2 = sqrt(ans2);
  long long ans3 = 0;
  for (int i = 0; i < N; i++) ans3 = max(ans3, abs(x[i]));

  cout << ans1 << endl;
  cout << fixed << setprecision(13) << ans2 << endl;
  cout << ans3 << endl;
}


#include <functional>
#include <ios>
#include <numeric>
#include <ostream>
#include <string>
#include <valarray>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC target("popcnt")
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include<bits/stdc++.h>
#include <cstdarg>
#include <cstdint>
#include <cstring>
#include <iomanip>
#include <math.h>
#include <vector>

// @author : sam000013

#define int long long
#define ll long long
#define PI 3.14159265
#define pb(x) push_back(x)
#define all(v) v.begin(), v.end()
#define dbg(x) cout<<#x<<" "<<x<<endl;
#define bye cout<<endl;return
#define uni 1.000000
#define ld long double
using namespace std;

const int mod = 1000000007;
const int secondMod = 998244353;
const int hashMod = 29996224275833;
template <typename T>

void show(vector<T> x)
{
    for (auto e : x){
        cout<<e<<" ";
    }
    cout<<endl;
}
template <typename T1>
void showPair(vector<pair<T1, T1>> x) {
    for(auto e:x){
        cout<<e.first<<" "<<e.second<<endl;
    }
}
template <typename T2>
void showSetPair(set<T2> x) {
    for(auto e:x){
        cout<<e.first<<" "<<e.second<<"\n";
    }
    // cout<<endl;
}
template <typename T3>
void showMultiSet(multiset<T3> x) {
    for(auto e:x){
        cout<<e<<" ";
    }
    cout<<endl;
}

/*

*/

void solve(){
    int n;
    cin>>n;
    set<int> s;
    for(int i=0; i<n; i++){
        int x;cin>>x;
        s.insert(x);
    }
    int ans = 1, prev = 0;
    for(auto x:s){
        ans = (ans * (x-prev+1))%mod;
        prev = x;
    }
    cout<<ans;bye;

}
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int t   = 1;
    // cin >> t;
    for(int i=1; i<=t; i++){
        solve();
    }
    return 0;
}

#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    lli n;cin>>n;
    vlli a(n);flli(i,0,n-1)cin>>a[i];
    sort(all(a));
    lli val=(a[0]+1)%mod;
   	flli(i,1,n-1)
   	{
   		val=(val*(a[i]-a[i-1]+1))%mod;
   	}
   	cout<<val;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long LL;
typedef pair <int, int> P;
const int N = 2e5 + 5;

int n, a[N], b[N], c[N];
LL ans, res;

int main() {
	cin>>n;
	rep (i, 1, n) scanf("%d", &a[i]), ans += a[i];
	rep (i, 1, n) scanf("%d", &b[i]), b[i] -= a[i];
	rep (i, 1, n) {
		if (i&1) b[(i + 1)>>1] = b[i];
		else c[i>>1] = b[i];
	}
	sort(b + 1, b + n/2 + 1);
	sort(c + 1, c + n/2 + 1);
	res = ans;
	per (i, n/2, 1) res += b[i] + c[i], ans = max(ans, res);
	printf("%lld\n", ans);
}

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

#define ll long long
#define ld long double
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define F first
#define S second
#define pll pair<ll, ll>
#define all(v) (v).begin(), (v).end()
#define decimal(n) cout << fixed << setprecision(n)
#define mod 1000000007
// #define mod 998244353
#define pi 3.14159265358979323846

ll ncr(ll n, ll r)
{
    ll p = 1, k = 1;

    if (n - r < r)
        r = n - r;

    if (r != 0)
    {
        while (r)
        {
            p *= n;
            k *= r;
            ll m = __gcd(p, k);
            p /= m;
            k /= m;

            n--;
            r--;
        }
    }
    else
        p = 1;
    return p;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t = 1, tc;
    //cin >> t;
    for (tc = 1; tc <= t; tc++)
    {
        ll l;
        cin >> l;
        cout << ncr(l - 1, 11);
    }
    return 0;
}


// Problem: B - ARC Wrecker
// Contest: AtCoder - AtCoder Regular Contest 117
// URL: https://atcoder.jp/contests/arc117/tasks/arc117_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<ll>
#define vll vector<ll>
#define all(x) (x).begin() , (x).end()

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_ll_distribution<ll>(x, y)(rng)

void dbg(){
	cerr << endl;
}
template<typename Head , typename... Tail>
void dbg(Head h , Tail... t){
	cerr << h << " ";
	dbg(t...);
}

#ifdef EMBI_DEBUG
#define debug(...) cerr << "(" << #__VA_ARGS__  << "): ", dbg(__VA_ARGS__)
#else
#define debug(...)
#endif

const ll max_n = 1e5 + 9;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
void solve(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	for(ll i = 0 ; i < n ; i++) {
		cin >> a[i];
	}

	sort(all(a));
	ll prod = (a[0] + 1);
	for(ll i = 1 ; i < n ; i++) {
		prod *= (a[i] - a[i-1] + 1);
		prod %= mod;
	}

	cout << prod << "\n";
}
signed main(){
	ll t = 1;
	// cin >> t;
	for(ll i = 1 ; i <= t ; i++){
		solve();
	}
}

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

#define INF 1234567890
#define ll long long
#define MOD 1000000007

int T;
int N;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	cin >> N;
	vector<int> A(N);
	for(int i=0; i<N; i++)
		cin >> A[i];
	A.push_back(0);
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	N = A.size();

	ll res = 1;
	for(int i=1; i<N; i++)
	{
		res *= A[i]-A[i-1]+1;
		res %= MOD;
	}
	cout << res << "\n";
	return 0;
}


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

int main(){
  ll n, m;
  cin >> n >> m;
  vector<pair<ll,ll>> As(n);
  vector<ll> A(n);
  vector<vector<ll>> g(n, vector<ll>(0));

  for(ll i=0; i<n; i++){
    ll a;
    cin >> a;
    As.at(i).first = a;
    As.at(i).second = i;
    A.at(i) = a;
  }
  for(ll i=0; i<m; i++){
    ll x, y;
    cin >> x >> y;
    g.at(x-1).push_back(y-1);
  }

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

  vector<ll> P(n, 0);
  ll ans = -10000000000;
  queue<ll> que;
  for(int i=0;i<n;i++){
    ll now = As.at(i).second;
    que.push(now);
    while (!que.empty()) {
      ll v = que.front();
      que.pop();
      if(now!=v) {
        ans = max(ans, A.at(v) - A.at(now));
        P.at(v) = 1;
      }
      for (ll nv : g.at(v)) {
        if (P.at(nv) == 1) continue;
        que.push(nv);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> pii;
typedef pair<LL,pii> ppi;
typedef pair<pii,pii> ppp;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second

template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {cout << "["; F0R(i, v.size()) {if (i) cout << ", "; cout << v[i];} return cout << "]";}

//var
const LL INF = 1e17;
LL t, n, m, a[200005], ans = -INF;
vector<LL> e[200005], e2[200005];
LL v[200005], minbuy[200005], maxsell[200005], v2[200005];

void dfs(LL g){
	if(v[g]) return;
	v[g] = 1;

	for(auto u : e[g]){
		if(!v[u]) dfs(u);
		maxsell[g] = max(maxsell[g], maxsell[u]);
		ans = max(ans, maxsell[u] - minbuy[g]);
	}

	//cout << g << '\n';
}

void dfs2(LL g){
	if(v2[g]) return;
	v2[g] = 1;
	for(auto u : e2[g]){
		if(!v2[u]) dfs2(u);
		minbuy[g] = min(minbuy[g], minbuy[u]);
	}
}

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

	LL t1, t2;
	FOR(i, m){
		cin >> t1 >> t2;
		e[t1].pb(t2);
		e2[t2].pb(t1);
	}

	FOR(i, n){
		maxsell[i] = a[i];
		minbuy[i] = a[i];
	}

	for(int i = n; i>=1; i--){
		if(v2[i]) continue;
		dfs2(i);
	}

	FOR(i, n){
		if(v[i]) continue;
		dfs(i);
	}

	cout << ans << '\n';
}

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

	t = 1;
	//cin >> t;
	FOR(i, t)
		solve();

	cout.flush();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = s; i < (int)(n); ++i)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
typedef string::const_iterator state; //構文解析
const double PI=acos(-1);
const ll big=998244353;
//const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
    if(x>y)return x;
    else return y;
}
ll min(ll x,ll y){
    if(x<y)return x;
    else return y;
}
ll expm(ll x,ll y,ll mod=big){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1,mod)*x)%mod;
    ll t=expm(x,y/2,mod);
    return (t*t)%mod;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    ll a,b,c;cin >> a >> b >> c;
    cout << a*(a+1)%big * b %big * (b+1) %big * c%big * (c+1) %big * expm(8,big-2,big)%big << endl;
}

//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
//Incase of close mle change language to c++17 or c++14

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353ll
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n, m;
    cin>>n>>m;
    //cout<<n%m;
    //cout<<power(10, n, m*m)%m<<" "<<power(10, n, m)<<"\n";
    cout<<(((power(10, n, m*m)-power(10, n, m))/m)+m)%m;
}


#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<ll> a(N);
    for (auto &it : a)
        cin >> it;

    ll ans = a[0];
    for (int i = 1; i < N; i++)
    {
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

/*
0のアスキー　"48"
*/

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){

    ll N;
    cin >> N;

    vector<ll> A(N);

    for(ll i = 0;i < N;i++)
        cin >> A.at(i);

    ll min = MOD;
    for(ll i = 0;i < N;i++){
        if(min > A.at(i))
            min =  A.at(i);
    }

    if(min == 1){
        cout << min << endl;
    }else{
        while(1){
        bool zero_fla = true;
        ll hako = MOD;
        for(ll i = 0;i < N;i++){
            A.at(i) %= min;
            if(A.at(i) != 0 and hako > A.at(i)){
                zero_fla = false;
                hako = A.at(i);
            }
        }

        if(min > hako)
            min = hako;

        if(zero_fla or min == 1)
            break;

        }

        cout << min << endl;
    }

    return 0;

}


#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
const int N=20,M=210;
int l;
ll dp[N][M];
ll dfs(int p,int s){
    if(s>l) return 0;
    if(p==13){
        if(s==l) return 1;
        return 0;
    }
    if(dp[p][s]!=-1) return dp[p][s];
    ll ans=0;
    ans+=dfs(p,s+1);
    ans+=dfs(p+1,s+1);
    return dp[p][s]=ans;
}
int main(){
    cin>>l;
    memset(dp,-1,sizeof(dp));
    cout<<dfs(1,0)<<endl;
}

#include "bits/stdc++.h"
using namespace std;
#define endl "\n"
using ll = long long;
const int MOD = 1e9 + 7;

ll binomialCoeff(ll n, ll k)
{
	ll res = 1;

	// Since C(n, k) = C(n, n-k)
	if (k > n - k)
		k = n - k;

	// Calculate value of
	// [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
	for (ll i = 0; i < k; ++i) {
		res *= (n - i);
		res /= (i + 1);
	}

	return res;
}

void solve() {
	ll num; cin >> num;
	cout << binomialCoeff(num - 1, 11) << endl;
}

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

	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
   fastIO
   int m,h; cin>>m>>h;
   if(h%m==0)cout<<"Yes\n";
   else cout<<"No\n";

   return 0;
}

#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pll, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define FOR(i,a,b)  for(ll i=a;i<=b;i++)
#define FORR(i,a,b)  for(ll i=a;i>=b;i--)
#define vl vector<ll>
#define ld long double
#define vld vector<ld>
#define vvl vector<vector<ll>>
#define vvld vector<vector<ld>>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.14159265358979323846264338327950288419716939937510
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define mset(a,val) memset(a,val,sizeof(a));
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M = 1000000007;
const ll MM = 998244353;
#define endl "\n"
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

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

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

const ll N = 2e5+5;

void OJ() {

#ifndef ONLINE_JUDGE

  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);

#endif

}

int main() {

  IOS;

OJ();

ll a,b,c;
cin>>a>>b>>c;

if(a*a+b*b<c*c)cout<<"Yes";
else cout<<"No";

return 0;

}


#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<ll,ll>
#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=5e5,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1e-9;

void solve(){
    int a,b;
    cin>>a>>b;
    int sa=0,sb=0;
    while(a)
        sa+=(a%10),a/=10;
    while(b)
        sb+=(b%10),b/=10;
    cout<<max(sa,sb);
}
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;
}

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
//indexed set is using "int" here--------- use ll ...
// typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
void solve_dp(ve<ve<ll>> &dp, ll r, ll c, ve<ve<ll>> &A, ve<ve<ll>> &B)
{
    dp[1][1] = 0;
    rep(i, 1, r + 1)
    {
        rep(j, 1, c + 1)
        {
            if (i == 1)
            {
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + A[i][j - 1]);
                continue;
            }
            if (j == 1)
            {
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + B[i - 1][j]);
                continue;
            }
            dp[i][j] = min({dp[i][j], dp[i][j - 1] + A[i][j - 1], dp[i - 1][j] + B[i - 1][j]});
        }
    }
}
int main()
{
    FAST;
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll r, c;
    cin >> r >> c;
    ve<ve<ll>> A(r + 1, ve<ll>(c + 1)), B(r + 1, ve<ll>(c + 1));
    rep(i, 1, r + 1)
    {
        rep(j, 1, c)
        {
            cin >> A[i][j];
        }
    }
    rep(i, 1, r)
    {
        rep(j, 1, c + 1)
        {
            cin >> B[i][j];
        }
    }
    ve<ve<ll>> dp(r + 1, ve<ll>(c + 1, 1e18));
    solve_dp(dp, r, c, A, B);
    rep(z, 0, 1001)
    {
        rep(i, 1, r + 1)
        {
            rev (j, c+1, 2)
            {
                dp[i][j - 1] = min(dp[i][j - 1], dp[i][j] + A[i][j - 1]);
            }
        }
        ve<ll> mn(c + 1, 1e18);
        rev(i, r + 1, 1)
        {
            rep(j, 1, c + 1)
            {
                mn[j] = min(mn[j], dp[i][j] + i + 1);
            }
            rep(j, 1, c + 1)
            {
                dp[i][j] = min(dp[i][j], mn[j] - i);
            }
        }
        solve_dp(dp, r, c, A, B);
    }
    cout << dp[r][c] << "\n";
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using PQ = priority_queue<T>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
constexpr ll dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
inline void Yes() { cout << "Yes" << ENDL; }
inline void No() { cout << "No" << ENDL; }
inline void YES() { cout << "YES" << ENDL; }
inline void NO() { cout << "NO" << ENDL; }

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T>
vector<T> finddivisor(T x) {  //整数xの約数(xを含む)
  vector<T> divisor;
  for(T i = 1; (i * i) <= x; i++) {
    if(x % i == 0) {
      divisor.push_back(i);
      if(i * i != x) { divisor.push_back(x / i);}
    }
  }
  sort(divisor.begin(), divisor.end());
  return divisor;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(auto&& x: vec) is >> x;
  return is;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}

template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  V<ll> a(n),b(n);cin>>a>>b;

  V<ll> c(n,0);
  ll amx=0;
  rep(i,0,n){
    chmax(amx,a[i]);

    if(i)chmax(c[i],c[i-1]);
    chmax(c[i],amx*b[i]);
  }

  rep(i,0,n)cout<<c[i]<<ENDL;
}
//! ( . _ . ) !
//CHECK overflow,vector_size,what to output?
//any other simpler approach?
//list all conditions, try mathematical and graphic observation

#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(void){
    int N;
    int maxA = 1;

    scanf("%d\n", &N);
    vector<long long> a(N), b(N), c(N);

    for(int i=0; i<N; i++){
        scanf("%lld", &a[i]);
    }
    for(int i=0; i<N; i++){
        scanf("%lld", &b[i]);
    }
    maxA = a[0];
    c[0] = maxA*b[0];

    for(int i=1; i<N; i++){
        if(maxA<a[i]){
            maxA = a[i];
        }
        c[i] = max(c[i-1],maxA*b[i]);
    }

    for(int i=0; i<N; i++){
        printf("%lld\n",c[i]);
    }

}


// $%D%$.$%M%$.$%Y%$
// $%h%$:$%m%$:$%s%$

#pragma GCC optimize("O3")

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

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ld long double
#define rep(i,a,n) for (int i=(int)(a);i<(int)(n);i++)
#define per(i,a,n) for (int i=(int)(n-1);i>=(int)(a);i--)
#define mp(a, b) make_pair(a, b)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define fi first
#define se second

const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};

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

int cmp(pii a, pii b) {
    swap(a.first, a.second);
    swap(b.first, b.second);
    return a < b;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> a(n), dp(n, 1e18);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<pll> e(m);

    for (int i = 0; i < m; ++i) {
        cin >> e[i].first >> e[i].second;
        --e[i].first, --e[i].second;
    }
    ll res = -1e18;

    sort(e.begin(), e.end(), cmp);
    for (auto x : e) {
        dp[x.second] = min(dp[x.second], dp[x.first]);
        dp[x.second] = min(dp[x.second], a[x.first]);

        res = max(res, a[x.second] - dp[x.second]);
    }

    cout << res << '\n';
}

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

std::vector<int> topological_sort(const std::vector<std::vector<int>> &graph) {
  int n = graph.size();
  std::vector<int> deg(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int e : graph[i]) ++deg[e];
  }
  std::queue<int> que;
  for (int i = 0; i < n; ++i) {
    if (deg[i] == 0) que.emplace(i);
  }
  std::vector<int> res;
  while (!que.empty()) {
    int ver = que.front(); que.pop();
    res.emplace_back(ver);
    for (int e : graph[ver]) {
      if (--deg[e] == 0) que.emplace(e);
    }
  }
  return res.size() == n ? res : std::vector<int>();
}

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<vector<int>> graph(n);
  while (m--) {
    int x, y; cin >> x >> y; --x; --y;
    graph[x].emplace_back(y);
  }
  vector<int> ts = topological_sort(graph);
  int ans = -INF;
  vector<int> dp(n, -INF);
  for (int i = n - 1; i >= 0; --i) {
    int town = ts[i];
    for (int e : graph[town]) chmax(dp[town], max(dp[e], a[e]));
    chmax(ans, dp[town] - a[town]);
  }
  cout << ans << '\n';
  return 0;
}


/*
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
*/
#include<bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define db long double
#define ull unsigned long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int flag[maxn];
db f1[maxn],f2[maxn],suf1[maxn],suf2[maxn];

int main()
{
    //fastio();
    int n,m,k; scanf("%d%d%d",&n,&m,&k);

    rep(i,1,k){
        int x; scanf("%d",&x);
        flag[x] = 1;
    }
    per(i,n-1,0){
        if(flag[i]){
            f1[i] = 0;f2[i] = 1;
        }else{
            f1[i] = 1.0 + (suf1[i+1] - suf1[i+m+1]) / m;
            f2[i] = (suf2[i+1] - suf2[i+m+1]) / m;
        }//show2(f1[i],f2[i]);
        suf1[i] = f1[i] + suf1[i+1];
        suf2[i] = f2[i] + suf2[i+1];
    }
    db ans = f1[0] / (1 - f2[0]);
    //printf("%.4Lf\n",ans);
    if(ans > 1e13) cout << -1 << endl;
    else cout << fixed << setprecision(4) << ans << endl;
    return 0;
}

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

int debug = 0;

const int N = 2e5, K = 18, inf = 1e9;
int n, m, k, ans, c[K], dp[K][1 << K], dist[K][K], d[N];
vector <int> g[N];

bool belong(int x, int mask) {
    return (mask >> x) & 1;
}

void bfs(int id) {
    int start = c[id];
    fill(d + 1, d + n + 1, -1);
    queue <int> q;
    q.push(start);
    d[start] = 0;
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int u : g[v]) {
            if (d[u] == -1) {
                d[u] = d[v] + 1;
                q.push(u);
            }
        }
    }
    rep(j, 0, k) {
        dist[id][j] = d[c[j]];
    }
}

void calcDist() {
    rep(i, 0, k) {
        bfs(i);
    }
}

main() {
    cin >> n >> m;
    rep(i, 0, m) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    cin >> k;
    rep(i, 0, k) fill(dp[i], dp[i] + (1 << k), inf);
    rep(i, 0, k) {
        cin >> c[i];
        dp[i][1 << i] = 1;
    }
    calcDist();
    rep(mask, 0, (1 << k)) {
        if ((int)__builtin_popcount(mask) > 1) {
            rep(v, 0, k) if (belong(v, mask)) {
                rep(u, 0, k) if (belong(u, mask) && u != v && dist[u][v] != -1) {
                    dp[v][mask] = min(dp[v][mask], dp[u][mask ^ (1 << v)] + dist[u][v]);
                }
            }
        }
    }
    ans = inf;
    rep(i, 0, k) {
        ans = min(ans, dp[i][(1 << k) - 1]);
    }
    if (ans == inf) ans = -1;
    cout << ans << '\n';
}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;
using vv = vector<vector<int>>;
const int INF = (int)1e9;
const LL LINF = (LL)1e18;
const int query = 1000;
const int grid_size = 30;
const int grid_total = grid_size * grid_size;
const int initial_length = 4000;

string path_ex(int si, int sj, int ti, int tj){
	int di = ti - si, dj = tj - sj;
	string s;
	if(di >= 0) rep(k,di) s.push_back('D');
	else rep(k,-di) s.push_back('U');
	if(dj >= 0) rep(k,dj) s.push_back('R');
	else rep(k,-dj) s.push_back('L');
	return s;
}

vector<vector<int>> G;
int cost[grid_total][grid_total];
int update_number[grid_total][grid_total];

void length_update(int from, int to, int ave_length){
	int now_length = cost[from][to];
	int num = update_number[from][to] + 1;
	int new_length = (now_length * num + ave_length) / (num + 1);
	cost[from][to] = new_length, cost[to][from] = new_length;
	update_number[from][to]++, update_number[to][from]++;
}

string dijkstra(int st, int ed){
   int N = G.size();
   vector<int> dist(N, INF), par(N, -1);
   dist[st] = 0;
   priority_queue<P,vector<P>,greater<P>> q;
   q.push({dist[st], st});
   while(!q.empty()){
	   P p = q.top(); q.pop();
	   int d = p.first, n = p.second;
	   if(dist[n] < d) continue;
	   for(auto v : G[n]){
		   int c = cost[n][v];
		   if(dist[v] <= d + c) continue;
		   dist[v] = d + c;
		   q.push({dist[v], v});
		   par[v] = n;
	   }
   }
   string path;
   int now = ed;
   while(now != st){
	   char c;
	   if(par[now] + 1 == now) c = 'R';
	   else if(par[now] - 1 == now) c = 'L';
	   else if(par[now] + grid_size == now) c = 'D';
	   else c = 'U';
	   path.push_back(c);
	   now = par[now];
   }
   reverse(path.begin(), path.end());
   return path;
}

int main(){
	//FILE *outputfile;
	//outputfile = freopen("test.txt", "w", stdout);

	G.resize(grid_total);
	rep(i,grid_size){
		rep(j,grid_size) cost[i][j] = INF;
	}
	rep(i,grid_size){
		rep(j,grid_size-1){
			int l = i * grid_size + j, r = i * grid_size + j + 1;
			assert(l < grid_total and r < grid_total);
			G[l].emplace_back(r);
			G[r].emplace_back(l);
			cost[l][r] = initial_length, cost[r][l] = initial_length;
		}
	}
	rep(j,grid_size){
		rep(i,grid_size-1){
			int u = i * grid_size + j, d = (i + 1) * grid_size + j;
			assert(u < grid_total and d < grid_total);
			G[u].emplace_back(d);
			G[d].emplace_back(u);
			cost[u][d] = initial_length, cost[d][u] = initial_length;
		}
	}
	rep(q,query){
		int si, sj, ti, tj;
		cin >> si >> sj >> ti >> tj;
		int st = si * grid_size + sj, ed = ti * grid_size + tj;
		assert(st < grid_total and ed < grid_total);
		string path = dijkstra(st, ed);
		cout << path << endl;
		int dist_result;
		cin >> dist_result;
		int path_size = path.size();

		random_device rnd;
		mt19937 mt(rnd());
		uniform_real_distribution<> rand_e(0.9, 1.1);
		//uniform_int_distribution<> rand_length(1, 1000);

		int sum_result = 0;
		vector<int> path_vertices(path_size + 1);
		path_vertices[0] = st;
		rep(k,path_size){
			int now = path_vertices[k];
			if(path[k] == 'R') now++;
			else if(path[k] == 'L') now--;
			else if(path[k] == 'D') now += grid_size;
			else now -= grid_size;
			path_vertices[k+1] = now;
		}
		rep(k,path_size){
			int from = path_vertices[k], to = path_vertices[k+1];
			int ave_length = dist_result / path_size;
			length_update(from, to, ave_length);
			sum_result += cost[from][to];
		}
		/*
		int dif = dist_result - sum_result;
		rep(k,path_size){
			int pre = path_vertices[k], now = path_vertices[k+1];
			cost[pre][now] += dif / path_size;
			cost[now][pre] += dif / path_size;
		}
		*/
	}

	return 0;
}

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

int main() {
  double a, b, c, d;
  cin >> a >> c >> b >> d;
  cout << fixed << setprecision(10);
  cout << c * (b-a) / (c+d) + a << endl;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define endl "\n"
#define deb(x) cout<<#x<<" "<<x<<endl;
#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar,n) for(int pen=0;pen<n;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define fr(i,x,n) for(int i=x;i<n;i++)
#define frt(it,vb) for(auto it=vb.begin();it!=vb.end();it++)
#define mem(ar,x) memset(ar,x,sizeof(ar));
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define rt return 0;
#define ct continue;
#define MAX 1000000000000000000
#define MAX1 1000000000
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

inline int solve()
{
    int n,m;
    cin>>n>>m;
    map <int , vector <int> > mp;
    fr(i,0,m){
        int x,y;
        cin>>x>>y;
        mp[x].push_back(y);
    }
    set <int> st;
    st.insert(n);
    for(auto it : mp){

        set <int> a,b;
        for(auto ut : it.second){
            int x = ut;
            if(st.find(x) != st.end() && st.find(x-1) == st.end() && st.find(x+1) == st.end()){
                b.insert(x);
            }
            if(st.find(x) == st.end() && (st.find(x-1) != st.end() || st.find(x+1) != st.end()) ){
                a.insert(x);
            }
        }
        for(auto ut : a){
            st.insert(ut);
        }
        for(auto ut : b){
            st.erase(ut);
        }
    }
    cout << st.size() << endl;
    rt;
}
signed main()
{
    // fastio;
    int t;
    int test_cases=1;
    if(test_cases==0)
    cin>>t;
    else
    t=1;
    while(t--){
        solve();
    }
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define irreps(i, m, n) for (long long i = ((long long)(n)-1); i > (long long)(m); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) (long long)(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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

  ll a,b,c; cin>>a>>b>>c;
  if(c==0){
    if(a>b) cout<<"Takahashi"<<endl;
    else cout<<"Aoki"<<endl;
  }else{
    if(a>=b) cout<<"Takahashi"<<endl;
    else cout<<"Aoki"<<endl;
  }

}


#include<ctime>
#include<cstdio>
#include<cctype>
using namespace std;
const int N=1e3+7;
int read() {
	char c;
	int x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while (isdigit(c)){
		x=x*10+(c-48)*f;
		c=getchar();
	}
	return x;
}
int n,m,a[N],b[N];
int main() {
	#ifndef ONLINE_JUDGE
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	m=read();
	for(int i=1;i<=n;++i)
		a[read()]=1;
	for(int i=1;i<=m;++i)
		b[read()]=1;
	for(int i=1;i<=1000;++i){
		if(a[i]^b[i])
			printf("%d ",i);
	}
	//--------
	clock_t t2=clock();
	fprintf(stderr,"time:%0.3lfs",1.0*(t2-t1)/CLOCKS_PER_SEC);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
using u64 = uint_least64_t;
using s64 = int_least64_t;
using ll = uint_least64_t;

int main(){
    int n,m;

    cin >> n >> m;
	vector<int> a(n+m),b(m);
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (int i = 0; i < m; i++){
		cin >> a[n+i];
	}
	sort(a.begin(), a.end());

	int nn = n + m;
	for (int i = 1; i < nn; i++){
		if (a[i-1] == a[i]){
			a.erase(a.begin()+i-1);
			a.erase(a.begin()+i-1);
			i--;
			nn-=2;
		}
	}
	for (auto i = a.begin(); i != a.end(); i++){
		cout << *i << " ";
	}
	cout << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#define N 201000
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-') flag = true; c = getchar(); }
	while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
	if (flag)	x = -x;
}
using namespace std;
int n;
int a[N], b[N], h[N], htot;
long long ans;
inline void sol(int L, int R) {
	if (L + 1 == R)	return ;
//	printf("sol(%d, %d) : \n", L, R);
	int ptr = R;
	for (int i = L + 1; i < R; ++i) if (b[i] > a[i]) { ptr = i; break; }
//	printf("ptr = %d\n", ptr);
	int tol = a[ptr - 1];
	for (int i = ptr - 1; i > L; --i) {
		if (b[i] < tol) {
			int p = upper_bound(a + L, a + R + 1, b[i]) - a - 1;//bug
//			printf("i = %d, p = %d\n", i, p);
			ans += i - p;
			tol = b[i];
		}
	}
	int tor = a[ptr];
	for (int i = ptr; i < R; ++i) {
		if (b[i] > tor) {
			int p = lower_bound(a + L, a + R + 1, b[i]) - a;//bug bug
//			printf("i = %d, p = %d\n", i, p);
			ans += p - i;
			tor = b[i];
		}
	}
}
int main() {
	read(n);
	int L;
	read(L);
	++n; ++n;
	a[0] = b[0] = 0; a[n - 1] = b[n - 1] = L + 2 - n;//0 ... L + 1
	for (int i = 1; i < n - 1; ++i) read(a[i]), a[i] -= i;
	for (int i = 1; i < n - 1; ++i) read(b[i]), b[i] -= i;
//	for (int i = 0; i < n; ++i) printf("%d ", a[i]); puts("");
//	for (int i = 0; i < n; ++i) printf("%d ", b[i]); puts("");
	for (int i = 0; i < n; ++i) h[++htot] = a[i];
	htot = unique(h + 1, h + 1 + htot) - h - 1; h[htot + 1] = -12341;
	for (int i = 0; i < n; ++i) a[i] = lower_bound(h + 1, h + 1 + htot, a[i]) - h;
	for (int i = 0; i < n; ++i) {
		int v = lower_bound(h + 1, h + 1 + htot, b[i]) - h;
		if (h[v] != b[i]) return puts("-1"), 0;
		b[i] = v;
	}
//	for (int i = 0; i < n; ++i) printf("%d ", a[i]); puts("");
//	for (int i = 0; i < n; ++i) printf("%d ", b[i]); puts("");
	int lst = 0;
	for (int i = 1; i < n; ++i) if (a[i] == b[i]) {
//		printf("\ni = %d : \n", i);
		sol(lst, i); lst = i;
//		printf("ans = %lld\n", ans);
	}
	printf("%lld\n", ans);
	return 0;
}

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

const int M = 2e5 + 10;

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

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

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

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

   	init();

   	int n,m,k;
   	cin>>n>>m>>k;
   	if(n==1 or m==1) {
   		cout<<ex(k,n+m-1);
   		return 0;
   	}
   	// Bi>=max(A)
   	int ans=0;
   	rep(i,1,k+1) {
   		int now=sub(ex(i,n),ex(i-1,n));
   		now=mul(now,ex(k-i+1,m));
   		ans=add(ans,now);
   	}
   	cout<<ans;

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
  int n,x;
  cin>>n>>x;
  string s;
  for(int i=0;i<n;i++){
    cin>>s;
    if(s[i]=='o'){
      x=x+1;
    }
    else{
      if(x>0){
        x=x-1;
      }
    }
  }
  cout<<x<<endl;
}

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

int main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);
int n,x;
string s;
cin>>n>>x>>s;
for(auto i=0;i<n;i++){
    if(x<=0){
        if(s[i]=='o'){
            x++;
        }else continue;
    }else{
        if(s[i]=='o')x++;
        else x--;
    }
}
cout<<x <<"\n";
}


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

using namespace std;

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

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

void swap(int *a, int *b) {
    *b = *a - *b;
    *a -= *b;
    *b += *a;
}

int sosu_judge(int N) {
    /*素数ならば1
      素数でなければ0を返す
    */
    int i, j;

    if(N == 2)
        return 1;
    if(N % 2 == 0)
        return 0;

    for(i = 3; i < N && N % i != 0; i += 2)
        ;

    if(i >= N)
        return 1;

    return 0;
}

int factorial(int N) { // Nの階乗を求める関数
    int ans = 1;

    while(N--)
        ans *= (N + 1);
    return ans;
}

//クイックソートをする関数
void q_sort(int a[], int first, int last) {
    int i, j;
    int x, t;

    x = a[(first + last) / 2];
    i = first;
    j = last;

    while(1) {
        while(a[i] < x)
            i++;
        while(x < a[j])
            j--;

        if(i >= j)
            break;

        swap(&a[i], &a[j]);
        i++;
        j--;
    }
    if(first < i - 1)
        q_sort(a, first, i - 1);
    if(last > j + 1)
        q_sort(a, j + 1, last);
}

int b_search(int target, int array[], int right, int left) {
    /*二分探索を行う関数である。
  戻り値は探索したい値の格納されている位置である。
  もし値が存在しない場合、NOT_FOUND(-1)を返す
  */
    int mid;
    while(left < right) {
        mid = (right + left) / 2;
        if(array[mid] < target)
            left = mid + 1;
        else
            right = mid;
    }
    if(array[mid] == target)
        return mid;
    return NOT_FOUND;
}

unsigned long combination(int n, int r) {
    /*nCrの値を求める関数である。
  値が巨大になる可能性があるため、戻り地はunsigned longである
  */
    int i, j;
    unsigned long a[17];

    if(n - r < r)
        r = n - r;
    if(r == 0)
        return 1;
    if(r == 1)
        return n;
    if(r > 17)
        return 0;
    for(i = 1; i < r; i++)
        a[i] = i + 2;
    for(i = 3; i <= n - r + 1; i++) {
        a[0] = i;
        for(j = 1; j < r; j++)
            a[j] += a[j - 1];
    }
    return a[r - 1];
}


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

#define ll long long
#define pi pair<int,int>
#define pll pair<long,long>
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vvvvi vector<vvvi>
#define vc vector<char>
#define vll vector<long long>
#define vpi vector<pi>
#define vpll vector<pll>
#define pb push_back
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define all(v) v.begin(), v.end()
#define pq(type) priority_queue<type>
#define inp(n, mas) for(int i=0;i<n;i++)cin>>mas[i];
#define vb vector<bool>
#define mp make_pair

///////////////////////////////////////////
#define hello ivanmordvintsevgay
///////////////////////////////////////////

using namespace std;

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

bool comp(string a, string b)
{
	for (int i = 0; i < min(a.length(), b.length()); i++)
	{
		if (a[i] < b[i]) return true;
		if (a[i] > b[i]) return false;
	}
	return (a.length() < b.length());
}

int bin_poisk(const

vector <string> &d, string z)

{

  int l = 0;

  int r = d.size() - 1;

  while (l < r) {

    int m = (l + r ) / 2;

    if (comp(z, d[m]))

      r = m;

    else

      l = m + 1;

  }

  if (d[r] == z)

    return r;

  else

    return r;

}

int plus(int a, int b)
{
	return (a + b) % 4;
}

void solve()
{
	int m, h;
	cin >> m >> h;
	cout << ((h % m == 0) ? "Yes":"No");
}

int main()
{
	/*ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);*/
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
		cout << endl;
	}
}

#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL)

#define nl "\n"
#define fr first
#define sc second
#define MP make_pair
#define pb push_back
#define VI vector<int>
#define VII vector<ll>
#define MAP map <ll,ll>
#define PI pair < int , int >
#define sz(v) (int)(v).size()
#define all(v) v.begin(),v.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define precise(n) fixed(cout);cout<<setprecision(n)
#define in(v) for(auto &it : v) cin >> it
#define out(v) for(auto &it : v) cout << it << " "; cout << nl
#define casee(v) cout << "Case " << CASE << ": " << v << nl
#define des (res ? "Yes" : "No")

typedef long long ll;
typedef double db;

const int N = (int)4e7;
const int MOD = (int)1e9 + 7;
const double pi = 2 * acos(0.0);
const double eps = 1e-9; // 10^-9 = 0.0000000001

using namespace std;

bool isEqual(db a, db b) {
    return abs(a - b) <= eps;
}
bool isGreater(db a, db b) {
    return a > b + eps;
}
bool isSmaller(db a, db b) {
    return a + eps < b;
}

void execution() {

    int m, h;
    cin >> m >> h;

    bool res = false;
    if (((h / m)*m) == h)
        res = true;

    cout << des << nl;
}

int main()
{
    io;

#ifdef CODE_MAFIA
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    ///Let the showdown begin

    //ll t;
    //cin >> t;
    //while (t--) {
    execution();
    //}

    ///Happily DONE

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
template<class T>
struct graph{
    struct edge{
        int to;
        T cost;
        edge(int to, T cost) : to(to), cost(cost){}
        bool operator<(const edge& r)const { return cost < r.cost; }
    };
    int V;
    vector< vector< edge > > adj;
    vector< T > dist;
    vector< int > prev;

    graph(int n = 0){
        init(n);
    }

    void init(int size){
        V = size;
        adj.assign(size, vector<edge>());
    }

    void add_edge(int from, int to, T cost){
        adj[from].push_back(edge(to, cost));
    }

    void Dijkstra(int from, T inf){
        using P = pair<T, int>;
        priority_queue< P, vector<P>, greater<P> > q;
        dist.assign(V, inf);
        prev.assign(V, -2);
        dist[from] = 0;
        prev[from] = -1;
        q.push(P(0, from));
        while(!q.empty()){
            P p = q.top();
            q.pop();
            int v = p.second;
            if(dist[v] < p.first) continue;
            for(edge e: adj[v]){
                if(dist[v] + e.cost < dist[e.to]){
                    dist[e.to] = dist[v] + e.cost;
                    prev[e.to] = v;
                    q.push(P(dist[e.to], e.to));
                }
            }
        }
    }

    void get_path(int to, vector<int>& path){
        path.clear();
        if(prev[to] == -2) return;
        while(prev[to] != -1){
            path.push_back(to);
            to = prev[to];
        }
        path.push_back(to);
        reverse(path.begin(), path.end());
    }

    void print_path(int to){
        vector< int > path;
        get_path(to, path);
        cout << "path: " << endl;
        for(int i: path) cout << i << " ( " << dist[i] << " )" << endl;
    }
};

int main(void){
    int n, m;
    cin >> n >> m;
    vector< vector< int > > a(n, vector< int >(m));
    vector< vector< int > > b(n, vector< int >(m));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m-1; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < n-1; i++){
        for(int j = 0; j < m; j++){
            cin >> b[i][j];
        }
    }

    graph< int > g(n*m);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            int id = i * m + j;
            if(j+1 < m) g.add_edge(id, i*m + j+1, a[i][j]);
            if(j > 0) g.add_edge(id, i*m + j-1, a[i][j-1]);
            if(i+1 < n) g.add_edge(id, (i+1)*m + j, b[i][j]);
            for(int k = 0; k < i; k++) g.add_edge(id, k*m + j, i-k+1);
        }
    }
    g.Dijkstra(0, 1e9);
    cout << g.dist[n*m-1] << endl;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const long long N=2e6+6;
ll a[N],b[N];
long long n,m,q,ans;
struct segment {
	long long siz[N<<2],sum[N],ls[N<<2],rs[N<<2],cnt=0,root=0;
	void change(ll l,ll r,ll &p,ll x,ll k) {
		if(!p) p=++cnt;
		if(l==r) {
			sum[p]+=k*x;
			siz[p]+=k;
			return;
		}
		ll mid=(l+r)>>1;
		if(x<=mid) change(l,mid,ls[p],x,k);
		else change(mid+1,r,rs[p],x,k);
		sum[p]=sum[ls[p]]+sum[rs[p]];
		siz[p]=siz[ls[p]]+siz[rs[p]];
	}
	ll query1(ll l,ll r,ll p,ll x) {
		if(!p) return 0;
		if(r<=x) return siz[p];
		ll mid=(l+r)>>1;
		if(x<=mid) return query1(l,mid,ls[p],x);
		else return siz[ls[p]]+query1(mid+1,r,rs[p],x);
	}
	ll query2(ll l,ll r,ll p,ll x) {
		if(!p) return 0;
		if(l>x) return sum[p];
		ll mid=(l+r)>>1;
		if(x<=mid) return sum[rs[p]]+query2(l,mid,ls[p],x);
		else return query2(mid+1,r,rs[p],x);
	}
} A,B;
signed main() {
	scanf("%lld %lld %lld",&n,&m,&q);
	A.change(0,1e8,A.root,0,n),B.change(0,1e8,B.root,0,m);
	for(long long i=1;i<=q;i++) {
		long long opt,t,x,y;
		cin>>opt>>x>>y;
		if(opt==1) {
			ans=ans-B.query1(0,1e8,B.root,a[x])*a[x]-B.query2(0,1e8,B.root,a[x]);
			A.change(0,1e8,A.root,a[x],-1);
			A.change(0,1e8,A.root,y,1);
			a[x]=y;
			ans+=B.query1(0,1e8,B.root,y)*y+B.query2(0,1e8,B.root,y);
		}
		else {
			ans=ans-A.query1(0,1e8,A.root,b[x])*b[x]-A.query2(0,1e8,A.root,b[x]);
			B.change(0,1e8,B.root,b[x],-1);
			B.change(0,1e8,B.root,y,1);
			b[x]=y;
			ans+=A.query1(0,1e8,A.root,y)*y+A.query2(0,1e8,A.root,y);
		}
		cout<<ans<<endl;
	}
	return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int P=1e9+7,N=4e5+5;
int A[N],B[N],b[N],T[N],X[N],Y[N],ans,len;
struct BIT{
	int t[N],sum;
	void add(int i,int k) {
		sum+=k;
		for(;i<=len;i+=(i&-i))t[i]+=k;
	}
	int qry(int i) {
		int res=0;
		for(;i>0;i-=(i&-i))res+=t[i];
		return res;
	}
}T1,T2,t1,t2;
int read() {
	int x=0,f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
main() {
	int n=read(),m=read(),Q=read();
	for(int i=1;i<=n;++i)A[i]=0;
	for(int i=1;i<=m;++i)B[i]=0;
	b[len=1]=0;
	for(int i=1;i<=Q;++i) {
		T[i]=read();
		X[i]=read();
		b[++len]=Y[i]=read();
	}
	sort(b+1,b+len+1);
	len=unique(b+1,b+len+1)-b-1;
	for(int i=1;i<=n;++i) {
		A[i]=1;
		T1.add(A[i],b[A[i]]);
		t1.add(A[i],1);
	}
	for(int i=1;i<=m;++i) {
		B[i]=1;
		T2.add(B[i],b[B[i]]);
		t2.add(B[i],1);
	}
	for(int i=1;i<=Q;++i) {
		Y[i]=lower_bound(b+1,b+len+1,Y[i])-b;
		if(T[i]==1) {
			int p=X[i];
			ans-=b[A[p]]*t2.qry(A[p]);
			ans-=(T2.sum-T2.qry(A[p]));
			t1.add(A[p],-1);T1.add(A[p],-b[A[p]]);
			A[p]=Y[i];
			ans+=b[A[p]]*t2.qry(A[p]);
			ans+=(T2.sum-T2.qry(A[p]));
			t1.add(A[p],1);T1.add(A[p],b[A[p]]);
		}
		else {
			int p=X[i];
			ans-=b[B[p]]*t1.qry(B[p]);
			ans-=(T1.sum-T1.qry(B[p]));
			t2.add(B[p],-1);T2.add(B[p],-b[B[p]]);
			B[p]=Y[i];
			ans+=b[B[p]]*t1.qry(B[p]);
			ans+=(T1.sum-T1.qry(B[p]));
			t2.add(B[p],1);T2.add(B[p],b[B[p]]);
		}
		printf("%lld\n",ans);
	}
	return 0;
}


#pragma GCC optimize ("Ofast,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 2e6+7;
constexpr int M = 998244353;

#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))

#ifdef int
#define INF 0x3f3f3f3f3f3f3f3f
#define INF2 (int)(0xcfcfcfcfcfcfcfcf)
#else
#define INF 0x3f3f3f3f
#define INF2 0xcfcfcfcf
#endif

signed main() {
    fastio
    int a, b, c;
    cin >> a>> b >> c;
    cout << (a*(a+1)/2 % M) * (b*(b+1)/2 % M) % M * (c*(c+1)/2 % M) % M << "\n";
    return 0;
}

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

int main() {
    ll N, K;
    ll mod;
    cin >> N >> K >> mod;

    ll MX = 500000;
    vector<vector<ll>> dp(N, vector<ll>(MX, 0));
    dp[0][0] = 1;
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < i; j++) {
            ll summand = 0;
            for (int k = j; k < MX; k += i) {
                summand += dp[i-1][k];
                if (k >= (K+1)*i) summand += mod-dp[i-1][k-(K+1)*i];
                while (summand >= mod) summand -= mod;
                dp[i][k] = summand;
            }
        }
    }
    for (int i = 1; i <= N; i++) {
        ll ans = 0;
        for (int j = 0; j < MX; j++) {
            ans += dp[i-1][j]*dp[N-i][j]%mod*(K+1)%mod;
        }
        ans -= 1;
        ans %= mod;
        cout << ans << endl;
    }
    return 0;
}


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

void chmin(int &ret, const int &tg) {
    if (tg < ret) ret = tg;
}
void chmax(int &ret, const int &tg) {
    if (tg > ret) ret = tg;
}

const int INF = 1e9 + 10;
const int M = 5;
const int K = 3;
int ans = 0;

void dfs(int m, vvi &R, const vvi &P) {
    if (m < M) {
        rep(k, R.size()) {
            R[k].push_back(m);
            dfs(m + 1, R, P);
            R[k].pop_back();
        }
        if (R.size() < K) {
            R.push_back({m});
            dfs(m + 1, R, P);
            R.pop_back();
        }
    } else {
        vi ret(R.size(), 0);
        rep(i, P.size()) {
            rep(j, ret.size()) {
                int r = INF;
                for (int k : R[j]) {
                    chmin(r, P[i][k]);
                }
                chmax(ret[j], r);
            }
        }
        chmax(ans, *min_element(ret.begin(), ret.end()));
    }
    return;
}
int main() {
    int N;
    cin >> N;
    vvi P(N, vi(M));
    rep(i, N) { rep(j, M) cin >> P[i][j]; }

    vvi R;
    dfs(0, R, P);
    cout << ans << endl;
    return 0;
}

//IQ134高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp = 0;
	int n; cin >> n;
	int a[n][5];
	REP(i, n) REP(j, 5) cin >> a[i][j];
	int he = 0, bo = 1000000001;
	int now;
	set<int> mp;
	while(he + 1 < bo){
		now = (he + bo) / 2;
		//cout << he << "," << bo << ":" << now << endl;
		mp.clear();
		REP(i, n){
			int bit = 0;
			REP(j, 5){
				bit = bit << 1;
				if(a[i][j] >= now) bit++;
			}
			mp.insert(bit);
		}
		bool ch = false;
		for(auto i = mp.begin(); i != mp.end(); i++){
			for(auto j = mp.begin(); j != mp.end(); j++){
				for(auto k = mp.begin(); k != mp.end(); k++){
					if(((*i | *j)| *k) == (1 << 5) - 1){
						//cout << bitset<5>(*i) << endl << bitset<5>(*j) << endl << bitset<5>(*k) << endl << endl;
						ch = true;
					}
				}
			}
		}
		if(ch) he = now;
		else bo = now;
	}
	cout << he << endl;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long a[200010],b[200010];
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
	for(int i=1;i<=m;++i) scanf("%lld",&b[i]);
	sort(a+1,a+1+n);
	sort(b+1,b+1+m);

	long long l=0,r=0;
	for(int i=n;i>=2;i-=2){
		r+=a[i]-a[i-1];
	}
	long long ans=1e18;
	for(int i=1;i<=n;i+=2){
		int p=lower_bound(b+1,b+1+m,a[i])-b;
		if(p!=m+1) ans=min(ans,r+l+b[p]-a[i]);
		if(p!=1) ans=min(ans,r+l+a[i]-b[p-1]);
		l+=a[i+1]-a[i];
		r-=a[i+2]-a[i+1];
	}
	cout<<ans<<endl;
	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

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

int main() {
    int n, m;   cin >> n >> m;
    vector<ll> h(n), w(m);
    rep(i, n)   cin >> h[i];
    rep(i, m)   cin >> w[i];
    sort(h.begin(), h.end());
    sort(w.begin(), w.end());

    vector<ll> s1(n/2+1, 0), s2(n/2+1, 0);
    rep(i, n/2) {
        s1[i+1] = s1[i] + abs(h[2*i]-h[2*i+1]);
    }
    rep(i, n/2) {
        s2[i+1] = s2[i] + abs(h[2*i+1]-h[2*i+2]);
    }
    /*
    rep(i, n/2+1)
        cout << s1[i] << " ";
    cout << endl;
    rep(i, n/2+1)
        cout << s2[i] << " ";
    cout << endl;
    */

    ll ans = 1e18;
    rep(i, m) {
        auto ite = lower_bound(h.begin(), h.end(), w[i]);
        int j = ite - h.begin();
        ll tmp;
        if (ite == h.end()) {
            tmp = w[i] - h[n-1] + s1[n/2];
        }
        if (j % 2) {
            tmp = abs(w[i]-h[j-1]) + s1[(j-1)/2] - s1[0] + s2[n/2] - s2[(j-1)/2];
            ans = min(tmp, ans);
        }
        else {
            if (j > 0) {
                tmp = s1[j/2] - s1[0] + abs(h[j]-w[i]) + s2[n/2] - s2[j/2];
                ans = min(ans, tmp);
            }
            else {
                tmp = abs(h[0]-w[i]) + s2[n/2] - s2[0];
                ans = min(tmp, ans);
            }
        }
        //cout << tmp << endl;
    }

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

//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;


#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <math.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define mp(x, y) make_pair(x, y)

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

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

//nが素数かをO(√n)で判断
bool is_prime(int n) {
    bool res = true;

    if (n == 1) return false;
    else if (n == 2) return true;

    else {
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                res = false;
                break;
            }
        }
    }

    return res;
}

int perm(int n, int r) {
    if (r == 1) return n;
    return n * perm(n - 1, r - 1);
}

int fact(int n) {
    if (n == 1) return 1;
    return fact(n - 1) * n;
}

int comb(int n, int r) {
    int a = min(n, r), b = max(n, r);
    return perm(a, b) / fact(a);
}

//aの逆元　a^(-1)
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

//n!
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}

ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//nCr(mod P)
ll comb_mod(ll n, ll r, ll mod) {
    if (r > n - r) r = n - r;
    if (r == 0) return 1;
    ll a = 1;
    for (int i = 0; i < r; i++) a = a * ((n - i) % mod) % mod;
    ll b = pow_mod(fact_mod(r, mod), mod - 2, mod);
    return (a % mod) * (b % mod) % mod;
}

bool isContain(int v, int s) {
    return s & (1 << v);
}

//unionFind ランクとりバージョン
/*
注意点
・tree.isSame(a, b)とtreeに対してisSameを使う
・スペルはisSame
*/
struct unionFind {
    vector<int> par, rnk;

    unionFind(int N) : par(N), rnk(N, 0) {
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);

        if (x == y) return;
        else if (rnk[x] < rnk[y]) par[x] = y;
        else {
            par[y] = x;
            if (rnk[x] == rnk[y]) rnk[y]++;
        }
    }

    bool isSame(int x, int y) {
        return root(x) == root(y);
    }
};

/*クラスカル法
注意点！
・long long 型
・関数kraskulの引数は(頂点数、辺集合)の順
・unionFindはランクバージョンを使用すること
*/

struct edge {
    int s, t;
    long long cost;
};

bool comp(const edge& left, const edge& right) {
    return left.cost < right.cost;
}

vector<edge> es;
long long kraskul(int N, vector<edge> es) {
    long long res = 0;

    unionFind tree(N);

    //sortを忘れないように!
    //compを忘れないように！
    sort(es.begin(), es.end(), comp);

    for (int i = 0; i < es.size(); i++) {
        edge e = es[i];
        if (!tree.isSame(e.s, e.t)) {
            res += e.cost;
            tree.unite(e.s, e.t);
        }
    }

    return res;
}

//max intはだいたい2e9
//max llはだいたい9e18

typedef pair<int, int> P;

const int INF = 1e8;
const long long LINF = 1e18;

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

    vll A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    ll sum = 0;

    rep(i, N) sum += (A[i] + B[i]) * (B[i] - A[i] + 1) / 2;

    cout << sum << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define endl     "\n"
#define pb       push_back
#define fastio   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll       long long
#define all(v)   v.begin(),v.end()
ll sum[1000000+10]={};
int main()
{
    ll n, a , b, i, j;
    ll total=0,l,r;
    sum[0]=0;
    for(i=1;i<1000005;i++)
    {
        sum[i]=sum[i-1]+i;
    }
    cin>>n;

    while(n--)
    {
        cin>>l>>r;
        total=total+sum[r]-sum[l-1];
        //cout<<total<<endl;

    }
    cout<<total<<endl;

}


#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }

template<ll mod> struct mint {
    ll x;
    mint(ll a = 0): x((a + mod) % mod) { }
    mint operator+(mint a) { return mint(*this) += a; }
    mint operator-(mint a) { return mint(*this) -= a; }
    mint operator*(mint a) { return mint(*this) *= a; }
    mint operator/(mint a) { return mint(*this) /= a; }
    mint& operator+=(mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(mint a) { (x *= a.x) %= mod; return *this; }
    mint& operator/=(mint a) { return *this *= a.inv(); }
    mint pow(ll t) { mint a = x, ret = 1; while (t) { if (t & 1) ret *= a; a *= a; t >>= 1; } return ret; }
    mint inv() { return pow(mod - 2); }
    friend istream& operator>>(istream& is, mint& a) { return is >> a.x; }
    friend ostream& operator<<(ostream& os, mint& a) { return os << a.x; }
};

struct UnionFind {
    vi p;
    UnionFind(int n): p(n, -1) { }
    int root(int x) { if (p[x] < 0) return x; else return p[x] = root(p[x]); }
    int size(int x) { return -p[root(x)]; }
    void unite(int x, int y) {
        int rx = root(x), ry = root(y);
        if (rx == ry) return; if (p[rx] > p[ry]) swap(rx, ry);
        p[rx] += p[ry]; p[ry] = rx;
    }
};

int main() {
  int N;

  cin >> N;

  if (N % 2 == 0) {
    prt("White");
  } else {
    prt("Black");
  }
  return 0;
}

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

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

int n;

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

cin>>n;

if(n%2)
cout<<"Black\n";

else
cout<<"White\n";

return 0;
}


///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           nd(a,b,c)                   mp(mp(a,b),c)
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=2e18;
const int mod=1e9+7;
const int M=100005;

void solve()
{
   int a,b,c,d,z;
   cin>>a>>b>>c>>d;

   int hor=c*d-b;

   if(hor==0)
   {
       cout<<"-1\n";return ;
   }
   z=(a+hor-1)/hor;

   int cyan=z*b+a;
   int red=z*c*d;
   if(cyan>red)
   {
       cout<<"-1\n";return ;
   }
   cout<<z<<"\n";
}

 main()

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

}

 #include <bits/stdc++.h>
using namespace std;
using ll = long long;
//素数判定　O√N
bool is_prime(long long x)
{
  assert(0<=x);
  if(x<2)
  {
    return false;
  }
  for(long long i=2;i*i<=x;i++)
  {
    if(x%i==0)
    {
      return false;
    }
  }
  return true;
}
template<class T> void chmin(T& a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T& a,T b){
    if(a<b){
        a=b;
    }
}
//約数列挙
vector<ll> enumeration_divisor(ll n){
  vector<ll> res_divisor;
  for(ll i=1;i<=sqrt(n);i++){
    if(n%i==0){
      res_divisor.push_back(i);
      if(i*i!=n){
        res_divisor.push_back(n/i);
      }
    }
  }
  sort(res_divisor.begin(),res_divisor.end());
  return res_divisor;
}
using Graph = vector<vector<ll>>;

vector<bool> seen;
void dfs(const Graph &G, ll v){
    seen[v] = true; //vを訪問済みにする
    //vからいける各頂点next_vについて
    for(auto next_v : G[v]){
        if(seen[next_v]==true) continue; //next_vが探索済みだったらスルー
        dfs(G, next_v); //再帰的に探索
    }
}
template<typename T,typename U>
T power(T a,U n){
  T res=1;
  while(n){
    res*=(n&1)?a:1;
    a*=a;
    n>>=1;
  }
  return res;
}
const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
std::vector<int> Eratosthenes( const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}
bool flag[100010];
mint dp[100010];
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a==0) cout << 0 << endl;
  else if(b>=c*d) cout << -1 << endl;
  else{
    bool p=true;
    ll red=0,cnt=0;
    while(p==true){
      a+=b;
      red+=c;
      cnt++;
      if(a<=red*d){
        cout << cnt << endl;
        p=false;
      }
    }
  }
}


#include"bits/stdc++.h"
using namespace std;
#define ri register int
#define ll long long
#define N 2010
int n,a[N],mn=0x3f3f3f3f;
inline int get_gcd(int x,int y){
    return !y?x:get_gcd(y,x%y);
}
unordered_map<int,int>vis;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(ri i=1;i<=n;++i){
        cin>>a[i];mn=min(mn,a[i]);
    }
    for(ri i=1;i<=n;++i){
        for(ri j=1;j*j<=a[i]&&j<=mn;++j){
            if(a[i]%j==0){
                //cout<<a[i]<<" "<<j<<endl;
                vis[j]=get_gcd(a[i],vis[j]);
                if(a[i]/j<=mn) vis[a[i]/j]=get_gcd(vis[a[i]/j],a[i]);
            }
        }
    }
    int ans=0;
    for (auto x : vis)
    if (x.first == x.second) ans++;
    cout<<ans;
    return 0;
}

#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

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

map<int, vi > M;
map<int, vi >::iterator it;

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

int main() {
  int n;
  S(n);

  int mn = 1000000000;
  rep(i,1,n+1) {
    int x;
    S(x);
    mn = min(mn, x);
    for(int j = 1; j * j <= x; j++) if(x % j == 0) {
      M[j].pb(x);
      if(j * j != x) M[x / j].pb(x);
    }
  }

  int ans = 0;
  for(it = M.begin(); it != M.end(); it++) {
    if(it->FF > mn) break;
    int g = 0;
    rep(i,0,it->SS.size()) {
      g = gcd(it->SS[i], g);
    }
    ans += g == it->FF;
  }
  P(ans);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i)
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 5e18;
map<int,int> mp;
void solve()
  {
   int num = 3,p = 1;
   while(num <= 1e18)
     {
      mp[num] = p;
      num *= 3;
      p++;
     }
   int n;
   cin>>n;
   num = 5;
   p = 1;
  while(num < n)
     {
      if(mp[n - num])
         {
          cout<<mp[n - num]<<" "<<p;
          return;
         }
      num *= 5;
      p++;
     }
      cout<<-1;
  }
int32_t main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
   /*int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long N;
  cin >> N;
  long long X = 5;
  long long A = -1;
  long long B;
  for (B = 1; B <= 10000 && X < N; B++) {
    long long M = N - X;
    if (M % 3 == 0 && (M & 1)) {
      A = 0;
      while (M % 3 == 0) M /= 3, A++;
      if (M == 1) {
        break;
      }
      A = -1;
    }
    X *= 5;
  }
  if (A == -1)
    cout << -1 << '\n';
  else
    cout << A << " " << B << '\n';
  return 0;
}


#include <bits/stdc++.h>

#define ms(a,b) memset(a, b, sizeof(a))
#define rep(a,b,c) for(int a = (int)(b); a < (int)(c); a++)
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define m_p(a,b) make_pair(a, b)
#define lson l,mid,o << 1
#define rson mid + 1,r,o << 1 | 1
#define ls o << 1
#define rs o << 1 | 1
#define inf 0x3f3f3f3f

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

inline bool isdigit(char& ch) {
	return ch >= '0' && ch <= '9';
}
template<class T>
void read(T &x) {
	x = 0;
	ll f = 1;char ch = getchar();
	for (;!isdigit(ch);ch = getchar())
		if (ch == '-') f = -1;
	for (; isdigit(ch);ch = getchar())
		x = (x << 1) + (x << 3) + ch - '0';
	x *= f;
}
template<class T>
inline void write(T x) {
	if (x == 0) {putchar('0');return ;}
	if (x < 0) {putchar('-');x = -x;}
	int _stk[65],_top = 0;
	for (;x;x /= 10) _stk[++_top] = x % 10 + 48;
	for (;_top;_top--)putchar(_stk[_top]);
}

namespace Union {
	vector<int>fa;
	void Assign(int n) {
		fa.assign(n, -1);
	}
	int root(int x) {
		if (fa[x] < 0)
			return x;
		return fa[x] == x ? fa[x] : fa[x] = root(fa[x]);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void merge(int x, int y) {
		fa[root(x)] = root(y);
	}
}

using namespace Union;

int main () {
	int n;

	using P = pair<db, db>;
	using Edge = pair<db, pair<int, int>>;

	vector<P>pint;
	cin >> n;
	pint.resize(n);
	for (auto &[x, y] : pint)
		cin >> x >> y;
//	cout << pint.size();
	Assign(n + 2);
	int S  = n, T = n + 1;
	auto calc = [&](P a, P b) {return sqrt((a.fi-b.fi) * (a.fi-b.fi) + (a.se-b.se)*(a.se-b.se));};

	vector<Edge>edge;
	for (int i = 0; i < pint.size(); ++i) {
		edge.push_back({100+pint[i].se, {S, i}});
		edge.push_back({100-pint[i].se, {T, i}});
		for (int j = i + 1; j < pint.size(); ++j) {
			edge.pb({calc(pint[i], pint[j]), {i, j}});
		}
	}
	sort(edge.begin(), edge.end());
	db res = 0;
	for (auto E : edge) {
		merge(E.se.fi, E.se.se);
	//	cout << E.se.fi << " " << E.se.se << " " << E.fi<<endl;
		if (same(S, T)) {
			res = E.fi / 2.0;
			break;
		}
	}
	cout << fixed << setprecision(10) << res << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];

    vector<ll> aa(n);
    rep(i,0,n) aa[i] = a[i]*a[i];
    vector<ll> aarec(n);
    aarec[0] = aa[0];
    rep(i,1,n) aarec[i] = aarec[i-1] + aa[i];
    vector<ll> arec(n);
    arec[0] = a[0];
    rep(i,1,n) arec[i] = arec[i-1] + a[i];

    ll ans = 0;
    rep(i,2,n+1) ans += (i - 1)*aa[i - 1];
    rep(i,0,n-1) ans += aarec[i];
    rep(i,2,n+1) ans -= 2*a[i - 1]*arec[i - 2];
    cout << ans << endl;
}


#include <iostream>
using namespace std;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	cout<<a-b+c;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 100
#define THOU 1000
#define FIVEMAX 100000
#define NINEMAX 1000000000
#define TWEMAX 1000000000000
#define rep(i,n) for (int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define darep(i,a,n) for(int i=n;i>=a;i--)
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;}
const ll INF=1LL<<60;
#define yn {puts("Yes");}else{puts("No");}

int main(){
  int n,a,b;
  int ans;
  cin>>n>>a>>b;

  ans=n-a+b;

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


#include <cstdio>
#include <cstring>
#include <algorithm>
#define reg register
typedef long long ll;
const int N=1400;
ll f[N]={0,1},n,x,y;
ll g[N][2];
int st[N],opt[N],tot,top;
ll R()
{
	reg ll x=0; reg bool f=0; reg char ch=getchar();
	for(;ch<48||ch>57;ch=getchar()) f|=(ch=='-');
	for(;ch>=48&&ch<=57;ch=getchar()) x=x*10+ch-48;
	return f?-x:x;
}
int main() {
	n=R();
	if(n==1) return puts("1\n1"),0;
	reg int p=1,i;
	reg bool now=0;
	while(1) {
		f[p+1]=f[p]+f[p-1];
		if(f[p+1]>n) break;
		++p;
	}
	for(i=p;i;--i)
		if(n>=f[i]) n-=f[i],st[++top]=i;
		/*
		now=0,x=0,y=1,plan to do x=x+y
		now=1,x=1,y=0,plan to do y=x+y
		*/
	x=0,y=1;
	for(i=1;i<=p+2;++i) {
		(i&1)?x=x+y:y=x+y;
		g[i][0]=x;
	}
	g[0][1]=x=1,y=0;
	for(i=1;i<=p+2;++i) {
		(i&1)?y=x+y:x=x+y;
		g[i][1]=x;
	}
	for(i=0;top;++i) {
		now^=1;
		if(g[i][now]==f[st[top]]) opt[++tot]=2-now,--top;
		opt[++tot]=4-now;
	}
	while(opt[tot]>=3) --tot;
	printf("%d\n",tot);
	x=y=0;
	for(i=tot;i;--i) {
		printf("%d\n",opt[i]);
	/*	if(opt[i]==1) ++x;
		if(opt[i]==2) ++y;
		if(opt[i]==3) x=x+y;
		if(opt[i]==4) y=x+y; */
	}
//	printf("end:%lld %lld\n",x,y);
}

/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     vi          vector<int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

void solve(){
    ll n;
    cin>>n;
    int cnt=0;
    while(n%2==0) n/=2,cnt++;
    if(!cnt) cout<<"Odd\n";
    else if(cnt==1) cout<<"Same\n";
    else cout<<"Even\n";
}

signed main(){
    FastIO;
    int t;
    cin>>t;
    while(t--) solve();
    return 0;
}