# include <bits/stdc++.h>
# ifndef ngng628_library
# define ngng628_library
# define int long long
# define float long double
# define fi first
# define se second
# define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++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 repr(i,b,e) for(int i=(b), i##_len=(e); i<i##_len; ++i)
# define reprs(i,b,e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define all(x) std::begin(x), std::end(x)
# define rall(x) std::rbegin(x), std::rend(x)
# define pb push_back
# define eb emplace_back
# define len(x) ((int)(x).size())
# define contains(x,key) ((x).find(key) != (x).end())
# define lb(v,x) distance(std::begin(v), lower_bound(all(v), (x)))
# define ub(v,x) distance(std::begin(v), upper_bound(all(v), (x)))
using namespace std;
template<class T> using vec = vector<T>;
using pii = pair<int, int>;
using vi = vec<int>;
using vb = vec<bool>;
using vvb = vec<vb>;
using vvvb = vec<vvb>;
using vs = vec<string>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
constexpr int INF = (1LL<<62)-(1LL<<31);
constexpr float EPS = 1e-10;
template<class T> istream& operator>>(istream& is, vec<T>& v) { for (auto& x : v) is >> x; return is; }
template<class T, class U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.fi >> p.se; }
template<class T> T scan() { T ret; cin >> ret; return ret; }
template<class T> string join(const vec<T> &v){ stringstream s; rep (i, len(v)) s<<' '<<v[i]; return s.str().substr(1); }
template<class T> ostream& operator<<(ostream& os, const vec<T>& v){ if (len(v)) os << join(v); return os; }
template<class T> ostream& operator<<(ostream& os, const vec<vec<T>>& v){ rep (i, len(v)) { if (len(v[i])) os << join(v[i]) << (i-len(v)+1 ? "\n" : ""); } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ cout << p.fi << " " << p.se; return os; }
void print(){ cout << "\n"; }
template<class T, class... A>void print(const T& v, const A&...args){cout << v; if(sizeof...(args))cout << " "; print(args...);}
void eprint() { cerr << "\n"; }
template<class T, class... A>void eprint(const T& v, const A&...args){cerr << v; if(sizeof...(args))cerr << " "; eprint(args...);}
void drop(){ cout << "\n"; exit(0); }
template<class T, class... A>void drop(const T& v, const A&...args){cout << v; if(sizeof...(args))cout << " "; drop(args...);}
template<class T> inline constexpr bool chmax(T &a, const T& b) { return a < b && (a = b, true); }
template<class T> inline constexpr bool chmin(T &a, const T& b) { return a > b && (a = b, true); }
constexpr int ctoi(const char c) { return ('0' <= c and c <= '9') ? (c - '0') : -1; }
const char* yn(bool b) { return b ? "Yes" : "No"; }
# endif  // ngng628_library

struct Edge {
   Edge() = default;
   Edge(int t, int w, int k) : to(t), weight(w), K(k) {}
   int to, weight, K;
};
using Graph = vec<vec<Edge>>;

vi dijkstra(const Graph& graph, int start) {
   vi dist(len(graph), INF);
   priority_queue<pii, vec<pii>, greater<pii>> pq; // {dist, to}
   dist[start] = 0;
   pq.emplace(dist[start], start);
   while (not pq.empty()) {
      auto [d, now] = pq.top(); pq.pop();
      if (dist[now] < d) continue;
      for (auto& edge : graph[now]) {
         int loss = (-dist[now] % edge.K + edge.K) % edge.K;
         int cost = dist[now] + loss + edge.weight;
         if (chmin(dist[edge.to], cost)) {
            pq.emplace(cost, edge.to);
         }
      }
   }
   return dist;
}

int32_t main() {
   int n, m, x, y;
   cin >> n >> m >> x >> y;
   x--; y--;
   Graph g(n);
   rep (i, m) {
      int a, b, t, k;
      cin >> a >> b >> t >> k;
      a--; b--;
      g[a].eb(b, t, k);
      g[b].eb(a, t, k);
   }
   auto d = dijkstra(g, x);
   print(d[y] < INF ? d[y] : -1);
}

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

void solve() {
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  eprintf("%d\n%s\n%s\n%s\n", n, a.c_str(), b.c_str(), c.c_str());
  a = a + a;
  b = b + b;
  c = c + c;
  auto test_one = [](const string& a, const string& b) {
    int pt = 0;
    for (char c : a) {
      if (b[pt] == c) pt++;
      if (pt == (int)b.size()) return true;
    }
    return false;
  };
  auto test = [&](const string &t) {
    return test_one(a, t) && test_one(b, t) && test_one(c, t);
  };

  for (char c1 = '0'; c1 <= '1'; c1++) {
    for (char c2 = '0'; c2 <= '1'; c2++) {
      for (char c3 = '0'; c3 <= '1'; c3++) {
        string cand = string(n, c1) + c2 + string(n, c3);
        if (test(cand)) {
          printf("%s\n", cand.c_str());
          return;
        }
        cand = string(n, c1) + string(n, c3) + c2;
        if (test(cand)) {
          printf("%s\n", cand.c_str());
          return;
        }
        cand = c2 + string(n, c1) + string(n, c3);
        if (test(cand)) {
          printf("%s\n", cand.c_str());
          return;
        }
      }
    }
  }
  assert(false);
}

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  int t;
  cin >> t;
  while (t-->0) {
    solve();
  }

  return 0;
}


/**
*    author:
*    created: 26.10.2020 13:52:11
**/

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

int main() {

     ll n;
   cin >> n;
   vector <ll> a(n),b(n+1,0),c(n+1,0),d(n);

   rep(i,n){
       cin >> a.at(i);
       //pq.push(a.at(i));
     if(i==0)
       d.at(i)=a.at(i);
     else
       d.at(i)=max(d.at(i-1),a.at(i));
   }

  rep(i,n){
    b.at(i+1)=b.at(i)+a.at(i);
    c.at(i+1)=c.at(i)+b.at(i+1);
  }

  rep(i,n){
    //cout << b.at(i) <<' '<< c.at(i) <<' '<< d.at(i) << endl;
    cout << d.at(i)*(i+1)+c.at(i)+b.at(i+1) << endl;
  }

}

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

long long N;
long long A[200000];
long long Max[200000] = { 0 };
long long _Max = 0;
long long A0_k = 0;
long long ans = 0;

int main(){
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (_Max < A[i]) {
			_Max = A[i];
		}
		Max[i] = _Max;
	}
	for (int i = 0; i < N; i++) {
		A0_k += A[i];
		ans += A0_k;
		cout << ans + Max[i] * (i + 1) << endl;
	}
}


#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <math.h>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
#include <time.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define PI 3.141592653589793

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

/*clock_t start = clock();
clock_t end = clock();
const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
printf("%lf", time);*/

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int par[1000000];

void init(int N){
    rep(i,N) par[i] = -1;
}

int find(int a){
    if(par[a] < 0) return a;
    else{
        return par[a] = find(par[a]);
    }
}

void unite(int a, int b){
    a = find(a);
    b = find(b);
    if(a == b) return;
    else{
        if(par[a] > par[b]) swap(a,b);
        par[a] += par[b];
        par[b] = a;
    }
}

int size(int A) {
     return -par[find(A)];
}

bool same(int a, int b){
    return find(a) == find(b);
}

int main(){
    int N,M;
    cin >> N >> M;
    init(N);
    vector<ll> a(N),b(N);
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    rep(i,M){
        int c,d;
        cin >> c >> d;
        c--;d--;
        unite(c,d);
    }
    map<int,vector<int>> group;
    rep(i,N){
        group[find(i)].push_back(i);
    }
    bool flag = true;
    for(auto g:group){
        auto v = g.second;
        ll A = 0;
        ll B = 0;
        for(auto u:v){
            A += a[u];
            B += b[u];
        }
        if(A != B) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

#include<bits/stdc++.h>

using namespace std;

const int maxN = 200009;
int N, M, a[maxN], b[maxN];
bool ap[maxN];
long long sumA, sumB;
vector < int > v[maxN];

void dfs (int nod)
{
    ap[nod] = 1, sumA += a[nod], sumB += b[nod];
    for (auto it : v[nod])
        if (!ap[it])
            dfs (it);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]);
for (int i=1; i<=N; i++)
    scanf ("%d", &b[i]);
while (M --)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    v[x].push_back (y);
    v[y].push_back (x);
}
for (int i=1; i<=N; i++)
    if (ap[i] == 0)
    {
        sumA = 0, sumB = 0, dfs (i);
        if (sumA != sumB)
        {
            printf ("No\n");
            return 0;
        }
    }
printf ("Yes\n");
return 0;
}


#include <bits/stdc++.h>
///#pragma GCC target ("sse4.2")

///#pragma GCC opimize("O1")
///#pragma GCC opimize("O2")

///#pragma GCC opimize("Os")
///#pragma GCC opimize("Ofast")
///#pragma GCC target("avx,avx2,fma")
///#pragma GCC target("avx2")

///#pragma GCC opimize("O3")
///#pragma GCC opimization ("unroll-loops")

using namespace std;

bool home = 1;
typedef long long ll;
typedef long double ld;
#define int ll
signed realMain();

