#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T>
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template<typename T>
inline void prt(vector<vector<T> >& vv){ for(const auto& v : vv){ prt(v); } }
template <typename T>
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T>
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T>
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

/*
step0 A<BとかA%2!=B%2を除外
step1 自分より右が存在するかチェック
step2 残り物の消去
step3 マッチングしてく

*/

int main(){
    ll n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    ll A = 0;
    ll B = 0;
    ll ans = 0;//答え
    //step0
    rep(i,n){
        if(s[i]=='1')A++;
        if(t[i]=='1')B++;
    }
    if(A<B||A%2!=B%2){
        cout << -1 << endl;
        return 0;
    }

    ll a = 0;
    ll b = 0;
    //step1
    rep(i,n){
        if(A<B){
            cout << -1 << endl;
            return 0;
        }
        if(s[i]=='1')a++;
        if(t[i]=='1')b++;
        if(a>b){
            a--;
            s[i]='0';
            for(int j=i+1;j<n;j++){
                if(s[j]=='1'){
                    s[j]='0';
                    ans += j-i;
                    break;
                }
            }
            A -= 2;
        }
    }

    //step2
    ll dif = B-A;
    ll r = n;
    ll l = n;
    for(int i=n-1;i>=0;i--){
        if(dif==0)break;
        if(s[i]=='1'){
            if(dif%2==0){
                r = i;
                dif--;
            }
            else{
                ans += r-i;
                dif--;
            }
        }

    }

    //step3
    rep(i,n){
        if(s[i]=='1'){
            ans += i;
        }
        if(t[i]=='1'){
            ans -= i;
        }
    }
    cout << ans << endl;

    return 0;
}

// clang-format off
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcountll
#define ffs __builtin_ffsll
#define ctz __builtin_ctzll
#define clz __builtin_clz
#define clzll __builtin_clzll
#define all(a) (a).begin(), (a).end()

using namespace std;
using namespace __gnu_pbds;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
// clang-format on

int main() {
    fastio();

    int n;
    string s, t;
    cin >> n >> s >> t;

    int borrow = 0;
    ll ans = 0;
    forn(i, n) {
        ans += borrow;

        if (s[i] == '1' and t[i] == '0') {
            if (borrow > 0)
                borrow--;
            else
                borrow++;
        }

        if (s[i] == '0' and t[i] == '1') {
            borrow++;
        }
    }

    bool ok = borrow == 0;

    cout << (ok ? ans : -1) << endl;

    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <sstream>
#include <iomanip>
using namespace std;

using VI = vector <int>;
using VVI = vector <VI>;
using VVVI = vector <VVI>;
using VLL = vector <long long>;
using VVLL = vector <VLL>;
using UMI = unordered_map<int, int>;
using UMLL = unordered_map<long long, long long>;

inline int getSum(const VVI& acc, int sr, int sc, int er, int ec) {
    if (er < sr || ec < sc) {
        return 0;
    }

    int ret = acc[er][ec];

    if (sr-1 >= 0) {
        ret -= acc[sr-1][ec];
    }

    if (sc-1 >= 0) {
        ret -= acc[er][sc-1];
    }

    if (sr-1 >= 0 && sc-1 >= 0) {
        ret += acc[sr-1][sc-1];
    }

    return ret;
}

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

    VVI val(N, VI(N));
    VI valVec;
    UMI rankMap;
    UMI rankToVal;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> val[i][j];
            valVec.push_back(val[i][j]);
        }
    }

    int cnt = 0;
    sort(valVec.begin(), valVec.end());
    rankMap[valVec[0]] = ++cnt;
    rankToVal[cnt] = valVec[0];

    for (int i = 1; i < valVec.size(); ++i) {
        if (valVec[i] != valVec[i-1]) {
            rankMap[valVec[i]] = ++cnt;
            rankToVal[cnt] = valVec[i];
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            val[i][j] = rankMap[val[i][j]];
        }
    }

    int target = K%2 ? (K*K)/2+1 : (K*K)/2;
    int low = 1;
    int up = rankToVal.size();
    int ans = -1;

    while (low <= up) {
        int mid = (low+up) / 2;

        VVI mask(N, VI(N));
        VVI acc(N, VI(N));
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                mask[i][j] = val[i][j] <= mid;
            }
        }

        for (int i = 0; i < N; ++i) {
            int racc = 0;
            for (int j = 0; j < N; ++j) {
                racc += mask[i][j];

                if (i) {
                    acc[i][j] += acc[i-1][j];
                }
                acc[i][j] += racc;
            }
        }

        bool ok = false;
        for (int i = 0; i+K-1 < N && !ok; ++i) {
            for (int j = 0; j+K-1 < N && !ok; ++j) {
                int sum = getSum(acc, i, j, i+K-1, j+K-1);
                if (sum >= target) {
                    ok = true;
                    break;
                }
            }
        }

        if (ok) {
            up = mid-1;
            ans = rankToVal[mid];
        } else {
            low = mid+1;
        }
    }

    cout << ans << endl;

    return 0;
}

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

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

    ll ng = -1;
    ll ok = 10e10;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        vector<vector<ll>> sum(n + 1, vector<ll>(n + 1));
        rep(i, n) rep(j, n) {
            sum[i + 1][j + 1] = (a[i][j] <= mid) + sum[i + 1][j];
        }
        rep(i, n) rep(j, n) { sum[j + 1][i + 1] += sum[j][i + 1]; }

        bool exist = false;
        for (int i = 0; i + k <= n; i++) {
            for (int j = 0; j + k <= n; j++) {
                if (sum[i + k][j + k] + sum[i][j] - sum[i][j + k] -
                        sum[i + k][j] >=
                    (k * k + 1) / 2)
                    exist = true;
            }
        }

        if (exist) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;
}


#include <iostream>
#include <climits>
#include<vector>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include<cmath>
#include <limits>
using namespace std;
typedef long long ll;

typedef pair<ll, ll> P;
const int INF = 10000000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

#define REP(i, a,b) for(i=a;i<b;i++)
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
const int MOD = 1000000007;

