#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 trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

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 = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy

ll read() {
    ll K = 0;
    string S; cin >> S;
    int cnt = 0;
    bool found = false;
    bool neg = false;
    trav(a, S) {
        if (a == '.') {
            found = true; continue;
        } else if (a == '-') {
            neg = true; continue;
        }
        if (found) cnt++;

        K *= 10; K += a - '0';
    }
    FOR(i, cnt, 4) K *= 10;
    if (neg) K *= -1;
    return K;
}

void solve() {

    ll X = read(), Y = read(), R = read();
    R *= R;
    ll ans = 0;
    for (ll x = -2000000000; x <= 2000000000; x += 10000) {
        ll lo = Y, hi = 2000000000;
        assert(lo < hi);
        ll G = (X-x)*(X-x);
        if (G > R) continue;
        while (lo < hi) {
            ll mid = lo + (hi-lo+1)/2;
            if ((Y-mid)*(Y-mid) <= R-G) {
                lo = mid;
            } else {
                hi = mid-1;
            }
        }
        ll upB = lo;
        lo = -2000000000;
        hi = Y;
        assert(lo < hi);
        while (lo < hi) {
            ll mid = lo + (hi-lo)/2;
            if ((Y-mid)*(Y-mid) <= R-G) {
                hi = mid;
            } else {
                lo = mid+1;
            }
        }
        ll loB = lo;
        loB += 1e12; upB += 1e12;
        assert(loB >= 0); assert(upB >= 0);
        loB = (loB + 9999) / 10000;
        upB = upB / 10000;
        assert(upB - loB + 1 >=0);
        ans += upB - loB + 1;
    }
    cout << ans << nl;

}

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

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

	return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
const long long mod = 1000000007;
//const long long mod = 998244353;

int main() {
	int N, K, M;
	scanf("%d %d %d", &N, &K, &M);
	int *A = new int[N];
	int sum = 0;
	for (int i = 0; i < N - 1; i++) {
		scanf("%d", A + i);
		sum += A[i];
	}
	int r = N * M - sum;
	if (r<0) {
		printf("0");
	}
	else if(r>K){
		printf("-1");
	}
	else {
		printf("%d", r);
	}
	return 0;
}


# include <iostream>
using namespace std;

int N, K;
int main() {
	cin >> N >> K;
	cout << int((1 + N)*N * 0.5 * 100 * K + (1 + K)* K * 0.5 * N) ;

}

#include<bits/stdc++.h>
//#define int long long
using namespace std;
void read() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
	read();
	ios::sync_with_stdio(0);
	cin.tie(0);
	int T;
	T = 1;
	//cin >> T;
	while (T--)
	{
		int n, m; cin >> n >> m;
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++)
				sum += (i * (100) + j);
		}
		cout << sum;
	}
}


#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dy[4]={ -1,0,1,0 };
const int dx[4]={ 0,-1,0,1 };

int N;
ll X;
ll A[51];

unordered_map<ll,ll> dp[51];
ll solve(int n, ll k){
    if(n == -1) return (k == 0);
    if(abs(k) >= A[n+1]) return 0;
    if(dp[n].count(k)) return dp[n][k];
    ll ret = 0;
    ll tmp = (k%A[n]+A[n])%A[n];
    if(abs(k-tmp)/A[n] < A[n+1]/A[n]) ret += solve(n-1, tmp);
    tmp -= A[n];
    if(abs(k-tmp)/A[n] < A[n+1]/A[n]) ret += solve(n-1, tmp);
    return dp[n][k] = ret;
}

signed main(){
    cin >> N >> X;
    rep(i, N) cin >> A[i];
    A[N] = 1e18L;

    cout << solve(N-1, -X) << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
ll n;
ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}
int main(){
	n=read();
	ll ans=1;
	for(ll i=2;i<=n;++i) ans=ans*i/gcd(ans,i);
	printf("%lld\n",ans+1);
	return 0;
}

#include<iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	cout << n - 1;
	return 0;
}


#include <iostream>
using namespace std;

int h, w, a, b;
int room[18][18];
int cnt;

void putA(int n, int pos) {
	if (n > a) {
		cnt++;
		return;
	}
	for (; pos < h * w; pos++) {
		int r = (pos / w) + 1;
		int c = (pos % w) + 1;
		if (room[r][c] == 0) {
			room[r][c] = n;
			if (room[r][c + 1] == 0) {
				room[r][c + 1] = n;
				putA(n + 1, pos + 1);
				room[r][c + 1] = 0;
			}
			if (room[r + 1][c] == 0) {
				room[r + 1][c] = n;
				putA(n + 1, pos + 1);
				room[r + 1][c] = 0;
			}
			room[r][c] = 0;
		}
	}
}

int main()
{
	cin >> h >> w >> a >> b;

	for (int r = 0; r < h + 2; r++)
		for (int c = 0; c < w + 2; c++)
			room[r][c] = ((r >= 1) && (r <= h) && (c >= 1) && (c <= w)) ? 0 : -1;
	cnt = 0;
	putA(1, 0);
	cout << cnt;
}

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
constexpr int MOD = 998244353;
constexpr int prob = 665496236;
long long dp[5001];

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

int main(){
    int H, W, K;
    scanf("%d%d%d", &H, &W, &K);

    vector<vector<pair<int, char>>> X(H);
    for(int i = 0; i < H; ++i) X[i].reserve(W);

    for(int i = 0; i < K; ++i){
        int x, y;
        char c;
        scanf("%d%d%c%c", &x, &y, &c, &c);
        --x, --y;
        X[x].emplace_back(y, c);
    }

    dp[0] = 1;
    for(int i = 0; i < H; ++i){
        sort(X[i].begin(), X[i].end());
        auto itr = X[i].begin();

        for (int j = 0; j < W; ++j){
            dp[j] %= MOD;
            if(itr != X[i].end() and itr->first == j){
                char c = itr->second;
                if(c != 'D') dp[j + 1] += dp[j];
                if((i != H - 1) & c == 'R') dp[j] = 0;
                ++itr;
            }
            else{
                dp[j + 1] += dp[j] * prob;
                if(i != H - 1) dp[j] *= prob;
            }
        }
    }

    long long ans = dp[W - 1];
    ans *= pow(3, H * W - K);
    printf("%d", ans % MOD);

    return 0;
}


#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

int64_t solve(int64_t N, std::vector<int64_t> a, std::vector<std::string> c) {
	int t[128] = {};
	t['R'] = 0;
	t['G'] = 1;
	t['B'] = 2;
	vector<vector<int64_t>> v(3);
	for (int i = 0; i < 2 * N; i++) {
		v[t[c[i][0]]].emplace_back(a[i]);
	}
	if (v[0].size() % 2 == 0) {
		swap(v[0], v[1]);
	}
	if (v[1].size() % 2 == 0) {
		swap(v[1], v[2]);
	}
	if (v[0].size() % 2 == 0) {
		return 0;
	}
	for (int i = 0; i < 3; ++i) {
		sort(v[i].begin(), v[i].end());
	}
	auto get_min = [&](const vector<int64_t>& a, const vector<int64_t>& b) {
		int64_t ans = 1LL << 60;
		int i = 0;
		for (auto x : a) {
			while (i < b.size() - 1 && abs(x - b[i]) >= abs(x - b[i + 1])) {
				++i;
			}
			ans = min(ans, abs(x - b[i]));
		}
		return ans;
	};
	int64_t ans = get_min(v[0], v[1]);
	if (!v[2].empty()) {
		ans = min(ans, get_min(v[0], v[2]) + get_min(v[1], v[2]));
	}
	return ans;
}

int main() {
	int64_t N;
	std::cin >> N;
	std::vector<int64_t> a(2*N);
	std::vector<std::string> c(2*N);
	for (int i = 0; i < 2*N; i++) {
		std::cin >> a[i] >> c[i];
	}
	cout << solve(N, std::move(a), std::move(c)) << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) int(x.size())
const int mod = 1e9 + 7;
const int inf = 2e9 + 5;
const ll linf = 9e18 + 5;
const ll ll0 = 0 * 1ll;

ll n, s, k;

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

    return gcd(b, a % b);
}

ll euler (ll n) {
    ll d = 2;

    ll ans = n;

    while (d * d <= n) {
        if (n % d == 0) {
            ans /= d;
            ans *= d - 1;
        }
        while (n % d == 0) {
            n /= d;
        }

        d++;
    }

    if (n > 1) {
        ans /= n;
        ans *= n - 1;
    }

    return ans;
}

ll mull(ll a, ll b) {
    return (a * b) % n;
}

ll binpow (ll a, ll b) {
    if (b == 0) {
        return 1;
    }
    if (b % 2) {
        return mull(a, binpow(a, b - 1));
    }

    ll half = binpow(a, b / 2);
    return mull(half, half);
}

void init () {
}

void input () {
    cin >> n >> s >> k;

    s = n - s;
}

void solve() {
    ll g = gcd(n, k);

    if (s % g) {
        cout << -1 << endl;
        return;
    }

    n /= g;
    s /= g;
    k /= g;

    cout << mull(s, binpow(k, euler(n) - 1)) << endl;
}

void output() {
}

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

    int number_of_testcases = 1;
    cin >> number_of_testcases;
    while (number_of_testcases--) {
        init();

        input();

        solve();

        output();
    }

    return 0;
}


#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

const ll INF = 100000000000000;