signed main() {
#ifdef ONLINE_JUDGE
  home = 0;
#endif
  if (home) {
    freopen ("tony_stark", "r", stdin);
  } else {
    ios::sync_with_stdio(0); cin.tie(0);
  }
  realMain();
}

const int M = (int) 1e9 + 7;
int n, mod;

signed realMain() {
  cin >> n >> mod;
  if (mod == 0) {
    cout << (n == 1) << "\n";
    return 0;
  }
  int ret = mod - 1, b = n - 1, a = mod - 2;
  while (b) {
    if (b & 1) {
      ret = (ll) ret * a % M;
    }
    b /= 2;
    a = (ll) a * a % M;
  }
  cout << ret << "\n";
  return 0;
}


#include <iostream> // cout, endl, cin
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <vector> //vector
using namespace std;
#define _LIBCPP_DEBUG 0
#define rep(i, n) for(int i = 0; i < (int)n; i++)
typedef long long ll;

string ans;

ll conbi(int s, int a){
    ll cans = 1;
    vector<int> v;
    rep(i, a) v.push_back(a - i);
    rep(i, a){
        cans *= s;
        for(auto it = v.begin(); it != v.end();){
            if(cans % *it == 0){
                cans /= *it;
                it = v.erase(it);
            }else{
                ++it;
            }
        }
        s--;
    }
    return cans;
}

void dfs(int a, int b, ll k){
    if(a == 0){
        rep(i, b) ans.push_back('b');
        return;
    }
    if(b == 0){
        rep(i, a) ans.push_back('a');
        return;
    }

    a--;
    int s = a + b;
    ll buf = conbi(s, min(a, b));
    //cout << "s : " << s << " buf : " << buf << " k : " << k;
    if(buf < k){
        //cout << " choice : b" << endl;
        ans.push_back('b');
        dfs(a+1, b-1, k-buf);
    }else{
        //cout << " choice : a" << endl;
        ans.push_back('a');
        dfs(a, b, k);
    }
}

int main(){
    int a, b;
    ll k;
    cin >> a >> b >> k;
    dfs(a, b, k);

    cout << ans << endl;
}

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

ll mod = 1000000007;

int main() {
    ll N; cin >> N;
    vector<Pr> s,t;
    string ans = "No";
    rep(i,N){
        ll x,y; cin >> x >> y;
        s.push_back(make_pair(x,y));
    }
    rep(i,N){
        ll x,y; cin >> x >> y;
        t.push_back(make_pair(x,y));
    }
    if(N==1){
        cout << "Yes" << endl; return 0;
    }
    ll dx = s[1].first - s[0].first;
    ll dy = s[1].second - s[0].second;
    double th1 = atan2(dy,dx);
    rep(i,N){
        rep(j,N){
            ll dx2 = t[j].first - t[i].first;
            ll dy2 = t[j].second - t[i].second;
            double th2 = atan2(dy2,dx2);
            if(dx*dx+dy*dy!=dx2*dx2+dy2*dy2) continue;
            set<Pr> pts;
            rep(k,N){
                pts.insert(s[k]);
            }
            rep(k,N){
                ll dx3 = t[k].first - t[i].first;
                ll dy3 = t[k].second - t[i].second;
                double ndx = dx3*cos(th1-th2) - dy3*sin(th1-th2);
                double ndy = dy3*cos(th1-th2) + dx3*sin(th1-th2);
                if(abs(round(ndx)-ndx)>=0.05) continue;
                if(abs(round(ndy)-ndy)>=0.05) continue;
                pts.erase(make_pair(s[0].first+round(ndx),s[0].second+round(ndy)));
            }
            if(pts.empty()){
                ans = "Yes"; //cout << i << " " << j << endl;
            }
        }
    }
    cout << ans << endl;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	long long C;
	cin >> N >> C;
	vector<int> a(N), b(N), c(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i] >> b[i] >> c[i];
	}

	vector<int> d;
	for (int i = 0; i < N; ++i) {
		d.push_back(a[i] - 1);
		d.push_back(b[i]);
	}
	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());

	const int D = d.size();

	vector<long long> acc(D + 1, 0LL);

	for (int i = 0; i < N; ++i) {
		auto it_a = lower_bound(d.begin(), d.end(), a[i] - 1);
		auto it_b = lower_bound(d.begin(), d.end(), b[i]);

		acc[it_a - d.begin()] += c[i];
		acc[it_b - d.begin()] -= c[i];
	}

	for (int i = 0; i < D; ++i) {
		acc[i + 1] += acc[i];
	}

	long long ans = 0;
	for (int i = 0; i + 1 < D; ++i) {
		ans += min(C, acc[i]) * (d[i + 1] - d[i]);
	}
	cout << ans << endl;
}

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

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    ll n, c;
    cin >> n >> c;
    map<ll, vector<ll>> mp;
    rep(i, n) {
        ll a, b, c;
        cin >> a >> b >> c;
        mp[a].push_back(c);
        mp[b + 1].push_back(-c);
    }
    ll ans = 0;
    ll sum = 0;
    ll now = 1;
    ll prev = now;
    for (auto e : mp) {
        now = e.first;
        ans += min(sum, c) * (now - prev);
        rep(i, e.second.size()) sum += e.second[i];
        prev = now;
    }
    cout << ans << endl;
}


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

/*
find my code templates at https://github.com/galencolin/cp-templates
also maybe subscribe please thanks
*/

#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}

typedef long long ll;
// typedef int ll;
// #pragma warning("int")

typedef long double lld;
typedef unsigned long long ull;

template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
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 << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}

mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 rng(61378913);
/* usage - just do rng() */

void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}

// #include <atcoder/all>
// using namespace atcoder;

const lld pi = 3.14159265358979323846;
// const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;

ll n, m, q, k, l, r, x, y, z;
const ll template_array_size = 1e6 + 15258;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;

void solve(int tc = 0) {
	ll ans = 1e10;
	cin >> n;
	for (ll i = 0; i < 62; i++) {
		ll v = (1LL << i);
		ans = min(ans, i + (n / v) + (n % v));
	}
	cout << ans << '\n';
}

int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif

	send help

	#ifndef galen_colin_local
		// usaco("code");
	#endif

	// usaco("cowland");

	// freopen("tc.cpp", "r", stdin);
	// freopen("tc2.cpp", "w", stdout);

	cout << setprecision(15) << fixed;

	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);

	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cerr << setprecision(4) << fixed;
		cerr << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
}

#include<bits/stdc++.h>
using namespace std;
bool vis[12];
long long ans=1;
int main(){
	int n;
	cin>>n;
	for(int i=n-1;i>=n-11;i--){
		ans*=i;
		for(int j=11;j>=2;j--){
			if(ans%j==0 && !vis[j]){
				vis[j]=true;
				ans/=j;
			}
		}
	}
	cout<<ans;
	return 0;
}


#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
# include <iostream>
# include <array>
# include <string>
# include <vector>
# include <algorithm>
# include <functional>
# include <cmath>
# include <iomanip>
# include <stack>
# include <queue>
# include <numeric>
# include <map>
# include <set>
# include <unordered_map>
# include <unordered_set>
# include <chrono>
# include <random>
# include <bitset>
# include <cassert>
# include <climits>

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

#define rep2(i,t,n) for (int i = (t); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

using namespace std;
typedef long long ll;

int t;
ll n;

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

  double cand = ((long double)n * 100 / t) + n;
  ll candL = (ll)cand;

  ll ans = candL;

  if(abs(cand - (long double)candL) < 0.000001L) {
    ans--;
  }

  cout << ans << endl;
  //printf("%10f", cand);

  return 0;
}

#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#endif
#if __has_include(<atcoder/all>)
#include <atcoder/all>
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
#define rep(i, a, b) for(int i = (int)(a); i <= (int)(b); i++)
#define rrep(i, a, b) for(int i = (int)(a); i >= (int)(b); i--)
const int MOD = 1000000007;
const int MOD2 = 998244353;
const ll INF = 1e18;
const ld PI = acos(-1);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> A(N+1);
    rep(i,0,N){
        cin >> A[i];
    }
    int diff=1e9;
    rep(i,0,N-1){
        diff=min(diff,abs(A[i]-A[i+1]));
    }
    cout << diff << endl;
    rep(i,0,diff-1){
        rep(j,0,N){
            cout << A[j]/diff << (j==N?'\n':' ');
            A[j]++;
        }
    }
}


#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
using namespace std;

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

        ll i, j, k, n, temp, count = 0, ans = 0, sum = 0;
        cin >> n;
        ll a[n], b[n];

        for(i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        for(i = 0; i < n; i++)
        {
            cin >> b[i];
            ans += a[i] * b[i];
        }

        if(ans == 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }

return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    cin>>n;
    vector<ll> arr(n+1);
    ll m=0, c=-1;
    double e=0;
    for(ll i=0;i<=n;i++)
    {
        cin>>arr[i];
        m+=abs(arr[i]);
        e+=(arr[i]*arr[i]);
        c=max(c, abs(arr[i]));
    }

    e=sqrt(e);
    cout<<m<<endl;
    cout<<setprecision(10)<<e<<endl;
    cout<<c<<endl;

}


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