int main() {
	ll N,i,j,ans;
	cin >> N;
	string S;
	cin >> S;
	ans = 0;
	ll cca, cct, ccg, ccc;
	cca = 0;
	cct = 0;
	ccg = 0;
	ccc = 0;
	REP(i, 0, N) {
		REP(j, i,N) {
			if (S[j] == 'A') cca++;
			if (S[j] == 'T') cct++;
			if (S[j] == 'G') ccg++;
			if (S[j] == 'C') ccc++;
			if ((cca == cct) && (ccg == ccc))ans++;
		}

		cca = 0;
		cct = 0;
		ccg = 0;
		ccc = 0;
	}
	output(ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int64_t>;
using vvi = vector<vi>;
using pii = pair<int64_t, int64_t>;

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

  int ans = 0;
  map<char, vi> check;
  check['A'] = vi(s.size()+10);
  check['T'] = vi(s.size()+10);
  check['C'] = vi(s.size()+10);
  check['G'] = vi(s.size()+10);
  for (int i=1; i < s.size()+1; i++) {
    for (auto x : check) {
      char key = x.first;
      if (s[i-1] == key) check[key][i] = check[key][i-1] + 1;
      else check[key][i] = check[key][i-1];
    }
  }
  for (int i = 1; i < s.size()+1; i++) {
    rep(j, s.size()+1-i) {
      if ((check['A'][j+i] - check['A'][j] == check['T'][j+i] - check['T'][j]) && (check['C'][j+i] - check['C'][j] == check['G'][j+i] - check['G'][j])) {
        ans += 1;
      }
    }
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using ii = pair<ll, ll>;
using vii = vector<ii>;
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
const ll mod = 1000000007;
const ll N = 3e5, M = N;
vi g[N];

void solve() {
    ll i, j, n, m, k;
    cin >> n;
    if(n % 100 == 0) {
        cout << n / 100;
    } else {
        cout << n/100 + 1;
    }
}

int main() {
    ll tc = 1;
    for(ll t = 0; t < tc; t++) {
        solve();
    }
    return 0;
}

/**
 *  created: 21/03/2021, 13:15:10
**/

#include <bits/stdc++.h>

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, dp[max_n];
vector<int> all[max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i < max_n; ++i) {
        for (int j = 2 * i; j < max_n; j += i) {
            all[j].push_back(i);
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int x : all[i]) {
            dp[i] = max(dp[i], dp[x]);
        }
        ++dp[i];
        printf("%d ", dp[i]);
    }
    puts("");
    return 0;
}


#include <iostream>
using namespace std;

int main(void) {
    int n, w, ans;
    cin >> n >> w;
    ans = n/w;
    cout << ans << endl;
}

#include <bits/stdc++.h>
#include <numeric>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = (int)(n) - 1 ; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define ALL(v) (v).begin(), (v).end()
#define MIN(v) *min_element((v).begin(), (v).end())
#define MAX(v) *max_element((v).begin(), (v).end())
#define PF(p) (p).first
#define PS(p) (p).second
#define MF(p) (p)->first
#define MS(p) (p)->second
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define VL vector<long long>
#define VVL vector<vector<long long>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VC vector<char>
#define VVC vector<vector<char>>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;
//const ll MOD = 998244353LL;
int pmod(int x){int y=x%(int)MOD;return (y>=0)?y:y+(int)MOD;}
ll pmod(ll x){ll y=x%MOD;return (y>=0LL)?y:y+MOD;}
bool in(ll x, ll a, ll b){return (a<=x)&&(x<b);}
template<class T>bool chmin(T& a, T b){if(a>b){a=b;return true;}else return false;}
template<class T>bool chmax(T& a, T b){if(a<b){a=b;return true;}else return false;}

int main(){
    ll N,W;
    cin>>N>>W;
    cout << N/W;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    double D, H;
    cin >> N;
    vector<double> d(N), h(N);
    cin >> D >> H;
    for (int i = 0; i < N; i++) {
        cin >> d[i] >> h[i];
    }
    double ans = 0.0;
    for (int i = 0; i < N; i++) {
        double y = (h[i]*D - H*d[i]) / (H - h[i]);
        double x = h[i]*y / (y + d[i]);
        ans = max(ans, x);
    }
    printf("%32.18f\n", ans);

}

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

int main(){
  int n, d, h;
  double max_hi = 0;
  cin >> n >> d >> h;
  vector<vector<int>> object(n, vector<int>(2));
  for (int i = 0; i < n; i++)
    cin >> object.at(i).at(0) >> object.at(i).at(1);
  for (int i = 0; i < n; i++){
    double tmp;
    tmp = object.at(i).at(1) - object.at(i).at(0) * ((double) h - object.at(i).at(1)) / (d - object.at(i).at(0));
    if (tmp > max_hi)
      max_hi = tmp;
  }
  cout << fixed << setprecision(16);
  cout << max_hi << endl;
}


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

#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, A, B) _rep3(Itr, A, B, 1)
#define _rep3(Itr, A, B, S) for(i64 (Itr) = A; (Itr) < B; (Itr) += S)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)
#define rep(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)

#ifndef SEGMENT_TREE_HPP
#define SEGMENT_TREE_HPP

#include <vector>
#include <functional>
#include <iterator>

//===
template<class Monoid>
struct SegmentTree {
    using T = typename Monoid::value_type;

    std::vector<T> tree;

    SegmentTree() = default;
    explicit SegmentTree(int n)
        :tree(n << 1, Monoid::identity()) {};

    template<class InputIterator>
    SegmentTree(InputIterator first, InputIterator last) {
        tree.assign(distance(first, last) << 1, Monoid::identity());

        int i;
        i = size();
        for (InputIterator itr = first; itr != last; itr++) {
            tree[i++] = *itr;
        }
        for (i = size() - 1; i > 0; i--) {
            tree[i] = Monoid::operation(tree[(i << 1)], tree[(i << 1) | 1]);
        }
    };

    inline int size() {
        return tree.size() >> 1;
    };

    inline T operator[] (int k) {
        return tree[k + size()];
    };

    void update(int k, const T dat) {
        k += size();
        tree[k] = dat;

        while(k > 1) {
            k >>= 1;
            tree[k] = Monoid::operation(tree[(k << 1)], tree[(k << 1) | 1]);
        }
    };

    // [l, r)
    T fold(int l, int r) {
        l += size(); //points leaf
        r += size();

        T lv = Monoid::identity();
        T rv = Monoid::identity();
        while (l < r) {
            if (l & 1) lv = Monoid::operation(lv, tree[l++]);
            if (r & 1) rv = Monoid::operation(tree[--r], rv);
            l >>= 1;
            r >>= 1;
        }

        return Monoid::operation(lv, rv);
    };

    template<class F>
    inline int sub_tree_search(int i, T sum, F f) {
        while (i < size()) {
            T x = Monoid::operation(sum, tree[i << 1]);
            if (f(x)) {
                i = i << 1;
            }
            else {
                sum = x;
                i = (i << 1) | 1;
            }
        }
        return i - size();
    }

    template<class F>
    int search(int l, F f) {
        l += size();
        int r = size() * 2; //r = n;
        int tmpr = r;
        int shift = 0;

        T sum = Monoid::identity();
        while (l < r) {
            if (l & 1) {
                if (f(Monoid::operation(sum, tree[l]))) {
                    return sub_tree_search(l, sum, f);
                }
                sum = Monoid::operation(sum, tree[l]);
                l++;
            }
            l >>= 1;
            r >>= 1;
            shift++;
        }

        while (shift > 0) {
            shift--;
            r = tmpr >> shift;
            if (r & 1) {
                r--;
                if (f(Monoid::operation(sum, tree[r]))) {
                    return sub_tree_search(r, sum, f);
                }
                sum = Monoid::operation(sum, tree[r]);
            }
        }

        return -1;
    };
};
//===

#endif

#include <iostream>
using i64 = long long;
using namespace std;

int main() {
	i64 n, q;
	cin >> n >> q;
	vector<i64> v(n);
	for (auto &vs: v) cin >> vs;

	struct M {
		using value_type = i64;
		static i64 operation(i64 a, i64 b) { return a ^ b; };
		static i64 identity() { return 0; };
	};
	SegmentTree<M> seg(n);
	rep (i, n) seg.update(i, v[i]);

	rep (_, q) {
		i64 t, x, y;
		cin >> t >> x >> y;
		x--;
		if (t == 1) {
			seg.update(x, seg[x] ^ y);
		}
		else {
			cout << seg.fold(x, y) << '\n';
		}
	}

	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; }
//---------------------------------------------------------------------------------------------------
int mod = 1000000007;
int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
template<class... T> int add(int x, T... y) { return add(x, add(y...)); }
int mul(int x, int y) { return 1LL * x * y % mod; }
template<class... T> int mul(int x, T... y) { return mul(x, mul(y...)); }
int sub(int x, int y) { return add(x, mod - y); }
int modpow(int a, long long b) {
    int ret = 1; while (b > 0) {
        if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1;
    } return ret;
}
int modinv(int a) { return modpow(a, mod - 2); }
typedef vector<int> Vec;
typedef vector<Vec> Mat;
Vec mulMatVec(Mat a, Vec b)
{
    int n = b.size(); Vec ret(n, 0);
    rep(i, 0, n) rep(j, 0, n) ret[i] = add(ret[i], mul(a[i][j], b[j]));
    return ret;
}
Mat mulMatMat(Mat a, Mat b)
{
    int n = a.size(); Mat ret(n, Vec(n, 0));
    rep(i, 0, n) rep(j, 0, n) rep(k, 0, n) ret[i][j] = add(ret[i][j], mul(a[i][k], b[k][j]));
    return ret;
}
Mat fastpow(Mat x, ll n)
{
    Mat ret(x.size(), Vec(x.size(), 0));
    rep(i, 0, x.size()) ret[i][i] = 1;
    while (0 < n) { if ((n % 2) == 0) { x = mulMatMat(x, x); n >>= 1; } else { ret = mulMatMat(ret, x); --n; } }
    return ret;
}
void printVec(Vec a) { cout << "[\t"; rep(i, 0, a.size()) cout << a[i] << "\t"; cout << "]" << endl; }
void printMat(Mat a) { rep(i, 0, a.size()) printVec(a[i]); }
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, M, K, A[101];
int X[10101], Y[10101];
int cnt[101];
bool E[101][101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> K;
	rep(i, 0, N) cin >> A[i];
    rep(i, 0, M) cin >> X[i] >> Y[i], X[i]--, Y[i]--;

    Mat Ma(N, Vec(N));
	rep(i, 0, M) {
        cnt[X[i]]--;
        cnt[Y[i]]--;
        E[X[i]][Y[i]] = E[Y[i]][X[i]] = true;
	}

    rep(to, 0, N) {
        int cnt = M;
        rep(from, 0, N) if (to != from) {
            if (E[to][from]) {
                Ma[to][to] = add(Ma[to][to], mul(modinv(M), modinv(2)));
                Ma[to][from] = add(Ma[to][from], mul(modinv(M), modinv(2)));
                cnt--;
            }
        }
        Ma[to][to] = add(Ma[to][to], mul(cnt, modinv(M)));
    }

    Vec v(N, 0);
    rep(i, 0, N) v[i] = A[i];

    Ma = fastpow(Ma, K);
    v = mulMatVec(Ma, v);
    rep(i, 0, N) cout << v[i] << endl;
}


#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define rev(v)  if(!v.empty())reverse(v.begin(),v.end())
#define PI 3.141592653589793238
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}

ll inv_mod(ll x){
    return pow_mod(x,mod-2);
}

const ll N=19;
ll inv[N];
ll fac[N];

ll ncr(ll n,ll r){
    if(n<r)
    return 0;

    if(n==r||r==0)
    return 1LL;

    ll x=fac[n];
    ll y=inv[n-r];
    ll z=inv[r];

    return ((x*y)%mod*z)%mod;
}

void solve()
{
/*
   3 1
2 2 1
0

*/
   ll n,m;
   cin>>n>>m;

   if(m==0)
   {
   	cout<<fac[n]<<endl;
   	return;
   }
   ll x[m+1],y[m+1],z[m+1];

   for(ll i=0;i<m;i++)
   cin>>x[i]>>y[i]>>z[i];

   vector<pii>v[n+1];

   for(ll i=0;i<m;i++){
   	--x[i];
   	v[x[i]].pb({y[i],z[i]});
   }
   ll ans=0;

   ll dp[(1LL<<n)+1][n+1];
   memset(dp,0,sizeof(dp));

   for(ll i=0;i<n;i++){
   	   for(ll j=1;j<(1LL<<n);j++){
   	   	     ll cnt=__builtin_popcountll(j);
   	   	     if(cnt!=i+1)
   	   	     continue;
   	   	     bool f=true;
   	   	     for(auto each:v[i]){
   	   	     	     ll lim=each.ff;
   	   	             ll cur=j%(1LL<<lim);
   	   	             ll cnt_now=__builtin_popcountll(cur);
   	   	             if(cnt_now>each.ss){
   	   	             	f=false;
   	   	             	break;
						   }
				   }
				   if(f==false){
				   	continue;
				   }

			////	   cout<<j<<" "<<i<<endl;

				   for(ll k=0;k<n;k++){
				   	  if(j&(1LL<<k)){
				   	  	   ll prev_pot=j^(1LL<<k);
				   	  	   if(i)
				   	  	   dp[j][i]+=dp[prev_pot][i-1];
				   	  	   else
				   	  	   dp[j][i]+=1;
						 }
				   }

		  }
   }

  // cout<<dp[0][1]<<endl;

   ans=dp[(1LL<<n)-1][n-1];
   cout<<ans<<endl;
}
int main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);

//Start from Here.
    fac[0]=1;

  for(ll i=1;i<N;i++)
  fac[i]=(i*fac[i-1]);

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();

//Good Bye!
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for (int i=0; i<n; i++)
#define all(vec) vec.begin(), vec.end()
#define pcnt __builtin_popcount