int main()
{
    int n, m;
    cin >> n >> m;
    ll w[10];
    for(int i = 0; i < n; i++) cin >> w[i];
    ll l[100005], v[100005];
    for(int i = 0; i < m; i++) cin >> l[i] >> v[i];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(w[i] > v[j]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    ll d[500]{0};
    for(int i = 0; i < (1 << n); i++){
        ll s = 0;
        for(int j = 0; j < n; j++){
            if((i >> j) & 1) s += w[j];
        }
        for(int j = 0; j < m; j++){
            if(s > v[j]) d[i] = max(d[i], l[j]);
        }
    }
    int p[10];
    ll ans = INF;
    for(int i = 0; i < n; i++) p[i] = i;
    do{
        ll e[10]{0};
        for(int i = 0; i < n; i++){
            int u = p[i];
            int b = (1 << u);
            for(int j = i - 1; j >= 0; j--){
                int v = p[j];
                b += (1 << v);
                e[u] = max(e[u], e[v] + d[b]);
            }
        }
        ans = min(ans, e[p[n - 1]]);
    }while(next_permutation(p, p + n));
    cout << ans << endl;
}

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define UQ(x) (x).resize(distance((x).begin(),unique(x.begin(),x.end())))

using namespace std;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd64(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
	ll ans = 1;
	while(m){
		if(m%2) ans *= a, ans %= (mod);
		a = (a*a) % mod;
		m >>= 1;
	}
	return ans;
}

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

  	size_t operator()(uint64_t x) const {
    	static const uint64_t FIXED_RANDOM =
        	chrono::steady_clock::now().time_since_epoch().count();
    	return splitmix64(x + FIXED_RANDOM);
  	}
  	size_t operator()(pair<int64_t, int64_t> Y) const {
    	static const uint64_t FIXED_RANDOM =
        	chrono::steady_clock::now().time_since_epoch().count();
    	return splitmix64(Y.first * 31 + Y.second + FIXED_RANDOM);
  	}
};

const long long inf = 1e18;
const long long M = 1000000007;

void solve(){
	ll i,j,_;
	ll n, m;
	ll mx = LLONG_MAX;
	cin >> n >> m;
	ll w[n];
	rep(i,0,n) cin >> w[i];
	sort(w,w+n);
	if(n > 1) swap(w[0], w[n - 2]);
	ll tmp[n];
	i = 0;
	ll l = 0, r = n - 1;
	// while(i < n) {
	// 	if(i%2) tmp[i] = w[r], r--;
	// 	else tmp[i] = w[l],l++;
	// 	i++;
	// }
	// rep(i,0,n) w[i] = tmp[i];
	ll l1[m],r1[m];
	_ = 10000;
	rep(i,0,m) cin >> l1[i] >> r1[i];
	do {
	ll dp[n][n];
	rep(i,0,n)rep(j,0,n) dp[i][j] = 0;

ll bl = 0,t;
	rep(t,0,m) {
		l = l1[t], r = r1[t];
		rep(i,0,n) {
			ll now = w[i];
			// cout << now << ' ' << r << endl;
			if(now > r) {
				cout << -1 << endl;
				return;
				// bl = 1;
			}
			rep(j,i + 1,n) {
				now += w[j];
				if(now > r) {
					dp[i][j] = max(dp[i][j], l);
					break;
				}
			}
		}
		if(bl) break;
	}
	if(bl) continue;
	// rep(i,0,n) {
	// 	rep(j,0,n) {
	// 		cout << dp[i][j] << ' ';
	// 	}
	// 	cout << endl;
	// }
	ll k;
	rep(i,1,n) {
		rep(j,0,n) {
			r = j + i;
			if(r >= n) break;
			rep(k,j,r+1) {
				dp[j][r] = max(dp[j][r], dp[j][k] + dp[k][r]);
			}
		}
	}
	mx = min(mx, dp[0][n-1]);
	// if(mx == 3802) cout << _ << endl;
// 	cout << dp[0][n-1] << endl;
//     if(dp[0][n-1] == 3802){
//         for(auto i : w) cout << i << ' ';
// 	cout << endl;
    // }

	}while ( std::next_permutation(w + 1,w + n - 1));
	// cout << _ << endl;
	if(mx == LLONG_MAX) mx = -1;
	cout << mx << endl;
}

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


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

#define ll long long
#define ull unsigned long long
#define ld long double
#define F first
#define S second
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

using namespace __gnu_pbds;
using namespace std;

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

template <typename T>
void ckmin(T& a, const T b) {a = min(a, b);}

template <typename T>
void ckmax(T& a, const T b) {a = max(a, b);}

template <typename T>
vector <T> sieve(T n) {
    vector <T> f(n+1, 1), res;
    for (T i = 2; i <= n; ++i)
        for (T j = i; j <= n; j += i)
            ++f[j];
    for (T i = 2; i <= n; ++i)
        if (f[i] == 2)
            res.eb(i);
    return res;
}

template <typename T>
T power(T a, T b, const T c) {
    a %= c;
    T res = 1;
    while (b)
    {
        if (b & 1) res = res * a % c;
        b >>= 1;
        a = a * a % c;
    }
    return res;
}

template <typename T>
void print(vector <T> v) {
    for (T i : v) cout << i << " ";
    cout << '\n';
}

template <typename T>
void print(vector <vector <T>>& v) {
    for (vector <T>& vv : v) {
        for (T& i : vv)
            cout << i << " ";
        cout << '\n';
    }
}

template <typename T>
void read(vector <T>& v) {for (T& i : v) cin >> i;}

template <typename T>
void read(T&& t) {cin >> t;}

template <typename T, typename... Args>
void read(T&& t, Args&&... args)
{
    cin >> t;
    read(forward<Args>(args)...);
}

template <typename T>
void print(T&& t) {cout << t << '\n';}

template <typename T, typename... Args>
void print(T&& t, Args&&... args)
{
    cout << t << " ";
    print(forward<Args>(args)...);
}

void usaco(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(name.size())
    {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".txt").c_str(), "w", stdout);
    }
}

int n, edge, node;
const int mxn = 4e5+1;
vector <int> adj[mxn];
bool vis[mxn];

void dfs(int u)
{
    vis[u] = 1;
    ++node;
    for (int v : adj[u])
    {
        ++edge;
        if (!vis[v])
            dfs(v);
    }
}

inline void solve()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int u, v;
        cin >> u >> v;
        adj[u].emplace_back(v);
        adj[v].emplace_back(u);
    }
    long long ans = 0;
    for (int i = 1; i < mxn; ++i)
    {
        if (vis[i] || adj[i].empty()) continue;
        edge = node = 0;
        dfs(i);
        edge >>= 1;
        ans += min(edge, node);
    }
    cout << ans << '\n';
}

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

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

#define ll long long
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define P pair<ll, ll>
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

ll n;
vector<vector<ll>> G(400001);
vector<bool> loop_dupl(400001, false);
vector<bool> check(400001, false);
ll ans = 0;
bool dfs(ll color, ll parent){
    //cout << "color : " << color << endl;
    if(check[color]) return true;
    check[color] = true;
    ans++;
    bool ret = loop_dupl[color];
    for(ll link : G[color]) if(link != parent) ret |= dfs(link, color);
    //cout << ret << endl;
    return ret;
}

int main(){
    cin >> n;

    ll a, b, c;
    set<P> s;
    rep(i, n){
        cin >> a >> b;
        if(a > b){
            c = a; a = b; b = c;
        }
        if(s.find(make_pair(a, b)) == s.end()){
            s.insert(make_pair(a, b));
            G[a].pb(b);
            G[b].pb(a);
        }else{
            loop_dupl[a] = true;
            loop_dupl[b] = true;
        }
    }

    for(ll i=1; i<=400000; i++){
        if(check[i]) continue;
        //cout << "aaa" << endl;
        ans -= !dfs(i, 0);
    }

    cout << ans << endl;
}


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

#define fo(i, x, y) for (int i = (x); i <= (y); ++i)
#define fd(i, x, y) for (int i = (x); i >= (y); --i)

typedef long long ll;

const int maxn = 1e5 + 5;
const double inf = 1e18;

int n;
ll a[maxn];

int getint()
{
	char ch;
	int res = 0, p;
	while (!isdigit(ch = getchar()) && (ch ^ '-'));
	p = ch == '-'? ch = getchar(), -1 : 1;
	while (isdigit(ch))
		res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
	return res * p;
}

int main()
{
	//freopen("t.in", "r", stdin);
	n = getint();
	ll sum = 0;
	fo(i, 1, n) scanf("%lld", &a[i]), sum += a[i];
	sort(a + 1, a + 1 + n);
	double ans = inf;
	ll pre = 0;
	fo(i, 1, n)
	{
		pre += a[i];
		double x = a[i] / 2.0;
		ans = min(ans, x + 1.0 * sum / n - 1.0 * (pre + a[i] * (n - i)) / n);
	}
	printf("%.8f\n", ans);
	return 0;
}


#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<iomanip>
using namespace std;
int main() {

	int n;
	int a[1001];
	int ans = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];

		if (a[i] > 10) {
			ans += a[i] - 10;
		}

	}

	cout << ans << endl;

	return 0;
}