int main() {

	int x;
	cin >> x;
	cout << 100 - x % 100 << '\n';
	return 0;
}

#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>

using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int X;
signed main(){
    scanf("%lld",&X);
    int ans=(int)(X/100+1)*100-X;
    printf("%lld\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"

void solve(int test)
{
   ll n,m;
   cin>>n>>m;
   ll mod = 998244353;

   ll power[n+1];
   power[0] = 1;
   ll i;
   for(i=1;i<=n;i++)power[i] = (1LL*power[i-1]*m)%mod;

   ll ans = (1LL*n*power[n])%mod;
   ll sub = 0;

   for(ll x=1;x<=m;x++)
   {
       ll curr = 1;
       ll r=m-x;
       for(ll diff = 1;diff<=n-1;diff++)
       {
           ll rem = n-diff-1;
           ll val = ((rem+1)*power[rem])%mod;
           val  = (val*curr)%mod;
           sub = (sub + val)%mod;
           curr = (curr*r)%mod;
       }
   }
   ans = (ans -sub)%mod;
   if(ans<0)ans += mod;
   cout<<ans<<endl;

}

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

  for(int x = t;x<=t;x++)
    solve(x);

  return 0;
}

/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
const int COMBINATION_SIZE = 1<<21;
LL pp[5001][5001];
int N,M;
void pre() {
    pp[0][0]=1;
    FOR(i,1,5000){
        pp[i][0]=1;
        FOR(j,1,5000){
            pp[i][j]=(LL)pp[i][j-1]*i%MOD;
        }
    }
}
void solve() {
    LL an=0;
    FOR(i,1,N){
        FOR(j,1,M){
            if(j<M||(j==M&&i==1)){
                ADD(an,pp[M-j][i-1]*(j-1)%MOD*(N-i)%MOD*pp[M][N-i-1]);
                ADD(an,pp[M-j][i-1]*pp[M][N-i]);
            }
        }
    }
    W(an);
}
void input() {
    R(N,M);
}
int main(){
    MOD=998244353;
    pre();
    input();
    solve();
    return 0;
}


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

vector<ll> table;

int main() {
    ll N, K; cin >> N >> K;
    table.resize(2 * N+1, 0);
    ll l = max(K + 2, 2ll), r = min(K + 2 * N, 2 * N);

    for (ll i = 2; i <= 2 * N; i++) {
        // a + b = iになる組み合わせ数をtableに格納する
        ll cnt = 0;
        cnt += min(N, i-1) - max(1ll, i - N) + 1;
        //cout << "i: " << i << " cnt: " << cnt << endl;
        table[i] = cnt;
    }

    ll cnt = 0;
    for (ll i = l; i <= r; i++) {
        cnt += table[i] * table[i - K];
    }
    cout << cnt << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}
template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

template<typename Monoid>
struct SegmentTree{
    int sz;
    vector<Monoid> seg;
    Monoid M0;// モノイドの元
    using F=function<Monoid(Monoid,Monoid)>;
    F f;
    SegmentTree(int n,Monoid M0,F f):M0(M0),f(f){
        sz=1;
        while(sz<n)sz<<=1;
        seg.assign(2*sz,M0);
    }
    void set(int k,Monoid x){
        seg[k+sz]=x;
    }
    void build(){
        for(int k=sz-1;k>0;k--) seg[k]=f(seg[2*k],seg[2*k+1]);
    }
    void update(int k,Monoid x){
        k+=sz;
        seg[k]=x;
        k>>=1;
        for(;k;k>>=1) seg[k]=f(seg[2*k],seg[2*k+1]);
    }
    Monoid query(int a,int b,int k=1,int l=0,int r=-1){
        if(r==-1) r=sz;
        if(a<=l and r<=b)   return seg[k];
        if(b<=l or r<=a)    return M0;
        Monoid L=query(a,b,2*k,l,(l+r)/2);
        Monoid R=query(a,b,2*k+1,(l+r)/2,r);
        return f(L,R);
    }
};

signed main(){
    int n;cin>>n;
    vector<int> a(n);
    cin>>a;
    SegmentTree<ll> seg(n,0ll,[](ll a,ll b){return a+b;});
    ll inv=0;
    vector<int> v(n,0);
    rep(i,n){
        ll x=seg.query(a[i],n);
        v[i]=x;
        inv+=x;
        seg.update(a[i],1);
    }

    cout<<inv<<endl;
    rep(i,n-1){
        inv+=n-a[i]-1;
        inv-=a[i];
        cout<<inv<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std;

void no() { cout << "-1" << endl; }

int main() {
    int n; cin >> n;
    string s, t; cin >> s >> t;
    long long ans = 0;
    int i = 0, j = 0;
    while (j < n) {
        if (t[j] == '1') {
            while (i < n && s[i] == '0') i++;
            if (i == n) { no(); return 0; }
            if (i < j) {
                int i2 = i + 1;
                while (i2 < n && s[i2] == '0') i2++;
                if (i2 == n) { no(); return 0; }
                ans += i2 - i;
                i = i2 + 1;
            } else {
                ans += i - j;
                i++; j++;
            }
        } else {
            j++;
        }
        // cerr << i << ' ' << j << ' ' << ans << endl;
    }
    while (i < n) {
        if (s[i] == '0')  { i++; }
        else {
            int k = i + 1;
            while (k < n && s[k] == '0') k++;
            if (k == n) { no(); return 0; }
            ans += k - i;
            i = k + 1;
        }
        // cerr << i << ' ' << j << ' ' << ans << endl;
    }
    cout << ans << endl;
}


// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-15;
const long double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
long long PW[5100][5100];
int main(){
	for(int i=0;i<5100;i++){
		long long cur=1;
		for(int j=0;j<5100;j++){
			PW[i][j]=cur;
			cur=cur*i%mod;
		}
	}
	int a,b;scanf("%d%d",&a,&b);
	init_C(210000);
	long long ret=0;
	for(int i=1;i<a-1;i++){
		for(int j=1;j<b;j++){
			long long ks=2*j-1;
			ks=ks*PW[b-j][i]%mod;
			ks=ks*(a-i-1)%mod;

			ks=ks*PW[b][a-i-2]%mod;
			ret=(ret+ks)%mod;
			// printf("%d %d: %lld\n",i,j,ks);
		}
	}

	for(int i=1;i<a;i++){
		for(int j=1;j<b;j++){
			long long ks=2;
			ks=ks*PW[b-j][i]%mod;
			ks=ks*PW[b][a-i-1]%mod;
			ret=(ret+ks)%mod;
			// printf("%d %d: %lld\n",i,j,ks);
		}
	}
	ret=(ret+PW[b][a])%mod;
	printf("%lld\n",ret);
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define debug(a) { cerr << #a << ": " << a << endl; }
#define endl '\n'
#define fi first
#define se second
using lint = long long;
using P = pair<int,int>;
template<class T> using V = vector<T>;
template<class T> using priq     = priority_queue<T>;
template<class T> using priq_inv = priority_queue<T, vector<T>, greater<T>>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
template<class T> T ceil(const T &a, const T &b) { return (a+b-1)/b; }
template<class T> bool chmin(T &a, T b) { if(a > b) { a = b; return 1; } return 0; }
template<class T> bool chmax(T &a, T b) { if(a < b) { a = b; return 1; } return 0; }
struct INF { template<class T> operator T() { return numeric_limits<T>::max() / 2; } } INF;

template<class T, class U> istream& operator>>(istream &in, pair<T,U> &p) {
    return in >> p.first >> p.second;
}
template<class T, class U> ostream& operator<<(ostream &out, const pair<T,U> &p) {
    return out << p.first << ' ' << p.second;
}
template<class T> istream& operator>>(istream &in, vector<T> &v) {
    for(auto &&e: v) in >> e;
    return in;
}
template<class T> ostream& operator<<(ostream &out, const vector<T> &v) {
    for(const auto &e: v) out << e << ' ';
    return out;
}

/*----------------------------------------------------------------------------------------------------*/

const lint mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    V<int> a(n);
    cin >> a;
    a.push_back(0);
    sort(all(a));
    lint ans = 1;
    Rep(i,n) {
        ans *= (a[i]-a[i-1]+1);
        ans %= mod;
    }
    cout << ans << endl;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#define setIO(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define closefile fclose(stdin), fclose(stdout)
#define m_p make_pair
#define sz(x) (int)x.size()
#define see(x) cerr << x << " "
#define seeln(x) cerr << x << endl
#define out(x) cerr << #x << " = " << x << " "
#define outln(x) cerr << #x << " = " << x << endl
#define outarr(x, l, r) {cerr<< #x"[" << l << " ~ " << r << "] = "; for (int _i = l; _i <= r; ++_i) cerr << x[_i] << " "; cerr << endl;}
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
#define gc() getchar()
//#define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf[1 << 21], *p1 = buf, *p2 = buf;
template <class T> void read(T &x)
{
    x = 0; int c = gc(); int flag = 0;
    while (c < '0' || c > '9') flag |= (c == '-'), c = gc();
    while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) +(c ^ 48), c = gc();
    if (flag) x = -x;
}
template <class T> T _max(T a, T b){return b < a ? a : b;}
template <class T> T _min(T a, T b){return a < b ? a : b;}
template <class T> bool checkmax(T &a, T b){return a < b ? a = b, 1 : 0;}
template <class T> bool checkmin(T &a, T b){return b < a ? a = b, 1 : 0;}
int a, b, c;
int qpow(int a, int b, int p)
{
    int ans = 1;
    a%=p;
    while (b)
    {
        if (b & 1) ans = (ll)ans * a % p;
        a = (ll)a * a % p;
        b >>= 1;
    }
    return ans;
}

void init()
{
    read(a); read(b); read(c);
}

void solve()
{
    printf("%d\n", qpow(a, qpow(b, c, 4) + 4, 10));
}

int main()
{
    init();
    solve();
    return 0;
}

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

int pow(int a, int n, int m){
  int ret = 1;
  while(n > 0){
    if(n & 1) (ret *= a) %= m;
    (a *= a) %= m;
    n >>= 1;
  }
  return ret;
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << pow(a % 10, pow(b % 4, c, 4) + 4, 10) << endl;
  return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define st first
#define nd second
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
template <class T> T read(T &a) {
    a=0;char x=getchar();bool f=0;
    for(;x<'0'||x>'9';x=getchar())f|=x=='-';
	for(;x>='0'&&x<='9';x=getchar())a=(a<<3)+(a<<1)+x-'0';
    if(f)a=-a;
    return a;
}
using namespace std;

LL MOD = 998244353;
const int N = 55;

int p[N];
LL d[N][N], cnt[N];
LL pre[N];

int find(int a) {
    return p[a] == a? a: p[a] = find(p[a]);
}

int main() {
    int n, m;
    read(n), read(m);
    pre[0] = 1;
    for (int i = 1; i <= 50; ++i) {
        pre[i] = pre[i - 1] * i % MOD;
        p[i] = i;
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            read(d[i][j]);
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 2; j <= n; ++j) {
            bool ok = 1;
            for (int k = 1; k <= n; ++k) {
                if (d[i][k] + d[j][k] > m) {
                    ok = 0;
                    break;
                }
            }
            if (ok) {
                int a = find(i), b = find(j);
                p[a] = b;
            }
        }
    }
    LL x = 1;
    for (int i = 1; i <= n; ++i) {
        cnt[find(i)]++;
    }
    for (int i = 1; i <= n; ++i) {
        x = x * pre[cnt[i]] % MOD;
    }
    for (int i = 1; i <= n; ++i) {
        p[i] = i;
    }
    memset(cnt, 0, sizeof cnt);
    for (int i = 1; i <= n; ++i) {
        for (int j = 2; j <= n; ++j) {
            bool ok = 1;
            for (int k = 1; k <= n; ++k) {
                if (d[k][i] + d[k][j] > m) {
                    ok = 0;
                    break;
                }
            }
            if (ok) {
                int a = find(i), b = find(j);
                p[a] = b;
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        cnt[find(i)]++;
    }
    for (int i = 1; i <= n; ++i) {
        x = x * pre[cnt[i]] % MOD;
    }
    printf("%lld\n", x);
	return 0;
}

#include <bits/stdc++.h>
#define SIZE 200005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct BIT
{
	int bit[SIZE];

	void init()
	{
		memset(bit,0,sizeof(bit));
	}
	void add(int k,int x)
	{
		k++;
		while(k<SIZE)
		{
			bit[k]+=x;
			k+=k&-k;
		}
	}
	int get(int k)
	{
		k++;
		int ret=0;
		while(k>0)
		{
			ret+=bit[k];
			k-=k&-k;
		}
		return ret;
	}
	int get(int s,int t)
	{
		return get(t)-get(s-1);
	}
	int pos(int k)
	{
		int l=-1,r=SIZE;
		while(r-l>1)
		{
			int m=(l+r)/2;
			if(get(m)<k) l=m;
			else r=m;
		}
		return r;
	}
}bit;

vector <int> vec[SIZE];
bool zan[SIZE];
int main()
{
	int n,m,k;
	scanf("%d %d %d",&n,&m,&k);
	int M=m;
	for(int i=0;i<k;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);x--,y--;
		vec[x].push_back(y);
		if(x==0) M=min(M,y);
	}
	bit.init();
	for(int i=0;i<M;i++)
	{
		bit.add(i,1);
		zan[i]=true;
	}
	bool vert=true;
	ll ret=0;
	for(int i=0;i<n;i++)
	{
		int mn=m;
		for(int j=0;j<vec[i].size();j++)
		{
			if(vec[i][j]==0) vert=false;
			mn=min(mn,vec[i][j]);
			if(zan[vec[i][j]])
			{
				bit.add(vec[i][j],-1);
				zan[vec[i][j]]=false;
			}
		}
		if(vert)
		{
			ret+=mn;
			ret+=bit.get(mn,m);
		}
		else ret+=bit.get(0,m);
	}
	printf("%lld\n",ret);
}


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

const int mod = 1000000007;
const int N = 101;

LL A[N][N], B[N][N], C[N][N];
int G[N][N];
int X[N];

LL _pow(LL a, LL b) {
  if(!b) return 1;
  if(b == 1) return a;
  if(b == 2) return a * a % mod;
  if(b & 1) {
    return a * _pow(a,b-1) % mod;
  }
  return _pow(_pow(a,b/2),2);
}

int n;
void solve(int k) {
  if(k == 0) {
    memset(B, 0, sizeof(B));
    rep(i,0,n) B[i][i] = 1;
    return;
  }
  solve(k / 2);
  memset(C, 0, sizeof(C));
  rep(i,0,n) {
    rep(j,0,n) {
      rep(k,0,n) {
        C[i][j] += B[i][k] * B[k][j];
        C[i][j] %= mod;
      }
    }
  }
  memcpy(B, C, sizeof(C));

  if(k & 1) {
    memset(C, 0, sizeof(C));
    rep(i,0,n) {
      rep(j,0,n) {
        rep(k,0,n) {
          C[i][j] += B[i][k] * A[k][j];
          C[i][j] %= mod;
        }
      }
    }
    memcpy(B, C, sizeof(C));
  }
}

int main() {
  int m,k;
  scanf("%d%d%d",&n,&m,&k);
  rep(i,0,n) S(X[i]);
  rep(i,0,m) {
    int x,y;
    S2(x,y);
    x--; y--;
    G[x][y] = G[y][x] = 1;
  }
  int inv = _pow(2 * m, mod - 2);
  rep(i,0,n) {
    int cnt = m;
    rep(j,0,n) {
      if(G[i][j]) {
        cnt--;
        A[i][j]++;
        A[i][i]++;
      }
    }
    A[i][i] += 2 * cnt;
    rep(j,0,n) {
      A[i][j] = A[i][j] * inv % mod;
    }
  }

  solve(k);
  rep(i,0,n) {
    LL ans = 0;
    rep(j,0,n) {
      ans += B[i][j] * X[j];
      ans %= mod;
    }
    P((int)ans);
  }
  return 0;
}


#pragma GCC diagnostic ignored "-Wunused-const-variable"

#ifdef MAC
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define mp make_pair
#define pb push_back
#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i < (int)(n); ++i)
#define nfor(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define correct(x, y, n, m) (0 <= x && x < n && 0 <= y && y < m)
#define all(x) (x).begin(), (x).end()
#define fst first
#define snd second
#define endl "\n"

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

template<typename T> inline T abs(T a){ return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a){ return a * a; }
template<class T> T gcd(T a, T b) { return a ? gcd (b % a, a) : b; }
template<class T> T lcm(T a, T b) { return a / gcd (a, b) * b; }
template<class T> T sign(T a) { return a > 0 ? 1 : (a < 0 ? -1 : 0); }

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void dbg() { cout << endl; }
template <typename Head, typename... Tail>
void dbg(Head H, Tail... T) {
    cout << " " << to_string(H);
    dbg(T...);
}

#ifdef DEBUG
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg(__VA_ARGS__)
#else
#define dbg(...)
#endif

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}

template<typename T>
vector<T> make_unique(vector<T> v) {
    sort(all(v));
    return v.resize(unique(all(v)) - v.begin());
}

int nxt() {
    int x;
    cin >> x;
    return x;
}

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int dxKn[8] = {-2, -1, 1, 2,  2,  1, -1, -2};
const int dyKn[8] = { 1,  2, 2, 1, -1, -2, -2, -1};
const int dxK[8] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dyK[8] = {1, -1, 0, 0, 1, -1, 1, -1};

const int MOD = int(1e9) + 7;
const int INF = int(1e9) + 100;
const ll INF64 = 2e18;
const ld PI = ld(3.1415926535897932384626433832795);
const ld e = ld(2.7182818284590452353602874713527);
const ld EPS = 1e-9;

//#############################
const int MAXN = 1000005;

int n, m; // sizes
vector<vector<int>> g; //graph, grid
vector<vector<ll>> dp;

int main() {
    fastIO();
    dp = vector<vector<ll>>(300, vector<ll>(300, 0));
    dp[1][1] = 1;
    for(int i = 2; i < 300; i++) {
        for(int j = 1; j <= i; j++) {
            dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
        }
    }
    // dbg(dp);
    int l = nxt();
    // dbg(dp[13]);
    cout << dp[l][12] << endl;
    return 0;
}

/*
    RECALL CORNER CASES - e.g. n = 1, n = 0
    WRITE SOME STUFF

    think first, always -
    1. concretely
    2. graphically
    3. abstractly
    4. algebraically
*/

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5+5;
const ll INF = 1e16;
vector<pair<int,pair<ll,ll>>> adj[N];
vector<ll> dist(N,INF);

void djk(int src){
    dist[src] = 0;
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> pq;
    pq.push({0,src});
    while(!pq.empty()){
        ll t = pq.top().first;
        int cur_node = pq.top().second;
        pq.pop();
        if(dist[cur_node] != t)
            continue;
        for(int i = 0; i < (int)adj[cur_node].size();++i){
            int next_node = adj[cur_node][i].first;
            ll next_t = adj[cur_node][i].second.first;
            ll k = adj[cur_node][i].second.second;
            ll leave_time = ((t+k-1)/k) * k;
            ll extra = max(0LL,leave_time - t);
            ll new_t = extra + t + next_t;
            if(dist[next_node] > new_t){
                dist[next_node] = new_t;
                pq.push({dist[next_node],next_node});
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    for(int i = 0 ; i < m;++i){
        int a,b;
        ll t,k;
        cin >> a >> b >> t >> k;
        adj[a].push_back({b,{t,k}});
        adj[b].push_back({a,{t,k}});
    }
    djk(x);
    if(dist[y] == INF)
        dist[y] = -1;
    cout << dist[y] << "\n";
}


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

using i64 = long long;
using u64 = unsigned long long;

struct debug {
    ~debug(){cerr << endl;}
    template<class c> debug& operator<<(c x) {cerr << x; return *this;}
    template<class c, class d>
    debug& operator<<(pair<c, d> x) {*this << "(" << x.first << ", " << x.second << ")";
        return *this;}
    template<class c> debug& operator<<(vector<c> x) { *this << "[";
        int f = 0; for(auto it : x) { *this << (f?", ":""); *this << it; f = 1;}
        *this << "]"; return *this;}
};

#define dbg(x) "[" << #x << ": " << x << "]  "
#define Wa() cerr << "[LINE: " << __LINE__ << "] -> "; debug() <<
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(NULL)

int main()
{
    int n;
    scanf("%d", &n);

    vector<pair<int, int>> p;
    for(int i = 0; i < n; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        p.push_back({x, y});
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            if(abs(p[i].second - p[j].second) <= abs(p[i].first - p[j].first)) ans++;
        }
    }

    printf("%d\n", ans);
}

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

typedef long long ll;
using P = pair<int, int>;

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

    pair<double, double> point[n];
    rep(i, n) cin >> point[i].first >> point[i].second;

    int cnt = 0;

    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
        {
            double d = (point[j].second - point[i].second) / (point[j].first - point[i].first);
            if (abs(d) <= 1)
                cnt++;
        }
    cout << cnt << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

template<typename T>
struct BinaryIndexedTree {
	using value_type = T;
	using const_reference = const value_type &;
	using F = std::function<value_type(const_reference, const_reference)>;
	using size_type = std::size_t;

	BinaryIndexedTree(size_type n, const F & f, const_reference id_elem) : n(n), f(f), id_elem(id_elem) {
		node.resize(n + 1, id_elem);
	}

	size_type size() const noexcept {
		return n;
	}

	void add(size_type i, const_reference x) {
		assert(i < size());
		++i;
		for (; i <= size(); i += i & -i) node[i] = f(node[i], x);
	}

	// [0, i)
	value_type sum(size_type i) const {
		assert(i <= size());
		value_type res = id_elem;
		for (; i > 0; i -= i & -i) res = f(res, node[i]);
		return res;
	}

	// sum[0, r] <= x を満たす最小の r を返す (存在しなければ size())
	size_type lower_bound(const_reference x) const {
		size_type res = 0;
		size_type s = id_elem, w = 1;
		while (w < size()) w <<= 1;
		for (; w > 0; w >>= 1) {
			if (res + w <= size()) {
				value_type cur = f(s, node[res + w]);
				if (cur < x) {
					res += w;
					s = cur;
				}
			}
		}
		return res;
	}

private:
	size_type n;
	F f;
	value_type id_elem;
	std::vector<value_type> node;
};

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	REP(i, N) scanf("%d", &A[i]);

	BinaryIndexedTree<int> bit(N, [](int a, int b) { return a + b; }, 0);
	ll ans = 0;
	REP(i, N) {
		ans += bit.sum(N) - bit.sum(A[i]);
		bit.add(A[i], 1);
	}

	REP(i, N) {
		printf("%lld\n", ans);
		if (i + 1 == N) break;
		ans -= bit.sum(A[i]);
		ans += bit.sum(N) - bit.sum(A[i] + 1);
	}
}

#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define N 1000005

using namespace std;

vector<ll> bit, bit2;
ll n;
void update(ll x, ll v, vector<ll> &bitt)
{
	while (x <= n)
	{
		bitt[x] += v;
		x += (x & (-x));
	}
}

ll query(ll x, vector<ll> &bitt)
{
	ll sum = 0;
	while (x > 0)
	{
		sum += bitt[x];
		x -= (x & (-x));
	}
	return sum;
}

void solve()
{
	cin >> n;
	bit = vector<ll>(n + 2, 0);
	ll a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		a[i]++;
	}
	ll ans = 0;
	for (int i = n - 1; i >= 0; --i)
	{
		update(a[i], 1, bit);
		ans += query(a[i] - 1, bit);
	}
	for (int i = 0; i < n; ++i)
	{
		cout << ans << endl;
		ans -= a[i] - 1;
		ans += n - a[i];
	}
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll>
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;

        ll n,s,d;
        cin>>n>>s>>d;
        int x,y;
        rep(i,0,n-1){
        	cin>>x>>y;
        	if(x<s && y>d){
        		cout<<"Yes";
        		return 0;
        	}
        }
        cout<<"No";

        cout<<'\n';
    return 0;
}

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

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

signed main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(0) ; cout.tie(0) ;
    int n , s , d ;
    cin >> n >> s >> d ;
    int f = 0 ;
    for( int i = 0 ; i < n ; i++ ){
    	int x , y ;
    	cin >> x >> y ;
    	if( x < s && y > d )
    		f = 1 ;
    }
    if( f )
    	cout << "Yes\n" ;
    else
    	cout << "No\n" ;
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}


#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<chrono>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
// #define MOD (998244353)
#define INF (1e9+7)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
using P=pair<ll,ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pl(T x){cout << x << " ";}
template<class T>void pr(T x){cout << x << endl;}
template <class T, class... Ts> inline void pr(T Tar, Ts... ts) { std::cout << Tar << " "; pr(ts...); return; }
template<class T>void prvec(vector<T>& a){rep(i, (int)a.size()-1){pl(a[i]);} pr(a.back());}
template<class T>void prarr(arr<T>& a){rep(i, (int)a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}

int main()
{
    int n,m; cin >> n >> m;
    vint cnt(n+1, 0);
    vint(a, n);

    int ans = INF;
    rep(i, m){
        cnt[a[i]]++;
    }
    rep(i, n+1){
        if(cnt[i]==0) chmin(ans, i);
    }

    FOR(i, 1, n-m+1){
        cnt[a[i-1]]--;
        cnt[a[i+m-1]]++;
        if(cnt[a[i-1]]==0) chmin(ans, a[i-1]);
    }

    pr(ans);
    return 0;}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(1.5e6 + 10);
std::set<int> s;
int n, m, a[N], b[N], ans = 1e9;

void Ins(int x) { if (!b[x]++) s.erase(x); }
void Ers(int x) { if (!--b[x]) s.insert(x); }

int main()
{
#ifndef ONLINE_JUDGE
	file(cpp);
#endif
	n = read(), m = read();
	for (int i = 1; i <= n; i++) a[i] = read();
	for (int i = 0; i <= n; i++) s.insert(i);
	for (int i = 1; i <= m; i++) Ins(a[i]);
	ans = std::min(ans, *s.begin());
	for (int i = m + 1; i <= n; i++)
		Ins(a[i]), Ers(a[i - m]), ans = std::min(ans, *s.begin());
	printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
using namespace std;
const ll maxn = 1e5 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n = 0;
  cin >> n;
  ll c = 1;
  while ((c * (c + 1) / 2) < n)
    ++c;
  cout << c;
}

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

typedef long long int ll;
#define All(a) (a).begin(),(a).end()
#define INF 2e18
#define MOD 1000000007

// ビットをずらすときは1LLを使え
// 有効桁のある小数を書く時はfixed + setorecisionを使え

int main(){
	ll n,ans;
  string s;
  cin >> s;
  cout << s[1] <<s[2]<<s[0]<< endl;

	/*for(ll i=0;i<n;i++){
		cin >> ;
	}*/

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


#include <bits/extc++.h>

#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

using namespace std;
using ll = long long;
using pii = pair<int, int>;
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, N;
    cin>>n>>m>>N;
    vector<int> top(m, n), left(n, m);
    vector<vector<int>> blocks(n);
    for (int i=0; i<N; i++) {
        int x, y;
        cin>>x>>y;
        x--, y--;
        top[y]=min(top[y], x);
        left[x]=min(left[x], y);
        blocks[x].push_back(y);
    }
    ll ans=0;
    for (int i=0; i<left[0]; i++) {
        ans+=top[i];
    }

    ordered_set<int> st;
    for (int i=left[0]; i<m; i++) st.insert(i);
    for (int i=1; i<top[0]; i++) {
        if(!st.empty()) ans+=st.order_of_key(left[i]);
        for (auto x:blocks[i]) st.insert(x);
    }
    cout<<ans;
    return 0;
}

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

using namespace std;
class Bit{
    public:
    vector<int> arr;
    int n;
    Bit(int n){
        arr = vector<int>(n+1,0);
        this->n=n;
    }
    void update(int index,int val){
        index+=1;
        for(int i=index;i<=n;i=i+(i&(-i))){

            arr[i]+=val;
        }
    }
    int get(int index){

        index+=1;
        int re = 0;
        for(int i=index;i>0;i=i-(i&(-i))){

            re+=arr[i];
        }
        return re;
    }
};

int main(){
    int H,M,W,x,y;
    ll re=0;

    cin>>H>>W>>M;
    vector<int> row(H,W),col(W,H);
    vector<vector<int>> ceil_block(H,vector<int>());
    Bit tree(W);
    forinc(i,0,M){

        cin>>x>>y;
        x--;y--;
        row[x]=min(row[x],y);
        col[y]=min(col[y],x);

    }
    // cout<<"here1";
    forinc(i,0,row[0]){

        re += (ll)col[i];
    }
  	forinc(i,0,row[0]){
      if(col[i]<H)ceil_block[col[i]].push_back(i);
      }
    // cout<<"here";
    for(int i=0;i<col[0];i++){

        re+= (ll) tree.get(row[i]-1);
        re+= (ll)max(row[i]-row[0],0);
        for(auto j:ceil_block[i]){
            tree.update(j,1);
        }

    }
    cout<<re;
}


#include <bits/stdc++.h>

using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vb=vector<bool>;using vvb=vector<vb>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;

#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()

// cin and cout of a vector
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,enable_if_t<iterable<T>::value,int> =0>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}

// for loop
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revv(i, a, b) for (int i = (int)(b-1); i >= (int)(a); i--)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
// #define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
// #define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
// #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
// #define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)

// Yes/no
#define cho(n,a,b) cout<< ((n)?a:b)<<endl;
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}

#define pb push_back
#define rsortv(v) sort((v).rbegin(), (v).rend())
#define sortv(v) sort((v).begin(), (v).end())

// max/min
template<class T, class U>bool chmax(T&a,const U&b){bool x=a<b;x?a=b:b;return x;}template<class T, class U>bool chmin(T&a,const U&b){bool x=a>b;x?a=b:b;return x;}
template<class T, class U>auto max(const T&a,const U&b){return a<b?b:a;}template<class T, class U>auto min(const T&a,const U&b){return a<b?a:b;}

//========================================
//========================================
//========================================

template<class T>auto minv(const T&a){return *min_element(all(a));}
template<class T>auto smod(T a, T b){a %= b; if (a < 0); a+= b; return a;}
template<class T>auto maxv(const T&a){return *max_element(all(a));}
template<class T>auto sumv(const T&a){ll sum = 0; for(auto x: a) sum+= x; return sum;}

template<class T>void pr(const T&a){cout << a << endl;}
template<class T>void pr_precise(const T&a){cout.precision(10); cout << fixed << a << endl;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
// ll M = 1000000007;
ll M = 998244353;
// vvl A(h+1, vl(n+1,0));

void check(){
    ll n;
    cin >> n;
    vi A(n, 0);
    string s;
    rep(i, n){
        cin >> s;
        if (s[0] == 'O') A[i] = 1;
    }
    // pr(A);
    ll now = 1;
    ll mul = 2;
    rep(i, n){
        if (A[i] == 1){
            now += mul;
        }
        mul*= 2;
    }
    pr(now);
}

int main() {
    int cases = 1;
    // cin >> cases;

    rep(CASE, cases){
        check();

        // pr(A);

    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long t=1;
	// cin>>t;
	while(t--){
		long long n;
		cin>>n;
		string s;
		long long a[n]={0};
		for(long long i=0;i<n;i++){
			cin>>s;
			if(s=="AND") a[i]=1;
			else a[i]=0;
		}

		long long ans=1;
		long long two=2;
		for(int i=0;i<n;i++){
			if(a[i]==0){
				ans+=two;
			}
			two*=2;
		}
		cout<<ans;
		cout<<endl;
	}
}


// D - Happy Birthday! 2
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rep(i,e) for(int i=0;i<(e);++i)

void print(int n, vi v){ cout<< n <<" "; rep(i, n) cout<< v[i] << (i<n-1? " ":"\n"); }

int main(){
	int n; cin>>n;
	vi A(n); for(int&x:A) cin>>x;
	vector<vi> B(200);
	for(int d=min(8, n), bit=1; bit<1<<d; ++bit){ // 8bit: 2^8=256
		int64_t r = 0; vi C;
		rep(i, d) if(bit>>i & 1) r += A[i], C.push_back(i+1);
		r %= 200;
		if(B[r].size()){
			puts("Yes");
			print(B[r].size(), B[r]);
			print(C.size(), C);
			return 0;
		}
		B[r] = C;
	}
	puts("No");
}

// KNOW NOTHING!
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define sz(x) (int)x.size()
#define szs(x) (int)x.length()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef queue<int> qin;
typedef deque<ll> dqll;
typedef deque<int> dqint;
typedef priority_queue<ll> pqll;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
ll mpwr(ll b,ll p){ll res=1;while(p){if(p&1) {res=(res*b)%MOD; p--;}else{b=(b*b)%MOD; p>>=1;}}return res;}
int msb (int n) {return 31-__builtin_clz(n);}
ll msbl (ll n) {return 63-__builtin_clzll(n);}
int lsb (int n) {return __builtin_ctz(n);}
ll  lsbl (ll n) {return __builtin_ctzll(n);}
int setbit (int n) {return __builtin_popcount(n);}
ll setbitl (ll n) {return __builtin_popcountll(n);}
int main()
{
/*
freopen ("input.txt","r","stdin");
freopen ("output.txt","w","stdout");
*/
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
int n; cin>>n;
vll a (n);
F (i,0,n,1) cin>>a[i];
int m = min (10,n);
int ok =0;
F (i,1,1<<m,1) {
	F (j,1,1<<m,1) {
		if (i!=j) {
		ll s1 = 0, s2=0;
		vin a1 , a2;
		F (k,0,m,1) {
			if (i&(1<<k)) {
				s1+=a[k];
				a1.pb (k);
			}
			if (j&(1<<k)) {
				s2+=a[k];
				a2.pb (k);
			}
		}
		if (s1%200 == s2%200) {
			ok =1;
			cout<<"YES"<<endl;
			cout<<sz(a1)<<" ";
			for (auto e : a1) cout<<e+1<<" ";
		    cout<<endl<<sz(a2)<<" ";
		    for (auto e : a2) cout <<e+1<<" ";
		    ok=1;
		    break;

		}
	}
}
if (ok) break;
}
if (!ok) cout<<"NO";
return 0;
}
/* What we know is a drop , but what we don't know is an ocean !*/


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

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

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<ll> siz;
    vector<map<ll,ll>> cnt;

    UnionFind(ll N) : par(N), siz(N,1LL), cnt(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    ll size(ll x) { // xが属する木のサイズを返す
        ll rx = root(x);
        return siz[rx];
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        if (siz[rx]<siz[ry]) swap(rx,ry); // sizeが大きいほうをx,小さいほうをyとする。
        siz[rx] += siz[ry]; // サイズの変更
        //xとyの根が同じでない(=同じ木にない)時：yの根ryをxの根rxにつける(siz[rx]>=siz[ry])
        par[ry] = rx;
        for (auto p : cnt[ry]) cnt[rx][p.first] += p.second;
        cnt[ry].clear();
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
    ll N, Q; cin >> N >> Q;
    UnionFind uf(N);
    rep(i,N) {
        ll c; cin >> c; c--;
        uf.cnt[i][c]++;
    }
    vector<ll> res;
    rep(q,Q) {
        ll t; cin >> t;
        ll x, y; cin >> x >> y;
        x--; y--;
        if (t==1) {
            uf.unite(x,y);
        } else {
            x = uf.root(x);
            res.push_back(uf.cnt[x][y]);
        }
    }
    for (ll ans : res) cout << ans << endl;
}

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

vector<map<int, int>> freq;
vector<array<int, 3>> query;
vector<int> c, sze, req, parent;

int find_parent(int v) {
	if (v == parent[v]) return v;
	return parent[v] = find_parent(parent[v]);
}

void union_set(int a, int b) {
	a = find_parent(a);
	b = find_parent(b);

	if (a != b) {
		if (sze[a] < sze[b]) swap(a, b);

		parent[b] = a;
		sze[a] += sze[b];
		for (auto [num, cnt] : freq[b])
			if (req[num]) freq[a][num] += cnt;
	}
	return;
}

int main() {

	int n, q; cin >> n >> q;
	c.resize(n + 1, 0); for (int i = 1; i <= n; i++) cin >> c[i];

	freq.resize(n + 1);
	sze.resize(n + 1, 1);
	parent.resize(n + 1, 0);
	req.resize(n + 1, 0);

	query.resize(q);

	for (int i = 0; i <= q - 1; i++) {
		cin >> query[i][0] >> query[i][1] >> query[i][2];
		if (query[i][0] == 2) {
			req[query[i][2]]++;
		}
	}

	for (int i = 1; i <= n; i++) {
		parent[i] = i;
		if (req[c[i]]) freq[i][c[i]]++;
	}

	for (int i = 0; i <= q - 1; i++) {
		if (query[i][0] == 1) union_set(query[i][1], query[i][2]);
		else {
			cout << freq[find_parent(query[i][1])][query[i][2]] << "\n";
			req[query[i][2]]--;
		}
	}

	return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N;
vector<pair<int, ll>> E[201010];
ll xo[201010];
//---------------------------------------------------------------------------------------------------
void dfs(int cu, int pa, ll x) {
    xo[cu] = x;
    fore(p, E[cu]) if (pa != p.first) dfs(p.first, cu, x ^ p.second);
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N - 1) {
        int a, b; ll c; cin >> a >> b >> c;
		a--; b--;
		E[a].push_back({ b, c });
		E[b].push_back({ a, c });
	}

    dfs(0, -1, 0);

    mint ans = 0;
    rep(bit, 0, 60) {
        ll msk = 1LL << bit;
        ll cnt[2] = { 0, 0 };
        rep(i, 0, N) cnt[(xo[i] & msk) != 0]++;
        ans += mint(msk) * mint(cnt[0]) * mint(cnt[1]);
    }
    cout << ans << endl;
}

// Problem: E - Xor Distances
// Contest: AtCoder - Mynavi Programming Contest 2021（AtCoder Beginner Contest 201）
// URL: https://atcoder.jp/contests/abc201/tasks/abc201_e
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#define XOX
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define int long long
#define re return
#define beg() begin()
#define cont continue
#define ldb long double
#define db double

#define br break
#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mkp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>

#define si set<int>
#define sdb set<db>
#define sldb set<ldb>

#define test int t; cin>>t; while(t--)
#define scan() int n; cin>>n; int a[n]; for(int i=0;i<n;i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k; int a[n]; for(int i=0;i<n;i++) cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define srt(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define cn(x) cout<<x<<"\n"
#define cs(x) cout<<x<<" "
#define c(x) cout<<x
#define all(v) v.begin(),v.end()

#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)

const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);
const int INF = 1e18;
const int NINF = -1e18;

int get_hash(string s){
	int N=1000001;
	int base[N],A=11,MD=1110111110111;
	base[0]=1;

	forr(i,1,N)
	base[i]=(base[i-1]*A)%MD;

	int hs=0;
	forr(i,0,s.size()){
		hs+=(s[i]*base[i]);
		hs%=MD;
	}

	re hs;
}

int power(int a,int n){
	int res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}

	return res;
}

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...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int root=1;
vector<int>dist;
vector<vector<pair<int,int>>>v;
vector<bool>bl;

void dfs(){
	queue<int>q;
	q.push(root);

	while(!q.empty()){
		int x=q.front();
		bl[x]=1;
		q.pop();

		for(int i=0;i<v[x].size();i++){
			if(bl[v[x][i].first]==0){
				dist[v[x][i].first]=dist[x]^v[x][i].second;
				q.push(v[x][i].first);
			}
		}
	}

	return;
}

int32_t main(){
	fast;

	int n;
	cin>>n;

	v.resize(n+1);
	for(int i=0;i<n-1;i++){
		int x,y,z;
		cin>>x>>y>>z;

		v[x].push_back({y,z});
		v[y].push_back({x,z});
	}

	dist.resize(n+1,0);
	bl.resize(n+1,0);
	dfs();

	int x=1;
	int ans=0;

	for(int i=0;i<=60;i++){
		int cnt1=0,cnt0=0;

		for(int j=1;j<=n;j++){
			if(dist[j]%2==1)
			cnt1++;

			else
			cnt0++;

			dist[j]/=2;
		}

		ans=(ans%MOD+(cnt1%MOD*cnt0%MOD)%MOD*(x%MOD))%MOD;
		x*=2;
	}

	cout<<ans;
	re 0;
}


#include <iostream>
#include <vector>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<deque>
#include<math.h>
#include<set>
#include<cstdio>
#include<string>
#include<queue>
#include<complex>
#include<numeric>
#include<stack>
#include<unordered_map>
#include<map>
using namespace std;
#define rep(i,n) for(ll i = 0;i<n;i++)
#define req(i,n) for(ll i = 1;i<=n;i++)
#define rrep(i,n) for(int i = n-1;i>=0;i--)
#define ALL(a) a.begin(),a.end()
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; }
typedef long long ll;
typedef long double ld;
const int MOD = 1e9 + 7;
int main() {
    int n; cin >> n; vector<set<int>> v(n + 1);
    vector<int> a(n+1,0); int cnt;
    req(i, n) {
        cnt = 1;
        if (v[i].size() == 0) {
            a[i] = cnt;
        }
        else {
            for (int j : v[i]) {
                if (j == cnt) cnt++;
                else {
                    a[i] = cnt; break;
                }
            }if (a[i] == 0) a[i] = cnt;
        }for (int j = i; j <= n; j += i) {
            v[j].insert(cnt);
        }
    }req(i,n) cout << a[i] << " ";
    cout << endl;
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007;

// struct fast_io {
	// fast_io(){
		// std::cin.tie(nullptr);
		// std::ios::sync_with_stdio(false);
	// };
// } fio;

signed main(){
	cout<<fixed<<setprecision(10);

	int N;
	int x = 0, y = 0;

	cin>>N;

	int X = N;
	int Y = N * 1.618033988749894848204586834365;
	Y = max(1ll, Y-10000);

	int mini = INF;
	for(int j = 0; ; j++){
		x = X;
		y = Y+j;

		int con = 0;

		for(;;){
			// cout<<x<<" "<<y<<endl;

			con++;
			// string s;

			// cin>>s;

			if(x > y) x -= y;
			else y -= x;

			if(!x || !y) {
				con += x + y;
				break;
			}
			if(con >= 140) break;
		}

		if(con <= 130) {
			x = X;
			y = Y+j;
			vector<int> ans;

			for(;;){

				con++;
				if(x > y) {
					x -= y;
					ans.push_back(3);
				} else {
					ans.push_back(4);
					y -= x;
				}
				if(!x || !y) {
					// con += x + y;
					if(x == 0) {
						for(int i = 0; i < y; i++){
							ans.push_back(2);
						}
					} else {
						for(int i = 0; i < x; i++){
							ans.push_back(1);
						}
					}
					break;
				}
			}

			cout<<ans.size()<<endl;

			for(int i = 0; i < ans.size(); i++){
				cout<<ans[ans.size()-i-1]<<endl;
			}
			return 0;
		}
	}

	// cout<<"mini = "<<mini<<endl;

	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(ll i=0; i<(ll)n; i++)
#define INF 1e9
typedef long long ll;

const ll MAXN=17;
ll n;
ll d[MAXN][MAXN];
ll dp[1<<MAXN][MAXN];

ll rec(ll S, ll v) {
    if(dp[S][v] >= 0) return dp[S][v];
    if(S==(1<<n)-1 && v==0) return dp[S][v]=0;
    ll tmp=INF;
    REP(u,n) if(!(S>>u & 1)) tmp=min(tmp, rec(S|1<<u,u)+d[v][u]);
    return dp[S][v]=tmp;
}

int main() {

    cin >> n ;
    ll m = n*n;
    vector<ll> x(n);
    vector<ll> y(n);
    vector<ll> z(n);

    for(ll i = 0; i < n; i++) {
        cin >> x.at(i) >> y.at(i) >> z.at(i);
        x.at(i)--;
        y.at(i)--;
        z.at(i)--;
    }
    REP(i,n) REP(j,n) d[i][j]=d[j][i]=INF;
    for(ll i = 0; i < n; i++) {
        for(ll j = 0; j < n; j++) {
            if(i != j) {
                ll a, b, c;
                a = i;
                b = j;
                d[a][b]=abs(x.at(i) - x.at(j)) + abs(y.at(i) - y.at(j)) + max((ll)0, z.at(j) - z.at(i));
            }
        }
    }
    fill((ll *)dp, (ll *)(dp+(1<<MAXN)), -1);
    cout << rec(0,0) << endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int INF = 1e9 + 239;
const int N = 501;

int a[N][N];
int b[N];
int c[N];

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

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    int mn = INF;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            mn = min(mn, a[i][j]);
        }
    }
    int any = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i][j] == mn && !any) {
                any = 1;
                for (int nj = 0; nj < n; nj++) {
                    b[nj] = 0;
                    c[nj] = a[i][nj];
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        b[i] = a[i][0] - c[0];
    }
    int ok = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ok &= (a[i][j] == b[i] + c[j]);
        }
        ok &= (b[i] >= 0);
        ok &= (c[i] >= 0);
    }
    if (ok) {
        cout << "Yes\n";
        for (int i = 0; i < n; i++) {
            cout << b[i] << ' ';
        }
        cout << '\n';
        for (int i = 0; i < n; i++) {
            cout << c[i] << ' ';
        }
        cout << '\n';
    } else {
        cout << "No\n";
    }
}


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

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) ;
#endif

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