int main() {
  int N,M;
  cin >> N >> M;
  vector<vector<P>> ps(N+1);
  rep(i, M) {
    int x,y,z;
    cin >> x >> y >> z;
    ps[x].emplace_back(y,z);
  }
  int N2 = 1<<N;
  vector<ll> dp(N2);
  dp[0] = 1;
  vector<int> mask(N+1);
  rep(i,N) mask[i+1] = mask[i]<<1|1;
  rep(s,N2) {
    int c = pcnt(s);
    for (P p : ps[c]) {
      if (pcnt(s&mask[p.first]) > p.second) dp[s] = 0;
    }
    rep(j,N) if (~s>>j&1) {
      dp[s|1<<j] += dp[s];
    }
  }
  cout << dp.back() << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#define ll long long int
#define inf 1000000000000
#define mod 1000000007
#define tc(t) int t; cin >> t; while (t--)
#define all(v) v.begin(),v.end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define ps(x,y)   fixed<<setprecision(y)<<x
using namespace std;

struct segtree {

	vector<int> node;
	int size;
	void init(int n) {

		size = 1;
		while (size < n)size *= 2;
		node.assign(2 * size, 0ll);
	}
	void build(vector<int>&a , int x, int lx, int rx) {

		if (rx - lx == 1) {
			if (lx < (int)a.size()) {
				node[x] = a[lx];
			}
			return;
		}
		int m = (lx + rx) / 2;
		build(a, 2 * x + 1, lx, m);
		build(a, 2 * x + 2, m, rx);
		node[x] = node[2 * x + 1] + node[2 * x + 2];
	}
	void build(vector<int>&a) {
		build(a, 0, 0, size);

	}
	void set(int i, int v, int x, int lx, int rx)
	{
		if (rx - lx == 1) {

			node[x] = v;
			return;
		}
		int m = (lx + rx) / 2;
		if (i < m) {

			set(i, v, 2 * x + 1, lx, m);
		}
		else {
			set(i, v, 2 * x + 2, m, rx);
		}
		node[x] = node[2 * x + 1] + node[2 * x + 2];
	}

	void set(int i, int v) {

		set(i, v, 0, 0, size);
	}

	int get(int l, int r, int x, int lx, int rx) {

		if (lx >= r || l >= rx)return 0;
		if (lx >= l && rx <= r )return node[x];

		int m = (lx + rx) / 2;
		int s1 = get(l, r, 2 * x + 1, lx, m);
		int s2 = get(l, r, 2 * x + 2, m, rx);

		return (s1 + s2);

	}

	int get(int r) {

		return get(0, r, 0, 0, size);
	}

};

void solve()
{
	int h, w, m;
	cin >> h >> w >> m;
	vector<pair<int, int>>obstacles(m);
	vector<vector<int>>by_row(h), by_col(w);
	segtree blocked_row;
	blocked_row.init(h + 2);
	for (int i = 0; i < m; i++) {
		cin >> obstacles[i].F >> obstacles[i].S;
	}
	sort(all(obstacles));
	for (auto [x, y] : obstacles) {
		--x, --y;
		by_row[x].push_back(y);
		by_col[y].push_back(x);
	}
	for (int x = 0; x < h; x++) {
		by_row[x].push_back(w);
	}
	for (int y = 0; y < w; y++) {
		by_col[y].push_back(h);
	}
	int reachable_rows = by_col[0][0];
	int reachable_cols = by_row[0][0];

	ll ans = 0;
	for (int x = 0; x < reachable_rows; x++) {
		ans += by_row[x][0];
	}

	for (int y = 1; y < reachable_cols; y++) {
		int height = by_col[y][0];

		ans += max(0LL, height * 1LL - reachable_rows * 1LL);
		ans += blocked_row.get(min(height, reachable_rows));
		for (auto x : by_col[y]) {
			blocked_row.set(x, 1);
		}
	}
	cout << ans << endl;

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

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const int INF = 1e9 + 47;
const LL LINF = 1LL * INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

VI g[1 << 19];
int cnt[1 << 19];
int u[1 << 19];
int m = 0;
int us = 0;

void dfs(int v)
{
	m += SZ(g[v]);
	u[v] = 1;
	us++;
	for(int to : g[v])
		if(!u[to])
			dfs(to);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	VI a(n), b(n);
	FOR(i, 0, n)
	{
		cin >> a[i] >> b[i];
		cnt[a[i]]++;
		cnt[b[i]]++;
		g[a[i]].PB(b[i]);
		g[b[i]].PB(a[i]);
	}
	int ans = 0;
	FOR(i, 1, 400001)
		if(cnt[i] && !u[i])
		{
			m = 0;
			us = 0;

			dfs(i);

			m /= 2;
			ans += min(m, us);
		}
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
int main(void){
    // Your code here!
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 int a,b;
 cin >> a >> b;
 cout << (abs(a-b)<3 ? "Yes" : "No");
 return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000007
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;

int sum(int a)
{
    int ans =0;
    while(a)
    {
        ans+=a%10;
        a/=10;
    }
    return ans;
}
int main(){
   std::ios::sync_with_stdio(false);
   cin.tie(0);

 int a,b;
 cin>>a>>b;

 cout<<max(sum(a),sum(b))<<endl;
return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cctype>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=5e5+500;
ll inf=1e18;

int gti(void)
{
	char c=getchar();
	int ret=0,st=1;
	for (;c!='-'&&!isdigit(c);c=getchar());
	if (c=='-') st=-1,c=getchar();
	for (;isdigit(c);c=getchar()) ret=ret*10+c-'0';
	return ret*st;
}

struct edge{edge *nxt;int to;ll len;}pool[N],*pt[N],*p=pool;
void addedge(int a,int b,int l)
{
	*(++p)=(edge){pt[a],b,l},pt[a]=p;
}

struct P
{
	int id;
	ll dis;
	bool operator<(const P &b)const
	{
		return dis>b.dis;
	}
};
priority_queue<P> hp;
ll dis[N];
void dijkstra(int v,int n)
{
	for (int i=1;i<=n;i++) dis[i]=inf;
	for (edge *i=pt[v];i;i=i->nxt)
	{
		dis[i->to]=min(dis[i->to],i->len);
		hp.push((P){i->to,dis[i->to]});
	}
	P now;
	for (int i=1;i<=n*2;i++)
	{
		if (hp.size()==0) break;
		for (now=hp.top(),hp.pop();hp.size()&&dis[now.id]!=now.dis;)
			now=hp.top(),hp.pop();
		if (dis[now.id]!=now.dis) break;
		for (edge *i=pt[now.id];i;i=i->nxt)
			if (dis[i->to]>dis[now.id]+i->len)
			{
				dis[i->to]=dis[now.id]+i->len;
				hp.push((P){i->to,dis[i->to]});
			}
	}
	if (dis[v]>=inf) puts("-1");
	else printf("%lld\n",dis[v]);
}

int main(void)
{
	int n=gti(),m=gti();
	for (int i=1;i<=m;i++)
	{
		int u=gti(),v=gti(),w=gti();
		addedge(u,v,w);
	}
	for (int i=1;i<=n;i++)
		dijkstra(i,n);
	return 0;
}

#pragma region Region_1

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (ll i = s; i < t; ++i)
#define rng(a) a.begiGn(), a.end()
#define rrng(a) a.rbegin(), a.rend()
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VP = vector<P>;
using VS = vector<string>;
using VC = vector<char>;
using VVC = vector<vector<char>>;
#define MOD 1000000007
// #define MOD 998244353
const int INF = (int)1e9 + 10;         // int max > 2*10^9
const long long INFL = (ll)2e18 + 10;  // ll max > 9*10^18

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

template <class T>
T sum(const vector<T>& v) {
    T res = 0;
    for (size_t i = 0; i < v.size(); ++i) res += v[i];
    return res;
}

/////////////////////////////////////////////////////////
// print like python
// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed
/////////////////////////////////////////////////////////
void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T>& vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << " ";
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>>& df) {
    for (auto& vec : df) {
        print(vec);
    }
}

#pragma endregion Region_1
/////////////////////////////////////////////////////////
struct mint {
    ll x;  // typedef long long ll;
    int mod;
    mint(ll x = 0, int mod = MOD) : x((x % mod + mod) % mod), mod(mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    // x^t
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;  // 桁ずらし
        if (t & 1) a *= *this;
        return a;
    }

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

mint calc_cmb(int n, int m) {
    if (n - m < m) m = n - m;
    mint x = 1;
    mint d = 1;
    for (int i = 0; i < m; ++i) {
        x *= (n - i);
        d *= (i + 1);
    }
    return x / d;
}
int main() {
    std::cout << std::setprecision(15);
    //////////////////////////////////////////
    ll n, m, k;
    cin >> n >> m >> k;
    if (n > m + k) {
        print(0);
        return 0;
    }

    mint a = calc_cmb((n + m), m);
    mint b = calc_cmb((n + m), m + k + 1);
    if (k + 1 > n) b = mint(0);

    print((a - b).x);

    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI   3.14159265358979323846264338327950

#define PB push_back

#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long
const int INF = INT_MAX;
const int mod = 1e9 + 7;

int main()
{
	FAST;
	int n;
	cin >> n;
	int it = 0;
	int a[n + 5];
	map<int, int> m;
	for(int i = 0; i < n; i ++){
		cin >> a[i];

	}
	for(int i = 0 ; i < n; i ++){
		m[a[i]] = 1;
		for(int j = it; j < 200002; j ++){
			if(! m[j]){

				cout << j << endl;;
				it = j;
				break;
			}
		}
	}
	return 0;
}

#define _DEBUG
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//デバッグ
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug1(x1) cout<<#x1<<": "<<x1<<endl
#define debug2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug5,debug4,debug3,debug2,debug1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
    ll N;
    cin>>N;
    vl p(N);
    set<ll> st;
    REP(i,200010){
        st.insert(i);
    }
    REP(i,N){
        cin>>p[i];
    }

    REP(i,N){
        st.erase(p[i]);
        cout<<*st.begin()<<endl;
    }

}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e, p) for (ll i = (ll)s; i < (ll)e; i += p)
#define ALL(vec) vec.begin(), vec.end()

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

    vector<ll> a(n), b(n);
    rep (i, 0, n, 1){
        cin >> a[i];
    }
    rep (i, 0, n, 1){
        cin >> b[i];
    }

    ll m = 0, ma = 0;
    rep (i, 0, n, 1){
        ma = max(ma, a[i]);
        m = max(m, ma * b[i]);
        cout << m << endl;
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>b)return 0; a=b; return 1;}
#define bitUP(x,a) ((x>>a)&1)
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double EPS = 1e-6;
long double PI = acos(-1);
const ll INF=(1LL<<62);
const int MAX=(1<<30);
constexpr ll MOD=1000000000+7;

inline void bin101(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

using pii=pair<int,int>;
using pil=pair<int,ll>;
using pli=pair<ll,int>;
using pll=pair<ll,ll>;
using psi=pair<string,int>;
using pis=pair<int,string>;
using psl=pair<string,ll>;
using pls=pair<ll,string>;
using pss=pair<string,string>;

using Graph=vector<vector<int>>;

template<typename T >
struct edge {
  int to;
  T cost;
  edge()=default;
  edge(int to, T cost) : to(to), cost(cost) {}

};
template<typename T>
using WeightGraph=vector<vector<edge<T>>>;

//1-indexed vector cin
template<typename T>
inline void vin1(vector<T> &v){
    for(size_t i=1;i<v.size();i++) cin>>v[i];
}

//0-indexed vector cin
template<typename T>
inline void vin0(vector<T> &v){
    for(size_t i=0;i<v.size();i++) cin>>v[i];
}

//1-indexed vector<vector> cin
template<typename T>
inline void vin1(vector<vector<T>> &v){
    for(size_t i=1;i<v.size();i++){
        for(size_t j=1;j<v[i].size();j++) cin>>v[i][j];
    }
}

//0-indexed vector<vector> cin
template<typename T>
inline void vin0(vector<vector<T>> &v){
    for(size_t i=0;i<v.size();i++){
        for(size_t j=0;j<v[i].size();j++) cin>>v[i][j];
    }
}

//要素数n 初期値x
template<typename T>
inline vector<T> vmake(size_t n,T x){
  return vector<T>(n,x);
}

//a,b,c,x data[a][b][c] 初期値x
template<typename... Args>
auto vmake(size_t n,Args... args){
    auto v=vmake(args...);
    return vector<decltype(v)>(n,move(v));
}

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

//pair cin
template<typename T, typename U>
inline istream &operator>>(istream &is,pair<T,U> &p) {
  is>>p.first>>p.second;
  return is;
}

//ソート
template<typename T>
inline void vsort(vector<T> &v){
    sort(v.begin(),v.end());
}

//逆順ソート
template<typename T>
inline void rvsort(vector<T> &v){
  sort(v.rbegin(),v.rend());
}

//1ビットの数を返す
inline int popcount(int x){
  return __builtin_popcount(x);
}
//1ビットの数を返す
inline int popcount(ll x){
  return __builtin_popcountll(x);
}

void solve(){
    int N;
    cin>>N;
    vector<ll> a(N),b(N);
    vin0(a);
    vin0(b);
    ll max_a=-1;
    ll max_b=-1;
    for(int i=0;i<N;i++){
        chmax(max_a,a[i]);
        b[i]*=max_a;
        chmax(max_b,b[i]);
        chmax(b[i],max_b);
    }
    for(int i=0;i<N;i++){
        cout<<b[i]<<"\n";
    }
}

int main(){
    bin101();
    int T=1;
    //cin>>T;
    while(T--) solve();
}


#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18;
void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);}
void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);}
void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<fixed<<setprecision(10)<<h;perr0(t...);}
void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);}
void ioinit() { cout << fixed << setprecision(15); ios_base::sync_with_stdio(0); cin.tie(0); }
// clang-format on