#include<bits/stdc++.h>

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        int x = a[i];
        for(int j = i; j < n; j++){
            x = min(x, a[j]);
            ans = max(ans, (j - i + 1) * x);
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define RFOR(i, a, b) for(int i = a; i >= b; i--)
#define all(v) ((v).begin()), ((v).end())
#define endl '\n'

using namespace std;
using ll     = long long;
using ull    = unsigned long long;
using Graph  = vector<vector<int>>;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vll    = vector<ll>;
using vpii   = vector<pii>;
using vpll   = vector<pll>;
#ifdef __SIZEOF_INT128__
using Bigint = __int128;
#endif

template <class T, class U>
void max_self(T& t, const U& u) {
    if (t > u) t = u;
}

template <class T, class U>
void min_self(T& t, const U& u) {
    if (t < u) t = u;
}

template <typename T>
void print(const T& cont) {
  cout << "{";
  int idx = 0;
  for (auto& itr : cont) {
      if (idx++) cout << ",";
      cout << itr;
  }
  cout << "}\n";
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    FOR (i, 0, v.size() - 1) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

string solve(ll& n)
{
  if (n % 4 == 0) return "Even\n";
  if (n % 2 == 0) return "Same\n";
  return "Odd\n";
}

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

  int t;
  cin >> t;
  while (t--)
  {
    ll n;
    cin >> n;
    cout << solve(n);
  }
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        if(n%2==1)
            cout<<"Odd"<<endl;
        else
        {
            ll r=0 ;
            while(n%2==0)
            {
                ++r;
                n=n/2;
            }
            ++r;
            if(r>=3)
                cout<<"Even"<<endl;
            else
                cout<<"Same"<<endl;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long   ll;

const int N = int(2e5) + 10;
ll a[N];
const ll mod = ll(998244353LL);

// ll sum(int m, int n){
//     ll mx = -1;
//     ll mn = -1;
//     for(int j = 0 ; j < n ; j++){
//         int e = 1 << j;

//         if(m & e){
//             if(mx == -1){
//                 mx = a[j];
//                 mn = a[j];
//             }else{
//                 mx = max(mx, a[j]);
//                 mn = min(mn, a[j]);
//             }
//         }
//     }

//     return (mx * mn) % mod;
// }

int main(){
    int n;

    scanf("%d", &n);

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

    // ll tmp = 0LL;

    // for(int m = 1 ; m < (1 << n) ; m++){
    //     tmp = (tmp + sum(m, n)) % mod;
    // }

    // printf("tmp = %lld\n", tmp);

    sort(a, a + n);

    ll sum = 0LL;
    ll ans = 0LL;

    for(int i = 0 ; i < n ; i++){
        // printf("%lld adds %lld\n", a[i], ((a[i] * sum) % mod + a[i] * a[i]));
        ans = (ans + ((a[i] * sum) % mod + a[i] * a[i]) % mod) % mod;
        sum = (sum * 2LL + a[i]) % mod;
    }

    printf("%lld\n", ans);

    return 0;
}

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

#define ll long long
#define pb push_back
#define pii pair <int, int>
#define vi vector<int>

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define FORd(i, a, b) for (int i=a-1; i>=b; i--)
#define F0Rd(i, a) for (int i=a-1; i>=0; i--)
#define F0R(i, a) for (int i=0; i<a; i++)

#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 998244353;
long double PI = 4*atan(1);
/*std::cout << std::fixed << std::setprecision(2);
ll po (ll b, ll p) return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD;
ll inv (ll b) { return po(b,MOD-2); }*/

ll n,a[200001],dp[200001],ans,cur;

void calc() {
	dp[n-1] = 0LL;
	if(n==1) return;
	dp[n-2] = a[n-1];
	if(n==2) return;
	F0Rd(i,n-2) {
		dp[i] = a[i+1]+ (2LL*dp[i+1]);
		dp[i] %= MOD;
	}
	//F0R(i,n) cout << dp[i] << " ";
}

void solve() {
	cin >> n;
	F0R(i,n) cin >> a[i];
	sort(a,a+n);
	calc();
	F0R(i,n) {
		cur = (a[i]*a[i])%MOD;
		ans = (ans+cur)%MOD;
		cur = (a[i]*dp[i])%MOD;
		ans = (ans+cur)%MOD;
		//cout << ans << " ";
	}
	cout << ans;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int test_cases = 1;
    //cin >> test_cases;
    F0R(i,test_cases) {
    	solve();
    	//init();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long  long ll;
ll MOD=1e9+7;
const ll MAX=1e5+2;

void solve(){
    ll n;cin>>n;
    ll a[n],b[n],c[n];
    for(auto &x:a)cin>>x;
    for(auto &x:b)cin>>x;
    for(auto &x:c)cin>>x;
    unordered_map<ll,ll>mc;
    for(auto &x:c)mc[x]++;
    unordered_map<ll,ll>mb;
    for(int i=0;i<n;i++){
        mb[b[i]]+=mc[i+1];
    }
    ll ans=0;
    for(auto &x:a){
        ans+=mb[x];
    }
    cout<<ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;t=1;
    // cin>>t;
    // cin.ignore();
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;

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

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

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

vector<vector<int>> R;
vector<int> used;

int rec(int cur){
    int res = 1;
    used[cur] = true;

    for(int nex : R[cur]){
        if(used[nex]) continue;
        res += rec(nex);
    }

    return res;
}

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

	int N;
	long double ans = 0;

    cin>>N;

    R.resize(N);

    for(int i = 0; i < N; i++){
        string s;

        cin>>s;

        for(int j = 0; j < s.size(); j++){
            if(s[j] == '1') {
                R[j].push_back(i);
            }
        }
    }

    for(int i = 0; i < N; i++){
        used.clear();
        used.resize(N);
        ans += 1.0 / rec(i);
    }

    cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define endl "\n"
#define fill(A,x) memset(A,x,sizeof A);

void solve()
{
  int n;
    cin>>n;
	vi pos(n+5),ar(n+5);
	vi ans;
    for(int i=1;i<=n;i++)
    {
        cin>>ar[i];
        pos[ar[i]]=i;
    }
    if(n==2)
    {
        if(pos[1]==1)cout<<0<<endl;
        else {cout<<1<<endl;cout<<1;}
        cout<<endl;
        return;
    }

    for(int i=n;i>0;i--)
    {
        if(i>n||pos[i]==i)
        continue;
        int c=pos[i];
        if(c%2!=(ans.size())%2)
        {
            while(pos[i]!=i)
            {
                int x=ar[pos[i]+1];
                ar[pos[i]]=x;ar[pos[i]+1]=i;
                ans.pb(pos[i]);
                pos[i]++;pos[x]--;
            }
        }
        else
        {
            if(c%2==0)
            {
                ans.pb(1);
                ans.pb(2);
                ans.pb(1);
                pos[ar[1]]+=2;pos[ar[3]]-=2;
                swap(ar[1],ar[3]);
                i++;
            }
            else
            {
                ans.pb(2);
                ans.pb(1);
                ans.pb(2);
                pos[ar[1]]+=2;pos[ar[3]]-=2;
                swap(ar[1],ar[3]);
                i++;
                i++;
            }
        }
    }

    int x=ans.size();
    cout<<x<<endl;

    for(auto it:ans)cout<<it<<" ";
    cout<<endl;
}

signed main()
{
    boost
    int test=0,t;
    cin >> t ;
    //t=1;
   while(test++ <t){
	//   cout<<"Case #"<<test<<": ";
	   solve();}

}

//Duodecim Ferra

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define rrep(i,x,y) for(ll i=x;i>=y;i--)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18
const ll mod = 9223372036854775800;
//cout<<fixed<<setprecision(15)<<x<<nnn;

signed main (){
    int l;cin>>l;
    vector<int>a={1,2,3,2,2,5,2,3,7,2,2,2,3,3,2,5,11};
    sort(range(a),greater<int>());
    int ans=1;
    rep(i,0,11){
        l--;
        ans*=l;
        rep(r,0,a.size()){
            if(ans%a[r]==0){
                ans/=a[r];
                a[r]=1;
            }
        }
    }
    cout<<ans<<nnn;
    return 0;
}


#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class S> inline int arrEraseVal_L(S val1, int &sz, S a[]){
  int i;
  int n = sz;
  sz = 0;
  for(i=(0);i<(n);i++){
    if(a[i]!=val1){
      a[sz++] = a[i];
    }
  }
  return n - sz;
}
int N;
int X;
int A[100000];
int main(){
  rd(N);
  rd(X);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  arrEraseVal_L(X, N, A);
  {
    int e98WHCEY;
    if(N==0){
      wt_L('\n');
    }
    else{
      for(e98WHCEY=(0);e98WHCEY<(N-1);e98WHCEY++){
        wt_L(A[e98WHCEY]);
        wt_L(' ');
      }
      wt_L(A[e98WHCEY]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay version 20210103-1 [bug fixed 2]

// --- original code ---
// int N, X, A[1d5];
// {
//   rd(N,X,A(N));
//   arrEraseVal(X, N, A);
//   wt(A(N));
// }

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

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

    int n, x;
    cin >> n >> x;

    int a = 0;
    rep(i, n){
        int v, p;
        cin >> v >> p;
        a += v * p ;

        if(x*100 < a){
            cout << i+1 << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}


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

using ll = long long;
using ii = pair<ll, ll>;

#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mp make_pair

const ll N = 2e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 2e9;
const ll dr4[] = {1, -1, 0, 0};
const ll dc4[] = {0, 0, 1, -1};
const ll dr8[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const ll dc8[] = {0, 1, 1, 1, 0, -1, -1, -1};

ll n, k;

void solve() {
  cin >> n >> k;

  const auto G1 = [&](ll x) {
    ll freq[10];
    memset(freq, 0, sizeof(freq));
    while(x) {
      freq[x % 10]++;
      x /= 10;
    }

    ll ret = 0;
    for(ll i = 9; i >= 0; i--) {
      for(ll j = 1; j <= freq[i]; j++) {
        ret = ret * 10 + i;
      }
    }

    return ret;
  };

  const auto G2 = [&](ll x) {
    ll freq[10];
    memset(freq, 0, sizeof(freq));
    while(x) {
      freq[x % 10]++;
      x /= 10;
    }

    ll ret = 0;
    for(ll i = 1; i <= 9; i++) {
      for(ll j = 1; j <= freq[i]; j++) {
        ret = ret * 10 + i;
      }
    }

    return ret;
  };

  ll ans = n;
  for(ll i = 0; i < k; i++) {
    ll g1 = G1(ans);
    ll g2 = G2(ans);
    ans = g1 - g2;
  }

  cout << ans << "\n";
}

int main() {

  ios_base::sync_with_stdio(0);
  // cin.tie(0); cout.tie(0);

  ll T = 1;
  // cin >> T;
  for(ll tc = 1; tc <= T; tc++) {
    solve();
  }

}

#ifdef __LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using PIL = pair<int,ll>;
using PLI = pair<ll,int>;
using PLL = pair<ll,ll>;
using Graph = vector<vector<int>>;
using Cost_Graph = vector<vector<PIL>>;

template<class T> bool chmin(T &a, T b) {if(a>b){a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b){a=b;return 1;}return 0;}
#define rep(i,n) for(int i=0;i<int(n);i++)
#define roundup(a,b) (a+b-1)/b
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;
const double pi = 3.14159265358979;

ll func(int x){
    string s = to_string(x);
    string t = to_string(x);

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    ll big = stoll(t);
    ll small = stoll(s);

    return (big - small);
}

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

    ll n,k;
    cin >> n >> k;

    for (int i = 0; i < k; i++){
        n = func(n);
    }

    cout << n << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 1e5 + 5;
inline int read()
{
    int w = 0, f = 1;
    char ch = getchar();
    while (ch < '0' or ch > '9')
    {
        if (ch == '-')
            f = -f;
        ch = getchar();
    }
    while (ch >= '0' and ch <= '9')
        w = w * 10 + ch - '0', ch = getchar();
    return w * f;
}
int L[maxn], R[maxn], A[maxn], N, M, K;
bool check(int limit)
{
    for (int i = 1; i <= K; i++)
        L[i] = ((A[i] * M - limit + N - 1) / N), R[i] = ((A[i] * M + limit) / N);
    for (int i = 1; i <= K; i++)
        L[i] = max(L[i], 0ll);
    for (int i = 1; i <= K; i++)
        if (L[i] > R[i])
            return 0;
    int lsum = 0, rsum = 0;
    for (int i = 1; i <= K; i++)
        lsum += L[i], rsum += R[i];
    if (lsum <= M and rsum >= M)
        return 1;
    return 0;
}
signed main()
{
    scanf("%lld%lld%lld", &K, &N, &M);
    for (int i = 1; i <= K; i++)
        scanf("%lld", &A[i]);
    int l = 0, r = M * N;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if (check(mid))
            r = mid - 1;
        else
            l = mid + 1;
    }
    check(l);
    int lsum = 0;
    for (int i = 1; i <= K; i++)
        lsum += L[i];
    int res = M - lsum;
    for (int i = 1; i <= K; i++)
    {
        printf("%lld ", min(L[i] + res, R[i]));
        res -= min(L[i] + res, R[i]) - L[i];
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
ll N,M,Q;
map<ll,ll>mp;
map<ll,ll>mp1;
P dat[2][800005];
ll n;
void init(ll n_){
  n=1;
while(n<=n_)n*=2;
  for(ll i=0;i<2*n-1;i++){
  dat[0][i]=P(0,0);
    dat[1][i]=P(0,0);
  }
}
void update(ll j,ll k,ll a){
 ll m=mp1.at(k); k+=n-1;
dat[j][k].first+=a;dat[j][k].second+=a*m;
  while(0<k){
  k=(k-1)/2;
    dat[j][k].first=(dat[j][2*k+1].first+dat[j][2*k+2].first);
    dat[j][k].second=(dat[j][2*k+1].second+dat[j][2*k+2].second);
  }

}
P query(ll j,ll a,ll b,ll k,ll l,ll r){
if(a<=l&&r<=b)return dat[j][k];
  else if(b<=l||r<=a)return P(0,0);
  else{

  P val=query(j,a,b,2*k+1,l,(l+r)/2);
    P var=query(j,a,b,2*k+2,(l+r)/2,r);
    P p(val.first+var.first,val.second+var.second);
    return p;

  }

}
int main(){
  cin>>N>>M>>Q;
  set<ll>S;S.insert(0);
  vector<ll>T(Q);vector<ll>X(Q);vector<ll>Y(Q);
  for(ll q=0;q<Q;q++){
  cin>>T[q];cin>>X[q];X[q]--;cin>>Y[q];S.insert(Y[q]);
  }ll I=0;
  for(auto x:S){mp[x]=I;I++;}
  for(auto p:mp){mp1[p.second]=p.first;}vector<ll>A(N);vector<ll>B(M);ll ans=0;
  init(I);update(0,0,N);update(1,0,M);
    for(ll q=0;q<Q;q++){
 if(T[q]==1){
 ans-=query(1,0,mp.at(A[X[q]])+1,0,0,n).first*A[X[q]];
 if(A[X[q]]<Y[q]){
 ans-=query(1,mp.at(A[X[q]])+1,mp.at(Y[q])+1,0,0,n).second;
 }else if(Y[q]<A[X[q]]){
  ans+=query(1,mp.at(Y[q])+1,mp.at(A[X[q]])+1,0,0,n).second;
 }else{}
 ans+=query(1,0,mp.at(Y[q])+1,0,0,n).first*Y[q];update(0,mp.at(A[X[q]]),-1);
             update(0,mp.at(Y[q]),1);A[X[q]]=Y[q];
 }else{
  ans-=query(0,0,mp.at(B[X[q]])+1,0,0,n).first*B[X[q]];
 if(B[X[q]]<Y[q]){
 ans-=query(0,mp.at(B[X[q]])+1,mp.at(Y[q])+1,0,0,n).second;
 }else if(Y[q]<B[X[q]]){
  ans+=query(0,mp.at(Y[q])+1,mp.at(B[X[q]])+1,0,0,n).second;
 }else{}
 ans+=query(0,0,mp.at(Y[q])+1,0,0,n).first*Y[q];update(1,mp.at(B[X[q]]),-1);
             update(1,mp.at(Y[q]),1);B[X[q]]=Y[q];
 }cout<<ans<<endl;
  }

 return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b)
    cout << c << endl;
  else if(b == c)
    cout << a << endl;
  else if(c == a)
    cout << b << endl;
  else
    cout << 0 << endl;
}

// /*
// power code taken from geeks for geeks
// */
// cout << setprecision (2) << fixed << 1.2;

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;

// THINGS TO REMEMBER
// ENDL is slow, '\n' is fast
// Clear everything (including graphs) between test cases
// use anti-anti-hash: https://codeforces.com/blog/entry/62393
// pb-ds: https://codeforces.com/blog/entry/11080
// check when to use LLONG_MAX/LLONG_MIN vs INT_MAX or INT_MIN
// You frequently suffer from confirmation bias - you trust your initial solution and miss simple things.
// When you hit a roadblock, remember to rethink the solution ground up, not just try hacky fixes

#define PLL pair<ll, ll>
#define en endl

const ll INF = 1e18 + 5;
const ll MAX_N = 1e5 + 5;
const ll MODD = 1e9 + 7;
const ll BITS = 10;

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

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return (a + MODD) % MODD; }

void swap(ll &a, ll &b) {
    ll t = a;
    a = b;
    b = t;
}

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;

    ll P = power(k, p/2LL);
    P = (P * P) % MODD;

    if (p % 2 == 1)
        P = (P * k) % MODD;

    return P;
}
int iii = 0;void _debug() {cout << "here " << (iii++) << endl;}

void solve() {
    ll a1, a2, a3, a4;
    cin >> a1 >> a2 >> a3 >> a4;
    cout << min({a1, a2, a3, a4}) << endl;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // init();

    ll t=1;

    // cin >> t;

    for(ll i = 0; i < t; i++) {

        // cout << "---------------case " << i + 1 << endl;

        // cout << "Case #" << i + 1 << ": ";

        // cout << endl;

        solve();
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;

int64_t mod = 998244353 ;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

vector<int> getprime(int n){
    vector<int> p(0) ;
    vector<bool> table(n+1,0) ;
    for (int i = 2; i <= n; i++)
    {
        if (table.at(i) == 0)
        {
            p.push_back(i) ;
            for (size_t j = 2; j < n/i ; j++)
            {
                table.at(i*j) = 1 ;
            }

        }

    }
    return p ;
}

int getnum(vector<int> &array, vector<char> &c, char a){
    for (int i = 0; i < c.size(); i++)
    {
        if (a == c.at(i))
        {
            return array.at(i) ;
        }

    }

}

int main(){
    string s1,s2,s3 ;
    cin >> s1 >> s2 >> s3 ;
    vector<int> array(10,0) ;
    for (int i = 0; i < 10; i++)
    {
        array.at(i) = i ;
    }
    vector<char> c(0) ;
    for (int i = 0; i < s1.size(); i++)
    {
        bool ok = 1 ;
        for (int j = 0; j < c.size(); j++)
        {
            if (s1.at(i) == c.at(j))
            {
                ok = 0 ;
                break ;
            }

        }
        if (ok)
        {
            c.push_back(s1.at(i)) ;
        }

    }
    for (int i = 0; i < s2.size(); i++)
    {
        bool ok = 1 ;
        for (int j = 0; j < c.size(); j++)
        {
            if (s2.at(i) == c.at(j))
            {
                ok = 0 ;
                break ;
            }

        }
        if (ok)
        {
            c.push_back(s2.at(i)) ;
        }

    }
    for (int i = 0; i < s3.size(); i++)
    {
        bool ok = 1 ;
        for (int j = 0; j < c.size(); j++)
        {
            if (s3.at(i) == c.at(j))
            {
                ok = 0 ;
                break ;
            }

        }
        if (ok)
        {
            c.push_back(s3.at(i)) ;
        }

    }
    /*
    for (int i = 0; i < c.size(); i++)
    {
        cout << c.at(i) ;
    }
    */

    if (c.size() > 10)
    {
        cout << "UNSOLVABLE" << endl ;
        return 0 ;
    }

    do
    {
        bool ng = 0 ;
        int64_t n1 = 0 ;
        int64_t n2 = 0 ;
        int64_t n3 = 0 ;
        for (int i = 0; i < s1.size(); i++)
        {
            int next = getnum(array,c,s1.at(i)) ;
            if (i == 0 && next == 0)
            {
                ng = 1 ;
                break ;
            }else
            {
                n1 = n1*10 + next ;
            }

        }
        for (int i = 0; i < s2.size(); i++)
        {
            int next = getnum(array,c,s2.at(i)) ;
            if (i == 0 && next == 0)
            {
                ng = 1 ;
                break ;
            }else
            {
                n2 = n2*10 + next ;
            }

        }
        for (int i = 0; i < s3.size(); i++)
        {
            int next = getnum(array,c,s3.at(i)) ;
            if (i == 0 && next == 0)
            {
                ng = 1 ;
                break ;
            }else
            {
                n3 = n3*10 + next ;
            }

        }

        if (ng)
        {
            continue ;
        }
        if (n1 + n2 == n3)
        {
            cout << n1 << endl ;
            cout << n2 << endl ;
            cout << n3 << endl ;

            return 0 ;
        }

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

    cout << "UNSOLVABLE" << endl ;

}

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

#define rep(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
#define rrep(i, a, b) for (int i = (int)(b) - 1; (i) >= (int)(a); (i)--)
#define all(v) v.begin(), v.end()

typedef long long ll;
template <class T> using V = vector<T>;
template <class T> using VV = vector<V<T>>;

/* 提出時これをコメントアウトする */
#define LOCAL true

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    constexpr char endl = '\n';

    string s[3];
    rep(i,0,3) cin >> s[i];
    map<char,int> v;
    rep(i,0,3) {
        rep(j,0,s[i].size()) {
            v[s[i][j]] = 0;
        }
    }
    string ss = "";
    for (auto e: v) {
        ss.push_back(e.first);
    }
    V<bool> used(10);

    auto dfs = [&] (auto self, int k) -> bool {
        if (k == v.size()) {
            ll n[3] = {};
            rep(i,0,3) {
                rep(j,0,s[i].size()) {
                    if (j == 0 && v[s[i][j]] == 0) return false;
                    n[i] *= 10;
                    n[i] += v[s[i][j]];
                }
            }
            return n[0] + n[1] == n[2];
        }
        rep(i,0,10) {
            if (used[i]) continue;
            v[ss[k]] = i;
            used[i] = 1;
            if (self(self, k+1)) return true;
            used[i] = 0;
        }
        return false;
    };

    bool result = dfs(dfs, 0);
    if (v.size() > 10) result = 0;

    if (!result) {
        cout << "UNSOLVABLE" << endl;
    } else {
        rep(i,0,3) {
            rep(j,0,s[i].size()) {
                cout << v[s[i][j]];
            }
            cout << endl;
        }
    }
    return 0;
}


#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<iostream>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int IM = 2e9;
int dat[400004];

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

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

	int N = getint();
	dat[0] = -IM;
	ll kotae = -IM * ll(N);
	for (int i = N + 1; i > 1; i--) {
		dat[i] = getint();
		kotae += dat[i];
	}

	for (int i = 2; i < N + 2; i++) {

		int p = 2 + (dat[2] > dat[3]);
		int v = dat[i] - IM;
		while (v > dat[p]) {
			dat[p >> 1] = dat[p];
			p <<= 1;
			p += dat[p] > dat[p + 1];
		}
		dat[p >> 1] = v;

		int a = getint();
		kotae += a;
		p = i;
		v = a - IM;
		while (v < dat[p >> 1]) dat[p] = dat[p >> 1], p >>= 1;
		dat[p] = v;

		kotae -= dat[1];
	}

	co(kotae);

	Would you please return 0;
}

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

using namespace std;

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

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

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

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

#if 1

ll gcd(ll a, ll b) {
  while (b) { a %= b; swap(b, a); } return a;
}
ll extGCD(ll a, ll b, pll& out) {
  ll l = a, r = b;
  ll la = 1, lb = 0, ra = 0, rb = 1;

  while (true) {

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

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

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

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

ll solve() {
  int N, S, K;
  cin >> N >> S >> K;

  /*
  S + K * x = 0 mod N
  K * x = (N-S) mod N

  x = (N-S) / K mod N

  mod N での K の逆数

  */
  ll g = gcd(K, N);
  if (S % g) return -1;
  S /= g; K /= g; N /= g;
  pll out;
  extGCD(K, N, out);
  //show(out.first);
  //show(N);
  //show(mod(out.first,N));
  return mod(out.first, N) * (N - S) % N;
}

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

  int T; cin >> T;
  F0R(i, T) {
    cout << solve() << newl;
  }
}
#endif


// #define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i,s,n) for (int i = (ll)s; i < (ll)n; i++)
#define rrep(i,n,e) for (int i = (ll)n; i > (ll)e; i--)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
// #define M_PI 3.14159265358979323846 // CF
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) cout << fixed << setprecision(10) << x << endl; // print Decimal number 10 Rank
#define endl "\n"
#define Case(x) printf("Case #%d: ", x); // gcj

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<char> vch;
typedef vector<vector<char>> vvch;

constexpr ll INF = 1001002003004005006ll;
constexpr int n_max = 2e5+10;

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

template<class T, class U>
T POW(T x, U n) {T ret=1; while (n>0) {if (n&1) {ret*=x;} x*=x; n>>=1;} return ret;};

// debug
template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';};
string to_string(const char c) {return to_string((string) &c);};
string to_string(bool b) {return (b ? "true" : "false");};
template <size_t N>
string to_string(bitset<N> v){
  string res = "";
  for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
  return res;
};
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for(const auto &x : v) {
    if(!first) res += ", ";
    first = false; res += to_string(x);
  }
  res += "}";
  return res;
};
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

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

void LINE_OUT() {
  cout << "--------------" << endl;
};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define LINE LINE_OUT();
#else
#define debug(...) 71
#define LINE 71;
#endif

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

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, W;
  cin >> A >> B >> W;
  int ma = -INF, mi = INF;
  rep(i, 1, 1000005) {
    if (A*i <= W*1000 && W*1000 <= B*i) {
      chmin(mi, i);
      chmax(ma, i);
    }
  }

  if (mi == INF) {
    cout << "UNSATISFIABLE" << endl;
  } else {
    cout << mi << " " << ma << endl;
  }

  return 0;
};

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

int A,B;
long long k;
long long dp[50][50];

int main(void){
    // freopen("D.in","r",stdin);
    // freopen("D.out","w",stdout);
    scanf("%d %d",&A,&B);
    cin>>k;
    dp[0][0]=1;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            if(i>0)dp[i][j]+=dp[i-1][j];
            if(j>0)dp[i][j]+=dp[i][j-1];
        }
    }
    while(A>=1&&B>=1){
        if(k<=dp[A-1][B]){
            A-=1;
            printf("a");
        }
        else{
            k-=dp[A-1][B];
            B--;
            printf("b");
        }
    }
    for(int i=1;i<=A;i++)printf("a");
    for(int i=1;i<=B;i++)printf("b");
}


#include <bits/stdc++.h>
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define REPS(i, ss, nn ) for(int i = ss ; i < (int) nn; i++)
#define REV(i, ss, nn ) for(int i = ss ; i >= nn; i--)
#define deb(x) std::cout << #x << " " << x << endl;
#define debl(x) std::cout << #x << " " << x << " ";
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
namespace std{
    template<class Fun>
    class y_combinator_result{
        Fun fun_;
        public:
            template<class T>
            explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)){}
            template<class ...Args>
            decltype(auto) operator()(Args&&...args){
                return fun_(std::ref(*this), std::forward<Args>(args)...);
            }
    };
    template<class Fun>
    decltype(auto) y_combinator(Fun && fun){
        return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
    }
};
template<typename T>
bool u_max(T& a, T b){
    if( a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
bool u_min(T& a, T b){
    if( a > b){
        a = b;
        return true;
    }
    return false;
}
struct edge{
    int to, from;
    ll cost;
    edge(){ edge(0,0);}
    edge(int to_, ll cost_){ edge(to_, -1, cost_);}
    edge(int to_, int from_, ll cost_) : to(to_), from(from_), cost(cost_){}
    // edge(int to_, int from_) : to(to_), from(from_){};
};

template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}

void solve(){
    int n, m;
    read(n, m);
    vector<vector<int>> e(n, vector<int>(n, 0));
    REP(i, m){
        int a, b;
        read(a, b);
        a--; b--;
        e[a][b] = e[b][a] = 1;
    }
    int state = 1;
    const int state_num = 1 << n;
    vector<bool> connected(state_num, true);
    auto state_contain = [](int s, int i) -> bool{
        // cout << "test " << s << " " << i << endl;
        // cout << "-> " << ((1<<i) & s ? true : false) << endl;
        return (1<<i) & s ? true : false;
    };
    auto is_connected = [&](int s) -> bool{
        // cout << "test " << s << endl;
        for(int i = 0 ; i < n ; i++){
            for(int j = i+1; j < n ; j++){
                if( ! state_contain(s, i) ) continue;
                if( ! state_contain(s,j) ) continue;
                if(e[i][j] == 0){
                    return false;
                }
            }
        }
        return true;
    };
    vector<int> group(n);
    REP(i, n){
        group[i] = 1 << i;
    }
    REP(ss, state_num){
        connected[ss] = is_connected(ss);
        if(connected[ss]){
            // deb(ss)
            for(int i = 0 ; i < n ; i++){
                if(state_contain(ss, i)) group[i] = ss;
            }
        }
    }
    // cout << "start dp" << endl;

    //max group size
    int INF = 1 << 30;
    vi dp(state_num, INF);
    dp[0] = 0;
    while (state < state_num){
        if(connected[state]){
            dp[state] = 1;
            state++;
            continue;
        }
        // deb(state)
        for(int submask = state; submask; submask=(submask-1)&state){
            dp[state] = min(dp[state], dp[submask] + dp[state^submask]);
        }
        state++;
    }
    cout << dp[state_num-1] << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}

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

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
//#define inf 1010000000
#define inf 4000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr << x << endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr << x << ", "; _do(y...);}
#else
#define bug(...) 826
#endif
template<typename T> void print(T && x) {cout << x << "\n";}
template<typename T, typename... S> void print(T && x, S&&... y) {cout << x << ' ';print(y...);}

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
const int maxn=100005;
//i_am_noob
int n;

int solve(int x){
    while(x>=n) x-=pow2(__lg(x));
    return x;
}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    rep(n) print(solve(i<<1)+1,solve(i<<1|1)+1);
    return 0;
}


#include<algorithm>
#include<cstdio>
#define MaxN 200500
#define ll long long
using namespace std;
const int mod=998244353;
ll powM(ll a,int t=mod-2){
  ll ret=1;
  while(t){
    if (t&1)ret=ret*a%mod;
    a=a*a%mod;t>>=1;
  }return ret;
}
ll fac[MaxN],ifac[MaxN];
ll C(int n,int m)
{return fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
void Init(int n)
{
  fac[0]=1;
  for (int i=1;i<=n;i++)
    fac[i]=fac[i-1]*i%mod;
  ifac[n]=powM(fac[n]);
  for (int i=n;i;i--)
    ifac[i-1]=ifac[i]*i%mod;
}
int d[MaxN][22];
void sieve(int n)
{
  for (int i=1;i<=n;i++){
    d[i][1]=1;
    for (int j=i+i;j<=n;j+=i)
      for (int k=1;k<20;k++)
        d[j][k+1]=(d[j][k+1]+d[i][k])%mod;
  }
}
ll buf[22];
int n,m;
int main()
{
  scanf("%d%d",&n,&m);
  Init(n+20);sieve(m);
  ll ans=0;
  for (int k=1;k<=min(20,n);k++)buf[k]=C(n-1,k-1);
  for (int i=1;i<=m;i++)
    for (int k=1;k<=min(20,n);k++)
      ans=(ans+d[i][k]*buf[k])%mod;
  printf("%lld",ans);
  return 0;
}

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

const ll inf = 1e18;
const ll mod = 998244353;

// nCr (mod p) 計算量 O(3*10^5*logp)
const ll Maximum = 3e5;
ll Fac[Maximum], iFac[Maximum];
bool made_Fac = false;
// x^n (mod p) 計算量 O(logn)
ll powmodp(ll x, ll n) {
    if (n==0) return 1;
    else if (n%2==0) {
        ll ans = powmodp(x,n/2);
        return ans*ans % mod;
    }
    else return x * powmodp(x,n-1) % mod;
}
// nCr (mod p) 計算量 O(3*10^5*logp)
void make_Fac() {
    Fac[0] = 1;
    iFac[0] = 1;
    for (ll i=0; i<Maximum; i++) {
        Fac[i+1] = Fac[i] * (i+1) % mod;
        iFac[i+1] = iFac[i] * powmodp(i+1,mod-2) % mod;
    }
}
ll nCrmodp(ll n, ll r) {
    if (!made_Fac) {
        make_Fac();
        made_Fac = true;
    }
    r = min(r,n-r);
    if (n==0 or r==0) return 1;
    ll tmp = iFac[n-r] * iFac[r] % mod;
    return tmp * Fac[n] % mod;
}

vector<ll> prime_counter(ll N) {
    vector<ll> res;
    for (ll i=2; i*i<=N; i++) {
        if (N%i) continue;
        ll cnt = 0;
        while (N%i==0) {cnt++; N/=i;}
        res.push_back(cnt);
    }
    if (N!=1) res.push_back(1);
    return res;
}

int main() {
    ll N, M; cin >> N >> M;

    ll ans = 0;
    for (ll i=1; i<=M; i++) {
        vector<ll> div = prime_counter(i);
        ll add = 1;
        for (ll cnt : div) {
            ll tmp = nCrmodp(cnt+N-1,N-1);
            add = add * tmp % mod;
        }
        ans = (ans + add) % mod;
    }

    cout << ans << endl;
}


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

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

    int n;
    while (scanf("%d", &n) == 1) {
        vector<int> a(n, 1);
        for (auto &x : a) scanf("%d", &x);

        map<long long, int> m = { { 0, 1 } };
        long long s[2] = { 0 } ;
        long long res = 0;
        for (int i = 0; i < n; i++) {
            s[i % 2] += a[i];
            res += m[s[0] - s[1]];
            m[s[0] - s[1]]++;
        }
        printf("%lld\n", res);
    }
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<ll> d_even(n), d_odd(n);
  d_even[0] = a[0];
  d_odd[0] = -a[0];
  FOR(i, 1, n) {
    d_even[i] = a[i] * (i & 1 ? -1 : 1) + d_even[i - 1];
    d_odd[i] = a[i] * (i & 1 ? 1 : -1) + d_odd[i - 1];
  }
  // REP(i, n) cout << d_even[i] << " \n"[i + 1 == n];
  // REP(i, n) cout << d_odd[i] << " \n"[i + 1 == n];
  map<ll, int> mp_even, mp_odd;
  REP(i, n) ++mp_even[d_even[i]];
  REP(i, n) ++mp_odd[d_odd[i]];
  ll ans = 0, cur_even = 0, cur_odd = 0;
  REP(i, n) {
    --mp_even[d_even[i]];
    --mp_odd[d_odd[i]];
    ans += (i & 1 ? mp_odd[cur_odd] : mp_even[cur_even]);
    cur_even += a[i] * (i & 1 ? -1 : 1);
    cur_odd += a[i] * (i & 1 ? 1 : -1);
  }
  cout << ans << '\n';
  return 0;
}


#pragma GCC optimize ("O2")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll A[200000], tmp[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 9;
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

const int CM = 1 << 17, CL = 20;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
const ll pre[9] = { 1,10,100,1000,10000,100000,1000000,10000000,100000000 };
inline ll getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		ll tmp2 = *(ll*)ci;
		if ((tmp2 & ma0) == ma0) {
			ci += 9;
			return 1000000000000000;
		}
		int dig = 68 - __builtin_ctzll((tmp2 & ma0) ^ ma0);
		if (dig == 64) {
			ci++;
			return tmp;
		}
		tmp2 = tmp2 << dig & ma1;
		tmp2 = tmp2 * 10 + (tmp2 >> 8) & ma2;
		tmp2 = tmp2 * 100 + (tmp2 >> 16) & ma3;
		tmp2 = tmp2 * 10000 + (tmp2 >> 32) & ma4;
		ci += (72 - dig >> 3);
		tmp = tmp * pre[64 - dig >> 3] + tmp2;
	}
	return tmp;
}

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

	int N = getint();

	int K[3] = {};
	rep(i, N << 1) {
		ll a = getint();
		char c = *ci++;
		ci++;
		ll C = (ll(c) >> 4 | ll(c) << 1) & 3;
		K[C]++;
		A[i] = a | C << 50;
	}
	pakuri_sort(N * 2, A);
	if (K[0] % 2 == 0 && K[1] % 2 == 0 && K[2] % 2 == 0) {
		co(0);
		return 0;
	}

	auto P = A;
	auto Q = A + K[0];
	auto R = A + K[0] + K[1];
	const ll ma = (1ll << 50) - 1;
	for(int i = N * 2 - 1; i >= K[0]; i--) A[i] &= ma;
	ll sai[3] = {};
	ll saiq = 1e18, sair = 1e18;
	int q = 0, r = 0;
	rep(p, K[0]) {
		if (q < K[1]) if (saiq > abs(Q[q] - P[p])) saiq = abs(Q[q] - P[p]);
		while (q < K[1] - 1 && Q[q] < P[p]) {
			q++;
			if (saiq > abs(Q[q] - P[p])) saiq = abs(Q[q] - P[p]);
		}
		if (r < K[2]) if (sair > abs(R[r] - P[p])) sair = abs(R[r] - P[p]);
		while (r < K[2] - 1 && R[r] < P[p]) {
			r++;
			if (sair > abs(R[r] - P[p])) sair = abs(R[r] - P[p]);
		}
	}
	sai[2] = saiq;
	sai[1] = sair;
	sair = 1e18;
	r = 0;
	q = 0;
	while (q < K[1]) {
		if (r < K[2]) if (sair > abs(R[r] - Q[q])) sair = abs(R[r] - Q[q]);
		while (r < K[2] - 1 && R[r] < Q[q]) {
			r++;
			if (sair > abs(R[r] - Q[q])) sair = abs(R[r] - Q[q]);
		}
		q++;
	}
	sai[0] = sair;
	ll kotae = 1e18;
	if (K[0] % 2 == 0) kotae = min(sai[0], sai[1] + sai[2]);
	else if (K[1] % 2 == 0) kotae = min(sai[1], sai[2] + sai[0]);
	else kotae = min(sai[2], sai[0] + sai[1]);
	co(kotae);

	Would you please return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
char In[1 << 20], *ss = In, *tt = In;
#define getchar() (ss == tt && (tt = (ss = In) + fread(In, 1, 1 << 20, stdin), ss == tt) ? EOF : *ss++)
ll read() {
	ll x = 0, f = 1; char ch = getchar();
	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + int(ch - '0');
	return x * f;
}
int readrgb() {
	char ch = getchar();
	for(; ch != 'R' && ch != 'G' && ch != 'B'; ch = getchar());
	return ch == 'R' ? 0 : (ch == 'G' ? 1 : 2);
}
const int MAXN = 1e5 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
int n;
vector<ll> ori[3];

ll getmindis(const vector<ll>& p, const vector<ll>& q) {
	if(!p.size() || !q.size()) return INF;
	ll ret = INF;
	for(int i = 0, j = 0; i < (int)p.size(); i++) {
		while(j < (int)q.size()-1 && q[j+1] <= p[i]) j++;
		if(q[j] <= p[i]) ret = min(ret, p[i] - q[j]);
	}
	for(int i = (int)p.size()-1, j = (int)q.size()-1; i >= 0; i--) {
		while(j > 0 && q[j-1] >= p[i]) j--;
		if(q[j] >= p[i]) ret = min(ret, q[j] - p[i]);
	}
	return ret;
}

int main() {
	n = read();
	for(int i = 1; i <= 2 * n; i++) {
		ll a = read(), c = readrgb();
		ori[c].push_back(a);
	}
	if((ori[0].size()&1) < (ori[1].size()&1)) swap(ori[0], ori[1]);
	if((ori[1].size()&1) < (ori[2].size()&1)) swap(ori[1], ori[2]);
	if((ori[0].size()&1) == 0) {
		printf("0\n");
		return 0;
	}
	sort(ori[0].begin(), ori[0].end());
	sort(ori[1].begin(), ori[1].end());
	sort(ori[2].begin(), ori[2].end());
	printf("%lld\n", min(getmindis(ori[0], ori[1]), getmindis(ori[0], ori[2]) + getmindis(ori[1], ori[2])));
	return 0;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
    string sep = " ";
    if(v.size()) os << v[0];
    for(int i=1; i<v.size(); i++) os << sep << v[i];
    return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
    for(int i=0; i<v.size(); i++) is >> v[i];
    return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
    cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    cin >> a;

    vector<vector<int>> score(h, vector<int>(w));
    for(int x=h-1; x>=0; x--){
        for(int y=w-1; y>=0; y--){
            if(x==h-1&&y==w-1) continue;
            score[x][y] = -1e9;

            if(x<h-1){
                int p = a[x+1][y]=='+'?1:-1;
                score[x][y] = max(score[x][y], p-score[x+1][y]);
            }

            if(y<w-1){
                int p = a[x][y+1]=='+'?1:-1;
                score[x][y] = max(score[x][y], p-score[x][y+1]);
            }
        }
    }

    if(score[0][0]>0) cout << "Takahashi" << endl;
    else if(score[0][0]<0) cout << "Aoki" << endl;
    else cout << "Draw" << endl;

    return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

#define endl '\n'
#define int long long int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define revrep(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))

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

ostream &operator<<( ostream &output, const pii &p ) { output << p.first << " " << p.second;return output; }
istream &operator>>( istream &input, pii &p ) { input >> p.first >> p.second;return input; }
template<typename T>
void inline println(vector<T> args){ for(T i: args)cout<<i<<" ";cout<<endl; }
void amax(int& a, int b) { a = max(a, b); }
void amin(int& a, int b) { a = min(a, b); }
int ceilInt(int a, int b) {
    if(!b) return 0;
    if(a%b) return a/b + 1;
    return a/b;
}

int INF = 1e18;
int MOD = 998244353;

void solve()
{
    int n, m, w; cin>>n>>m>>w;
    vi minCol(n, m), minRow(m, n);
    vector<vi> obsRow(m), obsCol(n);
    rep(t, 0, w) {
        int i, j; cin>>i>>j;
        i--, j--;
        minCol[i] = min(minCol[i], j);
        minRow[j] = min(minRow[j], i);
        obsRow[j].pb(i);
        obsCol[i].pb(j);
    }
    int ans = 0, extra = 0;
    ordered_set<int> os;
    rep(j, 0, minCol[0]){
        ans += minRow[j];
        int key = min(minRow[j], minRow[0]);
        extra += max(0LL, key-(int)os.order_of_key(key));
        for(int i: obsRow[j]) os.insert(i);
    }
    os.clear();
    rep(i, 0, minRow[0]) {
        ans += minCol[i];
        int key = min(minCol[i], minCol[0]);
        extra += max(0LL, key-(int)os.order_of_key(key));
        for(int j: obsCol[i]) os.insert(j);
    }
    cout<<ans-extra/2<<endl;
}

signed main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    rep(i, 0, t)
    {
        solve();
    }
    return 0;
}


#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <map>
using namespace std;
using ll = long long;

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

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

	ll ans = 0;
	for(int i = 0 ; i < n; ++i)
	{
		ans += a[i] * (2 * i - (n - 1));
	}

	cout << ans << endl;
}

// EXPLOSION!
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include<chrono>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpll;

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

#define pb push_back
#define mp make_pair
#define rsz resize
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define cont continue
#define endl '\n'
//#define ednl '\n'
#define test int testc;cin>>testc;while(testc--)
#define pr(a, b) trav(x,a)cerr << x << b; cerr << endl;
#define message cout << "Hello World" << endl;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 }; // for every grid problem!!
const ll linf = 4000000000000000000LL;
const ll inf = 1000000007;//998244353

void pv(vi a) { trav(x, a)cout << x << " "; cout << endl; }void pv(vll a) { trav(x, a)cout << x << " "; cout << endl; }void pv(vector<vi>a) {
	F0R(i, sz(a)) { cout << i << endl; pv(a[i]); cout << endl; }
}void pv(vector<vll>a) { F0R(i, sz(a)) { cout << i << endl; pv(a[i]); }cout << endl; }void pv(vector<string>a) { trav(x, a)cout << x << endl; cout << endl; }
void setIO(string s) {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef arwaeystoamneg
	if (sz(s))
	{
		freopen((s + ".in").c_str(), "r", stdin);
		if (s != "test1")
			freopen((s + ".out").c_str(), "w", stdout);
	}
#endif
}

template<int MOD, int RT> struct mint {
	static const int mod = MOD;
	static constexpr mint rt() { return RT; } // primitive root for FFT
	int v; explicit operator int() const { return v; } // explicit -> don't silently convert to int
	mint() { v = 0; }
	mint(ll _v) {
		v = int((-MOD < _v&& _v < MOD) ? _v : _v % MOD);
		if (v < 0) v += MOD;
	}
	friend bool operator==(const mint& a, const mint& b) {
		return a.v == b.v;
	}
	friend bool operator!=(const mint& a, const mint& b) {
		return !(a == b);
	}
	friend bool operator<(const mint& a, const mint& b) {
		return a.v < b.v;
	}

	mint& operator+=(const mint& m) {
		if ((v += m.v) >= MOD) v -= MOD;
		return *this;
	}
	mint& operator-=(const mint& m) {
		if ((v -= m.v) < 0) v += MOD;
		return *this;
	}
	mint& operator*=(const mint& m) {
		v = int((ll)v * m.v % MOD); return *this;
	}
	mint& operator/=(const mint& m) { return (*this) *= inv(m); }
	friend mint power(mint a, ll p) {// MAKE SURE YOU ARE USING THE CORRECT VERSION OF POW!!!!!!!!
		mint ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	friend mint inv(const mint& a) {
		assert(a.v != 0);
		return power(a, MOD - 2);
	}

	mint operator-() const { return mint(-v); }
	mint& operator++() { return *this += 1; }
	mint& operator--() { return *this -= 1; }
	friend mint operator+(mint a, const mint& b) { return a += b; }
	friend mint operator-(mint a, const mint& b) { return a -= b; }
	friend mint operator*(mint a, const mint& b) { return a *= b; }
	friend mint operator/(mint a, const mint& b) { return a /= b; }
};

typedef mint<inf, 5> mi; // 5 is primitive root for both common mods
int main()
{
	setIO("test1");
	int n;
	cin >> n;
	vi a(n);
	trav(x, a)cin >> x;
	sort(all(a));
	mi ans = 1 + a[0];
	F0R(i, n - 1)
		ans *= (a[i + 1] - a[i] + 1);
	cout << (int)ans << endl;
}


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

#define ll long long int
#define pb(a) push_back(a)
#define vll vector<ll>
#define loop(i, n) for(ll i=1;i<=n;i++)
#define loop0(i, n) for(ll i=0;i<n;i++)
#define in(i) scanf("%lld", &i);
#define out(i) printf("%lld", i)
#define pll pair<ll, ll>
#define vpll vector<pair<ll, ll>>
#define mp(i, j) make_pair(i, j)
#define google cout<<"Case #"<<tc-t<<": ";
const ll mod = 1000000007;
const ll big = 2999999999999999999;
const ll small = -2999999999999999999;
void in2(ll& a, ll& b) { in(a); in(b); }
void in3(ll& a, ll& b, ll& c) { in(a); in(b); in(c); }
void swap(ll& a, ll& b) { a = a+b; b = a-b; a = a-b; }
void arrayIn(vll& a, ll& n) { loop0(i, n) in(a[i]); }

ll n;
vll a;
vector<vpll> dp;

pll solve(ll i, bool pm)
{
  if(i == n)
    return {0, 1};
  if(dp[i][pm].second != -1)
    return dp[i][pm];
  if(pm)
  {
    pll b = solve(i+1, false);
    return dp[i][pm] = {(b.first + (b.second*a[i])%mod)%mod, b.second};
  }
  else
  {
    pll b = solve(i+1, false);
    pll c = solve(i+1, true);
    return dp[i][pm] = {((b.first+c.first)%mod+(((b.second-c.second+mod)%mod)*(a[i]%mod))%mod)%mod, (b.second+c.second)%mod};
  }
}

void solve()
{
  in(n);
  a.resize(n);
  dp.resize(n+1, vpll(2, {-1, -1}));
  loop0(i, n)
    in(a[i]);
  cout<<solve(0, true).first;
}

int main()
{
  solve();
}

#include <bits/stdc++.h>

#define foreach(i,v) for(auto&& i: v)
#define all(x) (x).begin(), (x).end()

typedef std::vector< std::string > VS;
typedef std::vector<int> VI;
typedef long long ll;
typedef std::pair<int, int> ii;

template <class C> C& mini(C& a, C b) { if (b < a) a = b; return a; }
template <class C> C& maxi(C& a, C b) { if (a < b) a = b; return a; }

template <typename T> void read(std::vector<T>& A) { for (T& x: A) std::cin >> x; }
template <typename T> void readv(std::vector<T>& A) { int N; std::cin >> N; A.resize(N); read(A); }

using namespace std;

#define MOD 1000000007

template <typename T>
void imfix(T& r) {
    if (r >= MOD)
        r -= MOD;
}

template <typename T>
T mfix(T r) {
    return r >= MOD ? r - MOD : r;
}

int main(int argc, const char* argv[]) {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.precision(20); cout.setf(ios::fixed);
    VI A;
    readv(A);
    int N = A.size();
    vector<ll> B(N+1), C(N+1);
    B[N] = 0;
    B[N-1] = A.back();
    C[N] = 1;
    C[N-1] = 1;
    for (int i = N-2; i >= 0; i--) {
        B[i] = (A[i] * C[i+1] + B[i+1]) % MOD + ((MOD + A[i] - A[i+1]) * C[i+2] + B[i+2]) % MOD;
        imfix(B[i]);
        imfix(C[i] = C[i+1] + C[i+2]);
    }
    cout << B[0] << endl;
    return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL = (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int N, M, K;
int A[101010];
int NG[101010];
long double dp[202020], S[202020];
long double solve(double v) {
  int i;

  for(i = N - 1; i >= 0; i--) {
    if(NG[i]) {
      dp[i] = v;
    } else {
      dp[i] = 1 + (S[i + 1] - S[i + 1 + M]) / M;
    }
    S[i] = S[i + 1] + dp[i];
  }
  return dp[0];
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> N >> M >> K;
  int p = -1, cur = 0;
  REP(i, K) {
    cin >> A[i];
    if(p + 1 != A[i])
      cur = 0;
    p = A[i];
    NG[A[i]] = 1;
    cur++;
    if(cur == M) {
      cout << -1 << endl;
      return 0;
    }
  };
  long double L = 0, R = 1e12;
  REP(i, 300) {
    long double M = (L + R) / 2;
    if(solve(M) > M)
      L = M;
    else
      R = M;
  }
  cout << setprecision(15) << L << endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

vector<vi>adj(200010);
vi vis(200010, 0), sum(2, 0), a(200010), b(200010);
void dfs(ll u) {
	vis[u] = 1;
	sum[0] += a[u];
	sum[1] += b[u];
	for (auto v : adj[u]) {
		if (vis[v])continue;
		dfs(v);
	}
}
int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n, m;
	cin >> n >> m;
	f(i, 1, n) {
		cin >> a[i];
	}
	f(i, 1, n) {
		cin >> b[i];
	}
	f(i, 1, m) {
		ll x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	f(i, 1, n) {
		if (!vis[i]) {
			sum.clear();
			sum = vi(2, 0);
			dfs(i);
			if (sum[0] != sum[1]) {
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";
	// read the stuff at the bottom
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* use int when constraints limits are tight
	* Time taken : global variable < pass by refernce < pass by value
	* It takes significant amt. of time in pass by value
	* Avoid Using endl
*/


#include "bits/stdc++.h"

using namespace std;

long long calc(int n){
    long long ret=1ll*(n*(n+1ll))/2ll;
    return ret;
}

void solve(){
    string s;
    cin>>s;
    int n=s.length();
    if(n==1){
        if(s[0]=='8'){
            cout<<"Yes\n";
        }
        else{
            cout<<"No\n";
        }
        return;
    }
    else if(n==2){
        int num1=(s[0]-'0')*10+s[1]-'0';
        int num2=(s[1]-'0')*10+s[0]-'0';
        if(num1%8==0 || num2%8==0){
            cout<<"Yes\n";
        }
        else{
            cout<<"No\n";
        }
        return;
    }
    int cnt[10];
    fill(cnt,cnt+10,0);
    for(auto c:s){
        cnt[c-'0']++;
    }
    // vector<vector<int>> req;
    for(int i=104;i<1000;i+=8){
        vector<int> temp(10,0);
        int j=i;
        while(j>0){
            temp[(j%10)]++;
            j/=10;
        }
        bool flag=false;
        for(j=0;j<10;j++){
            if(cnt[j]<temp[j]){
                flag=true;
                break;
            }
        }
        if(flag){
            continue;
        }
        cout<<"Yes\n";
        return;
    }
    cout<<"No\n";
}

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

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

using ll = long long;
using ld = long double;
using ordered_set = tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

const ll MOD = 1e9+7;
const ll INF = 1e18;
const ll N = 2e5+5;

#define S second
#define F first
#define vt vector
#define rep(i, st, en) for(ll i = (st); i < (en); ++i)
#define repr(i, en, st) for(ll i = (en); i >= (st); --i)

static bool dp[101][100001] = {0};

int main() {
	fastio();

	ll n;
	cin >> n;

	vt<ll> t(n);
	ll net = 0;
	rep(i, 0, n) {
		cin >> t[i];
		net += t[i];
	}

	dp[0][0] = dp[0][t[0]] = 1;

	ll mxt = 1e5;
	rep(i, 1, n) {
		rep(j, 0, mxt+1) {
			if (dp[i-1][j] || (j >= t[i] && dp[i-1][j-t[i]])) {
				dp[i][j] = 1;
			}
		}
	}

	ll ans = 0;
	ll neth = net/2;
	rep(i, 0, neth+1) {
		if (dp[n-1][i]) {
			ans = i;
		}
	}

	ans = max(ans, net-ans);
	cout << ans << '\n';

}


#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    int a, b;
    cin>> a>> b;
    int ans = 2*a + 100 - b;
    cout<< ans<< "\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer

int main()
{
    fast;
    int t = 1;
    // cin>> t;
    while(t--){
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);

/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/

// lower bound   >=
// upper bound   >
// vector<int>().swap(vec); //free memory from vec

#include<iostream>
using namespace std;
int main()
{
    int a, b;
    cin>>a>>b;
    cout<<2*a+100-b;
}


#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (c == 0) {
    if (a > b) {
      cout << "Takahashi" << endl;
    } else {
      cout << "Aoki" << endl;
    }
  } else {
    if (b > a) {
      cout << "Aoki" << endl;
    } else {
      cout << "Takahashi" << endl;
    }
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using ll = long long;
int mod = 1000000007;
const int INF = 1001001001;
template<class T> void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> void chmax(T& a, T b) {if (a < b) a = b;}
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
using Graph = vector<vector<int>>;
ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}

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


#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=2e5;
typedef int fuko[yuzu|10];
fuko a;
int main() {
  for (int t=read();t--;) {
  	int i,n=read();
  	for (i=1;i<=n;++i) a[i]=read();
  	sort(a+1,a+n+1);
  	if (n&1) puts("Second");
  	else {
	  int lxy=0;
  	  for (i=1;i<=n;i+=2) lxy|=a[i]^a[i+1]?1:0;
  	  puts(lxy?"First":"Second");
	}
  }
}

#include <bits/stdc++.h>
struct __fastio__ { __fastio__ () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } __fast_io__;
template<class T, class U> bool chmin (T &a, const U &b) { if (a > b) { a = b; return 1; } return 0; }
template<class T, class U> bool chmax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> void print(const T &value) { std::cout << value << '\n'; }
template<class T, class... Args> void print(const T &value, Args... args) { std::cout << value << ' '; print(args...); }
template<class T> using martix = std::vector<std::vector<T>>;
using i32 = std::int_fast32_t;
using u32 = std::uint_fast32_t;
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

void solve () {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	for (int &e : a) std::cin >> e;

	if (n & 1) {
		std::cout << "Second" << '\n';
	} else {
		std::map<int, int> mp;
		for (const int &e : a) mp[e]++;
		bool flag = true;
		for (const auto &p : mp) {
			flag &= (p.second % 2 == 0);
		}
		if (flag) std::cout << "Second" << '\n';
		else std::cout << "First" << '\n';
	}
}

int main() {
	int t;
	std::cin >> t;
	while (t--) solve();
	return 0;
}


#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ull unsigned long long
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define debug(x) cerr << #x << " = " << x << '\n';
#define pll pair <ll, ll>
#define fir first
#define sec second
#define INF 0x3f3f3f3f
#define int ll

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

int a,b,c,d;
signed main() {
  IO;
  cin >> a >> b >> c >> d;
  if (a == c && b == d) cout << 0 << '\n';
  else if (a + b == c + d || a - b == c - d) {
    cout << 1 << '\n';
  }else if (abs(a - c) + abs(b - d) <= 3) {
    cout << 1 << '\n';
  }else {
    if ((d - b - c + a) % 2 && abs(abs(d - b) - abs(c - a)) > 3) cout << 3 << '\n';
    else cout << 2 << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
#define int long long
// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint1000000007;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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 long double PI = acos(-1.0);
// cout << fixed << setprecision(14);

signed main() {
    int N, S, D;
    cin >> N >> S >> D;
    int X[N], Y[N];
    rep(i,N){
        cin >> X[i] >> Y[i];
    }
    rep(i,N){
        if(X[i] < S && Y[i] > D){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

#include<iostream>
using namespace std;
int main()
{
    int a, b, c;
    int ans;
    cin >> a >> b >> c;

    if (a == b) {
        ans = c;
    } else {
        if (b == c) {
            ans = a;
        } else {
            if (c == a) {
                ans = b;
            } else {
                ans = 0;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

void solve() {
  int n, m;
  cin >> n >> m;
  vector<i64> dp(1 << n);
  vector<vector<pair<int, int>>> conds(1 + n);
  while (m--) {
    int x, y, z;
    cin >> x >> y >> z;
    conds[x].emplace_back(y, z);
  }
  dp[0] = 1;
  for (int s = 0; s < 1 << n; s++) {
    for (auto [y, z] : conds[__builtin_popcount(s)]) {
      for (int i = 0; i < y; i++) {
        if (s >> i & 1) z--;
      }
      if (z < 0) dp[s] = 0;
    }
    for (int j = 0; j < n; j++)
      if (~s >> j & 1) {
        dp[s | 1 << j] += dp[s];
      }
  }
  cout << dp.back() << "\n";
}

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

  solve();
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define MOD(a, m) ((a % m + m) % m)
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; }
const ll MOD = 1e9+7;

int main(){
    ll N, M;
    cin >> N >> M;
    using P = pair<ll, ll>;
    vector<P> YZ[30];
    REP(i,M){
        ll x, y, z;
        cin >> x >> y >> z;
        //x--;
        YZ[x].push_back(P(y, z));
    }

    vector<ll> DP(1 << N);
    DP[0] = 1;
    for(int b = 0; b < (1 << N); b++){
        ll pop = __builtin_popcount(b);
        for(int v = 0; v < N; v++){
            if((b >> v) & 1) continue;
            bool valid = true;
            for(auto& [y, z] : YZ[pop+1]){
                ll num = 0;
                if(v+1 <= y) num++;
                for(int x = 0; x < y; x++){
                    if((b >> x) & 1)
                        num++;
                }

                if(num > z)
                    valid = false;
            }

            if(valid){
                DP[b | (1 << v)] += DP[b];
            }
        }
    }

    ll ans = DP[(1 << N) - 1];
    cout << ans << endl;
    return 0;
}