typedef long long ll;
typedef long double ld;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)((x).size())
#define pb push_back
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
#define X first
#define Y second
//#define debug(x) cerr << #x << " : " << (x) << " "
const long double PI = 3.14159265358979323846;
const long double eps = (1e-15);
//enum
//{
//    LESS, EQUAL, GREATER
//};

//int dcmp(ld x, ld y, ld EPS = eps)
//{
//    if (fabs(x - y) <= EPS)
//        return EQUAL;
//    return x > y ? GREATER : LESS;
//}

const int MOD = 1e9 + 7;
int add(int x, int y)
{
    x += y;
    if (x >= MOD)
        x -= MOD;
    return x;
}

int mult(int x, int y)
{
    return (1LL * x * y)%MOD;
}

int f(int n)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return 2;
    if (n == 2)
        return 3;
    int a = 2, b = 3; // f(1), f(2)
    for (int i = 3; i <= n; ++i)
    {
        int newA = b, newB = add(a, b);
        a = newA;
        b = newB;
    }
    return b;
}

int pwr(int base, int exp)
{
    int ret = 1;
    for (; exp; exp >>= 1, base = mult(base, base))
        if (exp&1)
            ret = mult(ret, base);
    return ret;
}

void myMain()
{
    int n;
    cin >> n;
    int c[2][2];
    rep(i,0,2)
    {
        rep(j, 0, 2)
        {
            char t;
            cin >> t;
            c[i][j] = t - 'A';
        }
    }

    if (n == 2)
    {
        cout << 1;
        return;
    }
    if (c[0][1] == 0)
    {
        if (c[0][0] == 0)
            cout << 1;
        else
        {
            if (c[1][0] == 0)
                cout << f(n - 3);
            else
                cout << pwr(2, n - 3);
        }
    }
    else
    {
        if (c[1][1] == 1)
            cout << 1;
        else
        {
            if (c[1][0] == 1)
                cout << f(n - 3);
            else
                cout << pwr(2, n - 3);
        }
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int tc = 1;
//    cin >> tc;
    while(tc--)
        myMain();
}

#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
#include <cassert>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; exit(0); }
void Yes() { cout << "Yes" << endl; exit(0); }
void No() { cout << "No" << endl; exit(0); }

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

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

signed main()
{
	int N, P;
	cin >> N >> P;

	mint p = P - 2;
	mint a = p.pow(N - 1);
	mint ans = a * (P - 1);
	cout << ans << endl;
}


#include "bits/stdc++.h"
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}
template<typename T, typename U> static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

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

ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;}