#ifdef ONLINE_JUDGE
void dbg(vector<ll> &p, ll j) {}
#else
void dbg(vector<ll> &p, ll j) {
    ll n = p.size() - 1;
    for (ll i = 1; i <= n; i++) {
        perr0(p[i], " ");
    }

    if (j > 0) {
        perr("!", j, "!");
    } else {
        perr();
    }
}
#endif

void output(vector<ll> &ops) {
    ll m = ops.size();
    print(m);
    for (ll i = 0; i < m; i++) {
        if (i > 0) print0(" ");
        print0(ops[i]);
    }
    print();
}
void op(vector<ll> &ops, vector<ll> &p, bool &even, ll i) {
    //    perr(i);
    swap(p[i], p[i + 1]);
    ops.push_back(i);
    even = !even;
    dbg(p, i);
}

void solve3(ll n, vector<ll> &p, bool even0, vector<ll> &ops) {
    bool even = even0;
    while (true) {
        if (p[1] == 1 && p[2] == 2 && p[3] == 3) {
            break;
        }
        if (even) {
            op(ops, p, even, 2);
        } else {
            op(ops, p, even, 1);
        }
    }
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> p(n + 1);
    for (ll i = 1; i <= n; i++) {
        cin >> p[i];
    }

    if (n == 2) {
        vector<ll> ops2;
        if (p[1] == 2) {
            ops2.push_back(1);
        }
        output(ops2);
        return;
    }

    vector<ll> ops;
    ll searchval = n;
    bool even = false;
    while (true) {
        if (searchval == 3) {
            solve3(3, p, even, ops);
            break;
        }
        ll searchi = -1;
        for (ll i = 1; i <= n; i++) {
            if (p[i] == searchval) {
                searchi = i;
                break;
            }
        }
        if (searchi == searchval) {
            searchval--;
            continue;
        }
        bool cureven = (searchi % 2 == 0);
        if (cureven && !even) {
            if (searchi == 2) {
                op(ops, p, even, 1);
                op(ops, p, even, 2);
                searchi = 1;
            } else {
                op(ops, p, even, 1);
            }
        } else if (!cureven && even) {
            if (searchi == 3) {
                op(ops, p, even, 2);
                op(ops, p, even, 1);
                op(ops, p, even, 2);
                searchi = 1;
            } else {
                op(ops, p, even, 2);
            }
        }
        for (ll i = searchi;; i++) {
            if (i >= searchval) break;
            op(ops, p, even, i);
        }
        searchval--;
    }
    output(ops);
}
int main() {
    ioinit();
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
}

/* bimillahir rahmanir rahim...
 * AUTHOR
 * mubin_akib */
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b) - 1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a) - 1; i >= 0; i--)
#define REP(i, a, b) for(int i = a; i <= (b); ++i)
#define trav(a,x) for(auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

const int mod = 1e9 + 7;
const char nl = '\n';

void solve(){
    int n;
    cin >> n;
    vi v(n), w(n);
    F0R(i, n){
        cin >> v[i];
    }
    F0R(i, n){
        cin >> w[i];
    }
    int ans = 0;
    F0R(i, n){
        ans += (v[i] * w[i]);
    }
    if(ans == 0){
        cout << "Yes" << nl;
    }
    else{
        cout << "No" << nl;
    }
}

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


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define tc int t; cin>>t; while(t--)
#define shweta ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fl for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MAX_SIZE 100005
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define looprev(i,b,a) for(int i=b;i>=a;i--)
#define inf 1e17
// char adj[1001][1001];
// int vis[1001][1001];
// vector<char> finalstring;
// bool bfound = false;
// int dx[] = {0, -1, 1, 0};
// int dy[] = {1, 0, 0, -1};
// string path = "RUDL";
// int N, M;
// int x1 = 0, y1 = 0;
// void bfs(int srcX, int srcY)
// {
//     queue<pair<int, int>> q;
//     q.push({srcX, srcY});
//     vis[srcX][srcY] = 1;
//     while (!q.empty())
//     {
//         int currX = q.front().first;
//         int currY = q.front().second;
//         vis[currX][currY]=1;
//         q.pop();
//         // cout<<currX<<" "<<currY<<endl;
//         for (int i = 0; i < 4; i++)
//         {   int newX = currX + dx[i];
//             int newY = currY + dy[i];
//             if (newX < 1 || newX > N || newY < 1 || newY > M)continue;
//             if (adj[newX][newY] == '#' || vis[newX][newY] == 1)continue;
//             if (adj[newX][newY] == '.')
//             {
//                 q.push({newX, newY});
//                 vis[newX][newY] = 1;
//             }
//             cout<<newX<<" "<<newY<<" "<<adj[newX][newY]<<" "<<vis[newX][newY]<<endl;
//             if (adj[newX][newY] == 'B')
//             {
//                 x1 = newX;
//                 y1 = newY;
//                 vis[newX][newY] = 1;
//                 bfound = true;
//                 break;
//             }
//         }
//         if(bfound)
//         {
//             break;
//         }
//     }

// }
// signed main()
// {
//     cin >> N >> M;
//     int corax, coray;
//     for (int i = 1; i <= N; i++)
//     {
//         for (int j = 1; j <= M; j++)
//         {
//             cin >> adj[i][j];
//             if (adj[i][j] == 'A')
//             {
//                 corax = i;
//                 coray = j;
//             }
//         }
//     }
//     for (int i = 1; i <= N; i++)
//     {
//         for (int j = 1; j <= M; j++)
//         {
//             vis[i][j]=0;
//         }
//     }
//     bfs(corax, coray);
//     if (bfound == false)
//     {
//         cout << "NO\n";
//     }
//     else
//     {
//         while (1)
//         {
//             int a = x1;
//             int b = y1;
//             finalstring.pb(path[vis[x1][y1]]);
//             x1 = x1 - dx[vis[a][b]];
//             y1 = y1 - dy[vis[a][b]];
//             if (x1 == corax && y1 == coray)
//                 break;
//         }
//         cout << "YES\n" << finalstring.size() << endl;
//         // for(int i=finalstring.size()-1;i>=0;i)
//         reverse(finalstring.begin(), finalstring.end());
//         for (auto it : finalstring)
//         {
//             cout << it;
//         }
//     }
// }
signed main()
{
    ll n;
cin>>n;
// cout<<n<<endl;
map <ll,ll> ansh;
map <ll,ll> ::iterator itr;
for(ll i=0;i<n;i++){
    ll a;
    cin>>a;
    ansh[a]++;
}
ll ans=((n)*(n-1))/2;
// cout<<ans<<endl;
itr=ansh.begin();

while(itr!=ansh.end()){
    ans-=((itr->second)*(itr->second-1))/2;
    itr++;

}
cout<<ans<<endl;

}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    ll arr[n];
    map<ll,ll> m;
    for(ll i =0 ;i<n;i++){
        cin>>arr[i];
        m[arr[i]]++;
    }
    ll ans = 0;
    for(ll i =0 ;i<n;i++){
        ans += (n-i-m[arr[i]]);
        if(m[arr[i]]>0)m[arr[i]]--;
    }
    cout<<ans;
}


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