int solve(){

    string s;
    cin>>s;

    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]>'z' || s[i]<'a')
                return cout<<"No"<<endl,0;
        }
        else {
            // if(s[i]>)
             if(s[i]>'Z' || s[i]<'A')
                return cout<<"No"<<endl,0;
        }
    }
    cout<<"Yes";

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

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

//#define int		long long
#define pb		push_back
#define ppb		pop_back
#define pf		push_front
#define ppf		pop_front
#define all(x)		(x).begin(),(x).end()
#define uniq(v)		(v).erase(unique(all(v)),(v).end())
#define sz(x)		(int)((x).size())
#define fr		first
#define sc		second
#define pii		pair<int,int>
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define mem1(a)		memset(a,-1,sizeof(a))
#define mem0(a)		memset(a,0,sizeof(a))
#define ppc		__builtin_popcount
#define ppcll		__builtin_popcountll
//#define rep(i, n) for (int i = 0; i < (int)(n); i++)

//template<typename T1,typename T2>istream& opertor>>(istream& in,pair<T1,T2> &a){in>>a.fr>>
//template<typename T1,typename T2>istream& opertor<<(ostream& out,pair<T1,T2> a){out<<a.fr<<
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

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

  string ans = "Yes";

  rep(i,0,S.size()){
    if(i%2==0){
      if(isupper(S.at(i))){
      	ans = "No";
        break;
      }
    }else if((i%2==1)){
      if(islower(S.at(i))){
      	ans = "No";
        break;
      }
    }
  }

  cout << ans << endl;

  }


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

typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1);
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ull base = 131;
const ull mod1 = 1e9 + 9;
const ull mod2 = 1610612741;

const int maxn = 2e3 + 10;
int h, w;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
char p[maxn][maxn];
bool vis[maxn][maxn];
vector<pair<int, int> > v[30];
struct node
{
    int x, y, step;
    node(int a, int b, int c):x(a), y(b), step(c) {}
};
bool vis1[30];

int main()
{
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; ++i) scanf("%s", p[i]+1);
    int x, y, s, t;
    for (int i = 1; i <= h; ++i)
        for (int j = 1; j <= w; ++j)
            if (p[i][j] == 'S') x = i, y = j;
            else if (p[i][j] >= 'a' && p[i][j] <= 'z') v[p[i][j]-'a'].push_back(make_pair(i, j));
            else if (p[i][j] == 'G') s = i, t = j;
    queue<node> q;
    q.push(node(x, y, 0));
    vis[x][y] = 1;
    while (!q.empty())
    {
        int x = q.front().x;
        int y = q.front().y;
        int step = q.front().step;
        q.pop();
//        if (vis[x][y]) continue;
//        vis[x][y] = 1;
        if (x == s && y == t) { printf("%d\n", step); return 0; }
        for (int i = 0; i < 4; ++i)
        {
            int nx = x+dx[i];
            int ny = y+dy[i];
            if (nx < 1 || nx > h) continue;
            if (ny < 1 || ny > w) continue;
            if (!vis[nx][ny] && p[nx][ny] != '#') q.push(node(nx, ny, step+1)), vis[nx][ny] = 1;
        }
        if (p[x][y] >= 'a' && p[x][y] <= 'z')
        {
            if (vis1[p[x][y]-'a']) continue;
            vis1[p[x][y]-'a'] = 1;
            for (int i = 0; i < v[p[x][y]-'a'].size(); ++i)
            {
                int nx = v[p[x][y]-'a'][i].first;
                int ny = v[p[x][y]-'a'][i].second;
                if (!vis[nx][ny]) q.push(node(nx, ny, step+1)), vis[nx][ny] = 1;
            }
        }
    }
    printf("-1\n");
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}