int main(void) {
    long long n;
    cin >> n;
    char digits[19];
    sprintf(digits, "%lld", n);

    int len = strlen(digits);

    int lim = 1 << len;
    int ans = INT_MAX;
    for (int i = 1; i <= lim; ++i) {
        int cur = 0, cnt = len;
        for (int j = 0; j < len; ++j) {
            if ((i >> j) & 1) {
                cur += digits[j] - '0';
                cnt--;
            }
        }
        if (cur % 3 == 0) ans = min(ans, cnt);
    }
    if (ans == len)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repd(i, n) for(int i = 0; i <= (n); ++i)
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
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; }

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    ll ans = 0;
    rep(j, n) {
        ans += j-mp[a[j]];
        mp[a[j]]++;
    }
    cout << ans << endl;
    return 0;
}


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

int  main()
{
	int a[5];
	ll sum=0;
	while(cin>>a[1]>>a[2]>>a[3]>>a[4])
	{
		sum=a[1]+a[2]+a[3]+a[4];
		int flag=0;
		for(int i=1;i<=4;i++)
		{
			if(sum-a[i]==a[i])
			{
				flag=1;
				break;
			}
		}
		if(!flag)
		{
			for(int i=1;i<=3;i++)
		{
			for(int j=i+1;j<=4;j++)
			{
				if(sum-a[i]-a[j]==a[i]+a[j])
				{
					flag=1;
					break;
				}
			}
			if(flag==1)break;
		}
		}
		if(flag)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
namespace atcoder {}
using namespace atcoder;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long A, long long B, long long C, long long D) {
  int c[4] = {A, B, C, D};
  int sm = A + B + C + D;
  rep(i, 1 << 4) {
    int tmp = 0;
    rep(j, 4) {
      if ((i >> j) & 1) {
        tmp += c[j];
      }
    }
    if (tmp * 2 == sm) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}

signed main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  long long D;
  scanf("%lld", &D);
  solve(A, B, C, D);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


// atcoder/arc105/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, m;
  while (cin >> n >> m) {
    vec<lli> w(n);
    cin >> w;
    vec<pair<lli, lli>> v(m);
    cin >> v;

    {
      int mx = *max_element(w.begin(), w.end());
      bool f = true;
      each (i, v) f = f && (mx <= i.second);
      unless (f) {
        cout << -1 << endl;
        continue;
      }
    }

    const int N = 10;
    const lli inf = 1LL << 60;
    lli mn = inf;

    sort(v.begin(), v.end(), [] (auto a, auto b) {
      if (a.second != b.second) return a.second < b.second;
      return a.first > b.first;
    });
    const int M = 1e5 + 5;
    static lli mx[M];
    fill(mx, mx + M, inf);
    vec<lli> u;
    for (int i = 0; i < m; ++i) {
      u.push_back(v[i].second);
      mx[i] = v[i].first;
      if (i) {
        setmax(mx[i], mx[i - 1]);
      }
    }

    sort(w.begin(), w.end());
    do {
      static lli g[N][N];
      fill(&g[0][0], &g[N - 1][N - 1] + 1, 0);
      for (int i = 0; i < n; ++i) {
        int sum = 0;
        for (int j = i; j < n; ++j) {
          sum += w[j];
          auto itr = lower_bound(u.begin(), u.end(), sum);
          if (itr != u.begin()) {
            --itr;
            setmax<lli>(g[i][j], mx[itr - u.begin()]);
          }
        }
      }

      // if (w == vec<lli>({1, 2, 4})) {
      //   for (int i = 0; i < n; ++i) {
      //     for (int j = 0; j < n; ++j) {
      //       cout << g[i][j] << ' ';
      //     }
      //     cout << endl;
      //   }
      // }

      static lli dp[N];
      fill(dp, dp + N, -inf);
      dp[0] = 0;
      for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
          setmax(dp[j], dp[i] + g[i][j]);
        }
      }
      setmin(mn, dp[n - 1]);
    } while (next_permutation(w.begin(), w.end()));
    cout << mn << endl;
  }

  return 0;
}

#include<iostream>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define int long long
using namespace std;
int c[502][502],a[502],b[502];
signed main(){
    ios::sync_with_stdio(false);
    int n; cin>>n;
    rep(i,1,n)rep(j,1,n)cin>>c[i][j];
    bool flag=true;
    rep(i,1,n){rep(j,2,n){
        if(i==1)a[j]=c[i][j]-c[i][j-1];
        else if(a[j]!=c[i][j]-c[i][j-1]){flag=false;break;}
    }if(!flag)break;}
    if(!flag){cout<<"No\n";return 0;}
    rep(j,1,n){rep(i,2,n){
        if(j==1)b[i]=c[i][j]-c[i-1][j];
        else if(b[i]!=c[i][j]-c[i-1][j]){flag=false;break;}
    }if(!flag)break;}
    if(!flag){cout<<"No\n";return 0;}
    int mna=0,mnb=0;
    rep(i,1,n){
        a[i]+=a[i-1],b[i]+=b[i-1];
        mna=min(mna,a[i]),mnb=min(mnb,b[i]);
    }
    //cout<<mna<<" "<<mnb<<endl;
    if(c[1][1]+mna+mnb<0){cout<<"No\n";return 0;}
    int ada=-mna,adb=c[1][1]-ada;
    cout<<"Yes\n";
    rep(i,1,n)cout<<b[i]+adb<<" ";
    cout<<endl;
    rep(i,1,n)cout<<a[i]+ada<<" ";
    cout<<endl;
    return 0;
}


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

int main() {
    int64_t n, k;
    cin >> n >> k;

    while (k--) {
        if (n % 200 == 0) {
            n /= 200;
        } else {
            n = 1000 * n + 200;
        }
    }
    cout << n << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
template <typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr)
{
    os << '{';
    string sep;
    for (const auto &x : arr)
        os << sep << x, sep = ", ";
    return os << '}';
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V)
{
    os << "[ ";
    for (auto v : V)
        os << v << " ";
    return os << "]";
}
template <class T>
ostream &operator<<(ostream &os, set<T> S)
{
    os << "{ ";
    for (auto s : S)
        os << s << " ";
    return os << "}";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) { return os << "(" << P.first << "," << P.second << ")"; }
template <class L, class R>
ostream &operator<<(ostream &os, map<L, R> M)
{
    os << "{ ";
    for (auto m : M)
        os << "(" << m.first << ":" << m.second << ") ";
    return os << "}";
}
#ifdef LMAO
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...) 42
#endif
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define tcase  \
    int tt;    \
    cin >> tt; \
    while (tt--)
#define tcase2 \
    int tt;    \
    cin >> tt; \
    for (int qq = 1; qq <= tt; qq++)
#define all(x) x.begin(), x.end()
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007;
const int INF = 1e8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define forne(i, a, b) for (int i = a; i <= b; i++)
/*****************start************/
#define int ll
int op(int x)
{
    if (x % 200)
    {
        return x * 1000ll + 200ll;
    }
    else
    {
        return x / 200;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed << setprecision(25);
    cerr << fixed << setprecision(10);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;i++)
    {
        n=op(n);
    }
    cout<<n<<endl;
    return 0;
}


#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <functional>
#include <numeric>
#include <iomanip>
#include <stdio.h>
//end of libraries
#define lnf 3999999999999999999
#define inf 999999999
#define PI 3.14159265359
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define rsz(a,n) a.resize(n)
#define pii pair <int,int>
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define drep(i,n) for(int i = n-1 ; i >= 0 ; i--)
#define crep(i,x,n) for(int i = x ; i < n ; i++)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

const int max_n = 550;

using namespace std;
int n;
int c[max_n][max_n];
int a[max_n] , b[max_n];
int main(){
fcin;
	cin >> n;
	rep(i,n) {
		rep(j,n) {
			cin >> c[i][j];
		}
	}

	a[0] = 0;
	int can = 1 , mn = 0;
	rep(i,n) {
		int cur = 0;
		rep(j,n) {
			if(i == 0) b[j] = c[i][j];
			else {
				if(j == 0) cur = c[i][j]-b[j];
				else {
					if(cur != c[i][j] - b[j]) can = 0;
				}
				if(cur<0)mn=max(mn,abs(cur));
			}
		}
	}
	a[0] = mn;
	rep(i,n) {
		rep(j,n) {
			if(i==0) b[j] = c[i][j] - a[i];
			else {
				a[i] = c[i][j] - b[j];
			}
		}
	}
	rep(i,n) {if(a[i]<0) can = 0;}
	rep(i,n) {if(b[i]<0) can = 0;}
	if(can==0){
		cout << "No\n";

	}else {
		cout << "Yes\n";
		rep(i,n) {
			cout << a[i];
			if(i+1<n) cout << " ";
		}
		cout << "\n";
		rep(i,n) {
			cout << b[i];
			if(i+1<n) cout << " ";
		}
	}
/*
*/

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using ll = long long;
using lint = long long;
typedef vector<long long> vint;
typedef pair<long long, long long> pint;
#define INF INT32_MAX / 2
#define INF64 INT64_MAX / 2
#define EPS 0.001
#define EPS14  1.0E-14
#define REP(i, n) for (ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define c(n) cout<<n<<endl;
#define cf(n) cout<<fixed<<setprecision(15)<<n<<endl;
template <class T>inline bool chmin(T&a,T b) {if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T&a,T b) {if(a<b){a=b;return true;}return false;}
template<class T>inline T sum(T n){return n*(n+1)/2;}
map<ll,ll> prime_fac(ll A) {map<ll,ll>mp;for(ll i=2;i*i<=A;i++){while(A%i== 0){mp[i]++;A/=i;}}if(A!=1){mp[A]=1;}return mp;}
bool is_prime(ll N){if(N<=1)return false;for(ll i=2;i*i<=N;i++){if(N%i==0) return false;}return true;}
template<class T>inline T myceil(T a,T b){return (a+(b-1))/b;}
ll pw(ll x, ll n){ll ret=1;while(n>0){if(n&1){ret*=x;}x *= x;n >>= 1;}return ret;}
bool is_product_overflow(long long a,long long b) {long prod=a*b;return (prod/b!=a);}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<std::vector<long long>> C){
    vector<vector<ll>> ans(2, vector<ll>(N, 0));

    ans[0][0] = C[0][0];
    ans[1][0] = 0;

    for (int i = 1; i < N; i++) {
        ans[0][i] = C[i][0] - 0;
    }

    ll min = 0;
    for (int i = 1; i < N; i++) {
        ans[1][i] = C[0][i] - C[0][0];

        chmin(min, ans[1][i]);
    }

    if (min < 0) {
        for (int i = 0; i < N; i++) {
            ans[0][i] -= -min;
        }

        for (int i = 0; i < N; i++) {
            ans[1][i] += -min;
        }
    }

    REP (i, N) {
        REP (j, N) {
            if (ans[0][i] + ans[1][j] != C[i][j]) {
                c(NO)
                return;
            }
        }
    }

    c(YES)

    REP (i, N) {
        cout << ans[0][i] << " ";
    }
    cout << endl;

    REP (i, N) {
        cout << ans[1][i] << " ";
    }
    cout << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::vector<long long>> C(N, std::vector<long long>(N));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
            scanf("%lld",&C[i][j]);
        }
    }
    solve(N, std::move(C));
    return 0;
}


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

int main() {
	    int n; cin>>n;
	    int a[n];
	    for(int i=0;i<n;i++){
	        cin>>a[i];
	    }
	    int k = *max_element(a,a+n);
	    int H[k]={0};
	    for(int i=0;i<n;i++){
	        ++H[a[i]];
	    }
	    int f=0;
	    for(int i=0;i<k;i++){
	        if(H[i]>1){
	            f=1;
	            i=k+1;
	        }
	    }
	    if(f==0){
	        cout<<"Yes"<<"\n";
	    }
	    else if(f==1){
	        cout<<"No"<<"\n";
	    }
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

void output(vector<int> &a){
  cout << a.size();
  for(auto &nx : a){
    cout << ' ' << nx;
  }
  cout << '\n';
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto &nx : a){cin >> nx;}
  vector<vector<int>> bk(200,vector<int>(0));

  int cnt=min(n,8);
  for(int i=1;i<(1<<cnt);i++){
    int sig=0;
    vector<int> s;
    for(int j=0;j<cnt;j++){
      if(i&(1<<j)){
        s.push_back(j+1);
        sig+=a[j];sig%=200;
      }
    }
    if(bk[sig].size()!=0){
      cout << "Yes\n";
      output(bk[sig]);
      output(s);
      return 0;
    }
    else{bk[sig]=s;}
  }
  cout << "No\n";
  return 0;
}


#include <cstdio>
#define N 400010
#define mo 3
#define ll long long
#define fo(x, a, b) for (int x = (a); x <= (b); x++)
#define fd(x, a, b) for (int x = (a); x >= (b); x--)
using namespace std;
int n, a[N]; char s[N];
ll ans = 0;

ll ksm(ll x, int y) {
	ll s = 1;
	while (y) {
		if (y & 1) s = s * x % mo;
		x = x * x % mo, y >>= 1;
	}
	return s;
}

ll C(int x, int y) {
	if (x > y) return 0;
	ll res = 1;
	fo(i, x + 1, y) res = res * i;
	fo(i, 1, y - x) res = res * ksm(i, mo - 2);
	return res % mo;
}

ll Lucas(int x, int y) {
	if (x < mo && y < mo) return C(x, y);
	else return Lucas(x / mo, y / mo) * C(x % mo, y % mo) % mo;
}

int main() {
	scanf("%d%s", &n, s + 1);
	fo(i, 1, n)
		if (s[i] == 'R') a[i] = 0;
		else if (s[i] == 'W') a[i] = 1;
		else a[i] = 2;
	fo(i, 1, n)
		ans = (ans + Lucas(i - 1, n - 1) * a[i]) % 3;
	if (n % 2 == 0) ans = -ans;
	ans = (ans % 3 + 3) % 3;
	if (ans == 0) printf("R\n");
	else if (ans == 1) printf("W\n");
	else printf("B\n");
	return 0;
}

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

void debug_out(){
    cerr << endl;
}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef local
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
#else
#define debug(...) 55
#endif

const int N = 10005;
char s[N];
int a[N], b[N], c[N], n;
int ok(int k){
	for(int i = 1; i <= n; i++) b[i] = a[i] / k, c[i] = a[i] % k;
	for(int i = 1; i < n; i++){
		int x = b[i], y = b[i + 1];
		if(x == y) return 0;
		if(x == y - 1 && c[i] > c[i + 1]) return 0;
		if(x == y + 1 && c[i] < c[i + 1]) return 0;
	}
	return 1;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int ans = 0;
	cin >> n;
	n++;
	cin >> s + 1;
	int mn = 1e9;
	for(int i = 1; i <= n; i++) cin >> a[i], mn = min(mn, a[i]);
	for(int i = 1; i <= 10000; i++){
		if(ok(i)) ans = max(ans, i);
	}
	cout << ans << '\n';
	for(int i = 1; i <= ans; i++){
		for(int j = 1; j <= n; j++){
			int x = a[j] / ans, y = a[j] % ans;
			if(i <= y) x++;
			cout << x << ' ';
		}
		cout << '\n';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int i;
    cin>>s;
    s[3]=s[0];
   for(i=1;i<4;i++)
   {
       cout<<s[i];
   }
   cout<<endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <bitset>

using namespace std;

int main(void) {
  int price;
  // input
  cin >> price;

  int p = price * 1.08;

  if (206 > p) {
    cout << "Yay!" << endl;
  } else if(206 == p){
    cout << "so-so" << endl;
  }else{
    cout << ":(" << endl;
  }
}


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

#define pb push_back
#define FOR(i,f,n) for(int i=f;i<n;i++)
#define FORI(i,f,n) for(int i=f;i>=n;i--)
#define sz(a) ((int)(a).size())
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define alli(a) (a).rbegin(),(a).rend()
#define approx(a) fixed<<setprecision(a)
#define trav(a,x) for(auto& a : x)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,bool> pib;
typedef pair<ll,bool> plb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class T> void ckmin(T &a, const T &b) { a = min(a, b); }
template <class T> void ckmax(T &a, const T &b) { a = max(a, b); }

template <class T> void read(vector<T> &v);
template <class F, class S> void read(pair<F, S> &p);
template <class T> void read(T &x) {cin>>x;}
template <class R, class... T> void read(R& r, T&... t){read(r); read(t...);};
template <class T> void read(vector<T> &v) {trav(x, v) read(x);}
template <class F, class S> void read(pair<F, S> &p) {read(p.ff, p.ss);}

template <class F, class S> void pr(const pair<F, S> &x);
template <class T> void pr(const T &x) {cout<<x;}
template <class R, class... T> void pr(const R& r, const T&... t) {pr(r); pr(t...);}
template <class F, class S> void pr(const pair<F, S> &x) {pr("{", x.ff, ", ", x.ss, "}");}
void ps() {pr("\n");}
template <class T> void ps(const T &x) {pr(x); ps();}
template <class T> void ps(vector<T> &v) {trav(x, v) pr(x, ' '); ps();}
template <class F, class S> void ps(const pair<F, S> &x) {pr(x.ff, ' ', x.ss); ps();}
template <class R, class... T> void ps(const R& r, const T &...t) {pr(r, ' '); ps(t...);}

const int MXN = 2e5+1;
vi adj[MXN], level[MXN], in(MXN), out(MXN);
int timer = 0;

void dfs(int v, int d){
    in[v] = ++timer;
    level[d].pb(in[v]);
    for(int u : adj[v]){
        dfs(u, d+1);
    }
    out[v] = ++timer;
}

void solve(){
    int n; read(n);
    FOR(i,1,n){
        int x; read(x);
        adj[x].pb(i+1);
    }
    dfs(1, 0);
    int q; read(q);
    FOR(i,0,q){
        int u, d; read(u, d);
        int ans = lower_bound(all(level[d]), out[u]) - lower_bound(all(level[d]), in[u]);
        ps(ans);
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int, int> >
#define vpll vector <pair <long long, long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define vb vector <bool>
#define vvb vector <vb>
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MANX MAXN
#define itn int
#define dbg(x); {cout << #x << "=" << x << ", ";}
#define in(x); { for (auto &to : x) cin >> to;}
#define out(x); { for (auto &to : x) cout << to << " "; cout << '\n'; }

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

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

const ll INFLL = 1e18;
const int MAXN = 2e5 + 100;
const ll INF = 1e9;
const int mod1 = 1e9 + 7;
const int mod2 = 1e9 + 21;
vvi g;
vvi d;
int ans[MAXN];
vvpii qu;
vector<map<int, int>> mm;

void dfs(int s, int ok) {
    mm[s][ok++]++;
    for (auto to:g[s]) {
        dfs(to, ok);
        if (mm[to].size() > mm[s].size())
            swap(mm[to], mm[s]);
        for (auto too:mm[to])
            mm[s][too.fi] += too.se;
    }
    for (auto to:qu[s]) {
        ans[to.se] = (mm[s].find(to.fi) == mm[s].end() ? 0 : mm[s][to.fi]);
    }
}

void solve() {
    int n;
    cin >> n;
    mm = vector<map<int, int>>(n);
    d = vvi(n);
    g = vvi(n);
    qu = vvpii(n);
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        x--;
        g[x].pb(i);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        qu[x].pb({y, i});
    }
    dfs(0, 0);
    for (int i = 0; i < q; i++)
        cout << ans[i] << '\n';
}

int main() {
#ifdef Mip182
    freopen("a.in", "r", stdin);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int _t;
    _t = 1;
//    cin>>_t;
    while (_t--)
        solve();
#ifdef Mip182
    cout << '\n' << "Time : " << (double) (clock()) / CLOCKS_PER_SEC << '\n';
#endif
}


#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
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;
using namespace std;
ll n;
ll res=1e18;
void solve(vector<ll>& r,vector<ll>& g,vector<ll>& b){
    rep(i,r.size()){
            auto itr=lower_bound(g.begin(),g.end(),r[i]);
            ll k=itr-g.begin();
            if(k!=g.size())chmin(res,abs(g[k]-r[i]));
            if(k!=0)chmin(res,abs(g[k-1]-r[i]));
        }
        priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>> > que1,que2;
        rep(i,b.size()){
            auto itr=lower_bound(g.begin(),g.end(),b[i]);
            ll k=itr-g.begin();
            ll buf3=1e18;
            if(k!=g.size())buf3=abs(b[i]-g[k]);
            if(k!=0){
                ll buf=abs(b[i]-g[k-1]);
                chmin(buf3,buf);
            }
            itr=lower_bound(r.begin(),r.end(),b[i]);
            k=itr-r.begin();
            ll buf4=1e18;
            if(k!=r.size())buf4=abs(b[i]-r[k]);
            if(k!=0){
                ll buf=abs(b[i]-r[k-1]);
                chmin(buf4,buf);
            }
            que1.push({buf3,i});
            que2.push({buf4,i});
        }
        if(que1.size()==0)return;
        ll buf1_1=que1.top().first;
        ll buf2_1=que2.top().first;
        que1.pop();que2.pop();

        chmin(res,buf1_1+buf2_1);
        return;
}
int main(void){
    cin>>n;
    vector<ll> r,g,b;
    rep(i,2*n){
        ll a;cin>>a;
        char c;cin>>c;
        if(c=='R')r.push_back(a);
        if(c=='G')g.push_back(a);
        if(c=='B')b.push_back(a);
    }
    if(r.size()%2==0&&g.size()%2==0&&b.size()%2==0){
        cout<<0<<endl;
        return 0;
    }
    sort(r.begin(),r.end());
    sort(g.begin(),g.end());
    sort(b.begin(),b.end());
    if(b.size()%2==0){
        solve(r,g,b);
    }else if(r.size()%2==0){
        solve(g,b,r);
    }else{
        solve(b,r,g);
    }
    cout<<res<<endl;
}

#include<bits/stdc++.h>
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define vll vector<ll>
#define xfor(arr) for(auto& x : arr)
#define input(arr) xfor(arr) cin >> x;
#define output(arr) xfor(arr) cout << x << ' '; cout << '\n';
#define FOR(type,i,n) for(type i = 0; i < n; i++)

typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
using namespace std;
int main(){
    fastio
    // int t = 0;
    // cin >> t;
    // while(t--){

    // }
    ll n;
    cin >> n;
    // while(!(n%10))
    //     n /= 10;
    string s = to_string(n);
    ll stop = s.length()-1;
    while(s[stop] == '0')
        stop--;
    ll l = 0, r = stop;
    while(l < r) {
        if(s[l] != s[r]) {
            cout << "No";
            return 0;
        }
        l++;
        r--;
    }
    cout << "Yes";
    return 0;
}


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

LL a,b,c;
const LL mod=998244353;

inline LL qr()
{
	char a=0;LL x=0,w=1;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a<='9'&&a>='0'){x=(x<<3)+(x<<1)+(a^48);a=getchar();}
	return x*w;
}

inline LL poww(LL a,LL b)
{
	if(a==0)
		return 0;
	LL ans=1;
	LL ba=a;
	while(b)
	{
		if(b&1)
			ans=(ans*ba)%mod;
		b>>=1;
		ba=(ba*ba)%mod;
	}
	return (ans%mod+mod)%mod;
}

int main()
{
	a=qr();
	b=qr();
	c=qr();
	a=a*(a+1)%mod/**pow(2,mod-2)*/;
	b=b*(b+1)%mod/**pow(2,mod-2)*/;
	c=c*(c+1)%mod/**pow(2,mod-2)*/;
	//cout<<a<<' '<<b<<' '<<c<<endl;
	cout<<a*b%mod*c%mod*poww(8,mod-2)%mod<<endl;
	return 0;
}
/*
10
1 0
2 0
3 0
4 0
10 0
*/

#include <bits/stdc++.h>

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b;
  cin >> a >> b;
  int ans = 1;
  for (int g = 2; g < b; g++) {
    // a <= g * x
    int l = g * ((a + g - 1) / g);
    // g * y <= b
    int r = g * (b / g);
    if (l < r) ans = g;
  }
  cout << ans << '\n';
  return (0);
}


//#define NDEBUG

#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class F> class rec_lambda {
  F f;

public:
  rec_lambda(F &&f) : f(std::move(f)) {}
  template <class... Args> auto operator()(Args &&... args) const {
    return f(*this, std::forward<Args>(args)...);
  }
};
template <class F> auto make_rec(F &&f) { return rec_lambda<F>(std::move(f)); }
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}
constexpr char eoln = '\n';
template <class T> T ceildiv(const T &l, const T &r) {
  return l / r + (l % r != 0 ? 1 : 0);
}

} // namespace n91