template <class T>
void debug(const vector<T> &v) {
  cout << "[";
  REP(i, SZ(v)) {
    if(i) cout << ", ";
    cout << v[i];
  }
  cout << "]" << endl;
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << " " << p.second;
}

template <class T, class U>
void debug(const pair<T, U> &p) {
  cout << "(" << p.first << " " << p.second << ")" << endl;
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int inf = INT_MIN;
const ll linf = LLONG_MIN;
const ld eps = 1e-9;

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

  int h, w; cin >> h >> w;

  vector<string> s(h);
  P st, gl;
  REP(i, h) {
    cin >> s[i];
    REP(j, w) {
      if(s[i][j] == 'S') st = {i, j};
      if(s[i][j] == 'G') gl = {i, j};
    }
  }

  vector<vector<P>> g(h*w+26);
  int dr[4] = {-1, 1, 0, 0};
  int dc[4] = {0, 0, -1, 1};
  REP(i, h) {
    REP(j, w) {
      REP(k, 4) {
        int nr = i + dr[k], nc = j + dc[k];
        if(!(0 <= nr && nr < h && 0 <= nc && nc < w) || s[nr][nc] == '#') {
          continue;
        }
        g[i*w+j].emplace_back(nr*w+nc, 2);
      }
    }
  }

  REP(i, h) {
    REP(j, w) {
      if('a' <= s[i][j] && s[i][j] <= 'z') {
        int tel = h * w + s[i][j] - 'a';
        g[i*w+j].emplace_back(tel, 1);
        g[tel].emplace_back(i*w+j, 1);
      }
    }
  }

  vi d(h*w+26, INF);
  d[st.first*w+st.second] = 0;
  priority_queue<P, vector<P>, greater<P>> pq;
  pq.push({0, st.first*w+st.second});

  while(!pq.empty()) {
    auto [nowd, now] = pq.top(); pq.pop();
    if(d[now] < nowd) continue;

    for(auto &[to, cost]: g[now]) {
      if(d[to] > nowd + cost) {
        d[to] = nowd + cost;
        pq.push({d[to], to});
      }
    }
  }

  int val = d[gl.first*w + gl.second];

  if(val == INF) {
    cout << -1 << endl;
  } else {
    cout << val/2 << endl;
  }

  return 0;
}