#include <set>

namespace n91 {

void solve() {
  const usize n = scan<usize>();
  std::vector<u32> a(n);
  for (auto &e : a) {
    std::cin >> e;
  }
  bool f_win = true;
  if (n % 2 == 0) {
    std::sort(a.begin(), a.end());
    f_win = false;
    for (const usize i : rep(0, n / 2)) {
      if (a[2 * i] != a[2 * i + 1]) {
        f_win = true;
      }
    }
  } else {
    f_win = false;
  }
  std::cout << (f_win ? "First" : "Second") << eoln;
}

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize t = scan<usize>();
  for (const usize i : rep(0, t)) {
    solve();
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

int n, a[300005];
int bit[300005];

void update(int x) {
    for (int i = x; i <= n; i += (i & (-i))) {
        bit[i]++;
    }
}

int query(int x) {
    int tot = 0;
    for (int i = x; i >= 1; i -= (i & (-i))) {
        tot += bit[i];
    }
    return tot;
}

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

    long long inv = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        a[i]++;

        inv += a[i] - 1 - query(a[i]);
        update(a[i]);

    }

    printf("%lld\n", inv);
    for (int i = 0; i < n - 1; i++) {
        inv -= a[i] - 1;
        inv += n - a[i];
        printf("%lld\n", inv);
    }
}


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

int main(){
	string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<10000;i++){
        vector<int> tmp(10);
        int a=i/1000,b=(i-a*1000)/100,c=(i-a*1000-b*100)/10,d=i%10;
        if(s[a]=='x'||s[b]=='x'||s[c]=='x'||s[d]=='x')continue;
        tmp.at(a)++;tmp.at(b)++;tmp.at(c)++;tmp.at(d)++;
        bool ok=true;
        for(int j=0;j<10;j++){
            if(s[j]=='o'&&tmp.at(j)==0)ok=false;
        }
        if(ok)ans++;
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define MS(a, b) memset(a, b, sizeof(a))
#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define EREP(a, b) for (register int a = head[b]; a; a = edge[a].nxt)

inline int rd() {
    int x = 0; char c = getchar(); bool f = 0;
    while (c < '0' && c != '-') c = getchar();
    if (c == '-') f = 1, c = getchar();
    while (c >= '0') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    return f ? -x : x;
}

const int SIZE = 2e5 + 100;

int n;

int head[SIZE], ecnt;
struct Edge {
	int v, nxt;
} edge[SIZE << 1];
void Add_Edge (int u, int v) {
	edge[++ecnt] = (Edge) { v, head[u] };
	head[u] = ecnt;
}

int dep[SIZE], F[SIZE];
int mx[SIZE][2];
int Len = -1, A, B;
void dfs (int u, int fa) {
	F[u] = fa;
	dep[u] = dep[fa] + 1;
	mx[u][0] = mx[u][1] = u;
	EREP (i, u) {
		int v = edge[i].v;
		if (v == fa) continue;
		dfs(v, u);
		if (dep[mx[v][0]] > dep[mx[u][0]])
			mx[u][1] = mx[u][0], mx[u][0] = mx[v][0];
		else if (dep[mx[v][0]] > dep[mx[u][1]])
			mx[u][1] = mx[v][0];
	}
	if (dep[mx[u][0]] + dep[mx[u][1]] - 2 * dep[u] > Len) {
		Len = dep[mx[u][0]] + dep[mx[u][1]] - 2 * dep[u];
		A = mx[u][0];
		B = mx[u][1];
	}
}
bool mark[SIZE];
int E;
int ans[SIZE];
void D (int u, int fa) {
	++E;
	ans[u] = E;
	EREP (i, u) {
		int v = edge[i].v;
		if (v == fa) continue;
		if (!mark[v]) D(v, u);
	}
	EREP (i, u) {
		int v = edge[i].v;
		if (v == fa) continue;
		if (mark[v]) D(v, u);
	}
	++E;
}

void _main () {
	n = rd();
	FOR (i, 1, n) {
		int u = rd(), v = rd();
		Add_Edge(u, v);
		Add_Edge(v, u);
	}
	dfs(1, 0);
	int T = A;
	while (A != B) {
		if (dep[A] < dep[B]) swap(A, B);
		mark[A] = 1;
		A = F[A];
	} mark[A] = 1;
	D(T, 0);
	REP (i, 1, n) printf ("%d ", ans[i]);
}

int main () {
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
#endif
	_main();
	return 0;
}


#include <bits/stdc++.h>
#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 ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
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; }
void Yes(bool a) { cout << (a?"Yes":"No") << endl; }
void YES(bool a) { cout << (a?"YES":"NO") << endl; }
int MOD = 1e9+7;

int main(int argc, char **argv) {
	int N; cin >> N;
	vector<int> A(N);
	rep(i, N) cin >> A[i];
	int ans = 0;
	rep(i, N) {
		if (A[i] > 10) ans += A[i] - 10;
	}
	cout << ans << endl;
}

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

int main(){
	int N;
	cin >> N;
	int A[N];
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	int ans=0;
	for(int i=0;i<N;i++){
		for(int j=A[i];j>10;j--){
			ans++;
		}
	}
	cout << ans << endl;
}


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

int main() {
  int a,b;
  double c;
  cin >> a >> b;
  c = a-b;
  c = c/a;
  cout << c * 100 << endl;
}

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// #pragma GCC optimize("O2")
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef multiset <ll> mms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define deb(x) cout << #x << " " << x << endl;
#define ff first
#define ss second
#define pb(v) push_back(v)
#define lb(v) lower_bound(v)
#define ub(v) upper_bound(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b) {
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s) {
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v) {
	forl(i,v.size()) cout<<v[i]<<" ";
	cout<<"\n";
}
void pa(ll *v, ll size) {
	forl(i,size) cout<<v[i]<<" ";
	cout<<"\n";
}
void removeDups(mv &v) {
	sort(all(v));
	mv::iterator it = unique(v.begin(), v.end());
	v.resize(distance(v.begin(), it));
}
inline ld kthRoot(ld n, ll k) {
	return pow(k, (1.0 / k) * (log(n) / log(k)));
}
ll power(ll x, ll y, ll p) {
	ll res=1;
	x=x%p;
	while(y>0) {
		if(y&1) res = (res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x, ll mod) {
	if(x>=mod) x%=mod;
}

ll mod = 1e9 + 7;

void thisIsMain() {
	ll a, b;
	cin>>a>>b;
	ld ans = (a - b) / (1.0 * a);
	ans *= 100;
	printf("%0.5Lf\n", ans);
}

int main(void)
{
	fastio
	ll t = 1;
	// cin>>t;
	while(t--) thisIsMain();
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define rev(v)  if(!v.empty())reverse(v.begin(),v.end())
#define PI 3.141592653589793238
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll n;
  cin>>n;

  string s[n];

  for(ll i=0;i<n;i++)
  cin>>s[i];

  ll ans=0;

  for(ll i=n-1;i>=0;i--){
      if(s[i]=="OR")
      {
          ans+=(ll)pow(2,i+1);
      }

      if(i==0){
        ++ans;
      }

  }
  cout<<ans<<endl;
}
int main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);

//Start from Here.

  ll t;
  t=1;
 //cin>>t;
  while(t--)
  solve();

//Good Bye!
    return 0;
}

// Problem : A - ReLU
// Contest : AtCoder - AtCoder Beginner Contest 183
// URL : https://atcoder.jp/contests/abc183/tasks/abc183_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int test =1;
void solve()
{
	//cout << "Case #"<< test++<<": ";
	int x;
	cin >> x;
	cout << max(x,(int)0);
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n; int t=n;
    int x = n/100;
    if(x*100 < t){
        cout<<x+1<<"\n";
    }
    else{
        cout<<x<<"\n";
    }
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); ++(i))
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define DEBUG(x) cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << "\033[m" << endl;

typedef long long ll;

int main()
{
    int ans = 0;
    int i, j, k, l, m, n;
    int a[100];
    string s;

    cin >> n;

    cout << (n+99)/100;

//    REP(i,5){ DEBUG(ans); }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int Q = 1000;
    while(Q--){
        int sx, sy, tx, ty;
        cin >> sx >> sy >> tx >> ty;

        string ans;
        if(sx > tx){
            for(int i = sx;i > tx;i--){
                ans.push_back('U');
            }
        }
        if(sx < tx){
            for(int i = sx;i < tx;i++){
                ans.push_back('D');
            }
        }

        if(sy > ty){
            for(int i = sy;i > ty;i--){
                ans.push_back('L');
            }
        }
        if(sy < ty){
            for(int i = sy;i < ty;i++){
                ans.push_back('R');
            }
        }
        cout<<ans<<endl;
        int dist;
        cin >> dist;
    }
    return 0;
}

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

// (i,j) i:上下 j:左右
#define NSIZE (30) // node数
#define ESIZE (29) // edge数
#define TEST_NUM (1000)
bool LOCAL_TEST=false; // 提出時はfalseに変更
bool DB_PRINT=false;
int h[NSIZE][ESIZE]; // h[i:上下][j:左右]
int v[ESIZE][NSIZE]; // v[i:上下][j:左右]
int si[TEST_NUM];
int sj[TEST_NUM];
int ti[TEST_NUM];
int tj[TEST_NUM];
double a[TEST_NUM];
double e[TEST_NUM];
int result[TEST_NUM];

int read_h_v()
{
  // i:上下, j:左右  h_ij,v_ij
  for (int i = 0; i < NSIZE; i++) {
    for (int j = 0; j < ESIZE; j++) {
      cin >> h[i][j];
    }
  }
  for (int i = 0; i < ESIZE; i++) {
    for (int j = 0; j < NSIZE; j++) {
      cin >> v[i][j];
    }
  }

  if (DB_PRINT) {
    cout << h[ 0][0] << " " << h[ 0][1] << " " << h[ 0][28] << endl;
    cout << h[ 1][0] << " " << h[ 1][1] << " " << h[ 1][28] << endl;
    cout << h[29][0] << " " << h[29][1] << " " << h[29][28] << endl;
    cout << v[ 0][0] << " " << v[ 0][1] << " " << v[ 0][29] << endl;
    cout << v[28][0] << " " << v[28][1] << " " << v[28][29] << endl;
  }

  return 0;
}

int read_s_t_a_e(int k)
{
  cin >> si[k] >> sj[k] >> ti[k] >> tj[k] >> a[k] >> e[k];
  if (DB_PRINT) {
    cout << si[k] << " " << sj[k] << " " << ti[k] << " " << tj[k] << " ";
    cout << a[k] << " " << e[k] << endl;
  }

  return 0;
}

int read_s_t(int k)
{
  cin >> si[k] >> sj[k] >> ti[k] >> tj[k];
  if (DB_PRINT) {
    cout << si[k] << " " << sj[k] << " " << ti[k] << " " << tj[k] << endl;
  }

  return 0;
}

string query(int si, int sj, int ti, int tj, int prev_result) {
  // WRITE YOUR SOLUTION HERE
  string str;

  // 上下に一気に移動
  if (si > ti) {
    for (int i = 0; i < si-ti; i++){
      str.push_back('U');
    }
  }
  else if (si < ti) {
    for (int i = 0; i < ti-si; i++){
      str.push_back('D');
    }
  }

  // 左右に一気に移動
  if (sj > tj) {
    for (int i = 0; i < sj-tj; i++){
      str.push_back('L');
    }
  }
  else if (sj < tj) {
    for (int i = 0; i < tj-sj; i++){
      str.push_back('R');
    }
  }

  return str;
}

int compute_path_length(string path)
{
  return 0;
}

int read_result()
{
  int result;
  cin >> result;

  return result;
}

int main() {

    if (LOCAL_TEST) {
        read_h_v();
    }
    int prev_result = 0;
    double score = 0.0;
    for (int k = 0; k < 1000; k++) {
        if (LOCAL_TEST) {
            read_s_t_a_e(k);
        } else {
            read_s_t(k);
        }
        string path = query(si[k], sj[k], ti[k], tj[k], prev_result);
        cout << path << endl << flush;
        if (LOCAL_TEST) {
            int b = compute_path_length(path);
            score = score * 0.998 + a[k] / b;
            prev_result = round(b * e[k]);
        } else {
            prev_result = read_result();
        }
        result[k] = prev_result;
    }
    if (LOCAL_TEST) {
        cout << round(2312311 * score) << endl;
    }
    return 0;
}


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

#define pb push_back
#define pob pop_back
#define pll pair <long long, long long>
#define pld pair <long double, long double>
#define ll long long
#define ull unsigned long long
#define ld long double
#define Int int
#define itn int
#define nit int
#define int long long
#define x first
#define y second

using namespace std;

const int N = 1e4 + 123;
const int INF = 2 * 1e18 - 1;
const int inf = 2 * 1e9 - 1;

bool prime(int x) {

    for (int i = 2;i <= sqrt(x);i++) {

        if (x % i == 0) {

            return 0;

        }

    }

    return 1;

}

void factorizing(int x) {

    if (prime(x)) {

        cout << x;return;

    }

    int div = 2;

    while (x) {

        if (x % div == 0) {

            cout << div << ' ';
            x /= div;
            div = 2;

        }
        else {

            div++;

        }

    }

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

    int n;
    cin >> n;

    int sum = 0;
    int cnt = 0;

    int then = 1000;

    for (int i = 1000;i <= n;i *= 10) {

        if (i == then) {

            cnt++;
            then *= 1000;

        }

        int log = (int)log10(i);
        int next = pow(10, log + 1);
        int minus = min(n - i + 1, next - i);

        sum += (minus * cnt);

    }

    cout << sum;

    return 0;

}


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

typedef long long ll;
typedef pair<int,int> ii;

void solve(){
	int n; cin >> n;
	vector<ll> a,b;
	for (int i=0; i<n; i++){
		ll x; cin >> x;
		a.push_back(x);
	}
	for (int i=0; i<n; i++){
		ll x; cin >> x;
		b.push_back(x);
	}

	ll dot = 0;
	for (int i=0; i<n; i++){
		dot = dot + a[i] * b[i];
	}
	cout << (dot == 0? "Yes\n" : "No\n");
}

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

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

	return 0;
}
// NK

/*
 * author :Sadik Hassan(_sad_)
 *
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
using   ld =          long double;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define MP            make_pair
#define PI            (acos(-1.0))
#define rep1(i,n)     for(int i=1;i<=n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         (int)s.size()
#define all(x)        (x).begin(), (x).end()
#define rall(x)       (x).rbegin(), (x).rend()
#define w(t)          int t;cin>>t;while(t--)
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(10);

typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N=(int)2e5+5;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+5;
const int nn=1e6;

int main()
{
    _SAD()
    int n;
    cin>>n;
    int ans=0;
    rep(i,n)
    {
        int y;
        cin>>y;
        ans=__gcd(y,ans);
    }
    cout<<ans<<nl;
    return 0;
}