#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long int;
using ld = long double;

class BIT{
private:
    vector<ll> a;
    int n;
public:
    BIT(int len){
        a = vector<ll>(len+1, 0);
        n = len;
    }

    void add(int ind, ll x){
        ind++;
        while(ind <= n){
            a[ind] += x;
            ind += ind & (-ind);
        }
    }

    ll sum_sub(int end){
        end++;
        ll ans = 0;
        while(end > 0){
            ans += a[end];
            end -= end & (-end);
        }
        return ans;
    }

    ll sum(int start, int end){
        return sum_sub(end)-sum_sub(start-1);
    }
};

int main(){
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> t(q), x(q), y(q);
    for(int i = 0; i < q; i++) cin >> t[i] >> x[i] >> y[i];

    map<int, int> trans1;
    for(int i = 0; i < q; i++){
        x[i]--;
        trans1[y[i]] = 1;
    }
    {
        trans1[0] = 0;
        int i = 0;
        for(auto &p: trans1){
            p.second = i++;
        }
    }

    vector<ll> a(n, 0);
    vector<ll> b(m, 0);
    BIT acount(trans1.size()+1), bcount(trans1.size()+1);
    BIT asum(trans1.size()+1), bsum(trans1.size()+1);
    acount.add(0, n); bcount.add(0, m);
    ll ans = 0;
    for(int turn = 0; turn < q; turn++){
        if(t[turn] == 1){
            ans -= a[x[turn]] * bcount.sum(0, trans1[a[x[turn]]]);
            ans -= bsum.sum(trans1[a[x[turn]]]+1, trans1.size());

            acount.add(trans1[a[x[turn]]], -1);
            asum.add(trans1[a[x[turn]]], -a[x[turn]]);
            a[x[turn]] = y[turn];
            acount.add(trans1[a[x[turn]]], 1);
            asum.add(trans1[a[x[turn]]], a[x[turn]]);

            ans += a[x[turn]] * bcount.sum(0, trans1[a[x[turn]]]);
            ans += bsum.sum(trans1[a[x[turn]]]+1, trans1.size());
        }else{
            ans -= b[x[turn]] * acount.sum(0, trans1[b[x[turn]]]);
            ans -= asum.sum(trans1[b[x[turn]]]+1, trans1.size());

            bcount.add(trans1[b[x[turn]]], -1);
            bsum.add(trans1[b[x[turn]]], -b[x[turn]]);
            b[x[turn]] = y[turn];
            bcount.add(trans1[b[x[turn]]], 1);
            bsum.add(trans1[b[x[turn]]], b[x[turn]]);

            ans += b[x[turn]] * acount.sum(0, trans1[b[x[turn]]]);
            ans += asum.sum(trans1[b[x[turn]]]+1, trans1.size());
        }
        cout << ans << endl;
    }
    return 0;
}

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

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M,Q;
int T[202020],X[202020],Y[202020];
vector<int> V;
int A[202020],B[202020];

template<class V, int ME> class BIT {
public:
	V bit[1<<ME],val[1<<ME];
	V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { val[e++]+=v; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
	void set(int e,V v) { add(e,v-val[e]);}
	int lower_bound(V val) {
		V tv=0; int i,ent=0;
		for(i=ME-1;i>=0;i--) if(tv+bit[ent+(1<<i)-1]<val) tv+=bit[ent+(1<<i)-1],ent+=(1<<i);
		return ent;
	}
};
BIT<ll,20> Anum,Asum,Bnum,Bsum;

void solve() {
	int i,j,k,l,r,x,y; string s;

	V.push_back(0);
	cin>>N>>M>>Q;
	FOR(i,Q) {
		cin>>T[i]>>X[i]>>Y[i];
		X[i]--;
		V.push_back(Y[i]);
	}
	sort(ALL(V));
	V.erase(unique(ALL(V)),V.end());
	Anum.add(0,N);
	Bnum.add(0,M);
	ll sum=0;
	FOR(i,Q) {
		Y[i]=lower_bound(ALL(V),Y[i])-V.begin();
		if(T[i]==1) {
			//del
			x=A[X[i]];
			sum-=Bnum(x)*V[x];
			sum+=Bsum(x);
			Anum.add(x,-1);
			Asum.add(x,-V[x]);
			//add
			x=A[X[i]]=Y[i];
			sum+=Bnum(x)*V[x];
			sum-=Bsum(x);
			Anum.add(x,1);
			Asum.add(x,V[x]);
		}
		else {
			//del
			x=B[X[i]];
			sum-=Anum(x)*V[x];
			sum+=Asum(x);
			Bnum.add(x,-1);
			Bsum.add(x,-V[x]);
			//add
			x=B[X[i]]=Y[i];
			sum+=Anum(x)*V[x];
			sum-=Asum(x);
			Bnum.add(x,1);
			Bsum.add(x,V[x]);
		}
		cout<<sum<<endl;
	}

}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

#include <bits/stdc++.h>

using namespace std;

#define DEBUG
#ifdef DEBUG
inline void debug_print() { cerr << endl; }
template <typename T1, typename... T2> void debug_print(const T1 a, const T2 &... b) { cerr << a << ' '; debug_print(b...); }
#define debug(...) cerr << __LINE__ << ": [" << #__VA_ARGS__ << "] = " , debug_print(__VA_ARGS__);
#else
#define debug(...) true
#endif

inline void print() { cout << '\n'; }
template <typename T1, typename... T2> void print(const T1 a, const T2 &... b) { cout << a << ' '; print(b...); }

template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto e : v) os << e << ' '; return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) { for (auto e : v) os << e << ' ';  return os; }
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &v) { for (auto e : v) os << e << ' ';  return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp) { for (auto e : mp) os << e << ' '; return os; }

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

const int INF = (1<<30)-1;
const long long LINF = 1LL<<60;
const double EPS = 1e-9;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int dx[8] = {-1,0,1,0,1,-1,1,-1};
const int dy[8] = {0,1,0,-1,1,-1,-1,1};

//-------------------------- Libraries --------------------------//

//--------------------------- Solver ----------------------------//

void solve() {
    int N;
    cin >> N;
    pair<double, double> p0, p2;
    cin >> p0.first >> p0.second;
    cin >> p2.first >> p2.second;

    pair<double, double> o = {(p0.first+p2.first)/2, (p0.second+p2.second)/2};

    p0.first -= o.first;
    p0.second -= o.second;

    double theta = 2*M_PI / N;

    pair<double, double> p1;
    p1.first = p0.first * cos(theta) - p0.second * sin(theta);
    p1.second = p0.first * sin(theta) + p0.second * cos(theta);

    p1.first += o.first;
    p1.second += o.second;

    print(p1.first, p1.second);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

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

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

typedef vector<vector<ll>> mat;

void print(mat A){
	rep(i, A.size()){
		rep(j, A[i].size()){
			cout << A[i][j] << (j == A[i].size()-1 ? "\n" : " ");
		}
	}
}

mat mmul(mat A, mat B){
	int n = A.size();
	int l = A[0].size();
	int m = B[0].size();
	mat C(n, vector<ll>(m, 0));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			for(int k = 0; k < l; k++){
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}

	return C;
}

mat mE(int n){
	mat A(n, vector<ll>(n, 0));
	for(int i = 0; i < n; i++){
		A[i][i] = 1LL;
	}

	return A;
}

mat mpow(mat A, ll x){
	int n = A.size();
	if(x == 0) return mE(n);
	if(x % 2 == 1) return mmul(A, mpow(A, x - 1));

	mat B = mpow(A, x / 2);
	return mmul(B, B);
}

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

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

	ll n;
	cin >> n;

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

	mat A1 = vector<vector<ll>>(3, vector<ll>(3, 0));
	A1[0][1] = 1;
	A1[1][0] = -1;
	A1[2][2] = 1;

	mat A2 = vector<vector<ll>>(3, vector<ll>(3, 0));
	A2[0][1] = -1;
	A2[1][0] = 1;
	A2[2][2] = 1;

	mat A3 = mE(3);
	A3[0][0] = -1;

	mat A4 = mE(3);
	A4[1][1] = -1;

	vector<mat> A;
	A.push_back(mE(3));

	ll m;
	cin >> m;

	rep(i, m){
		int t;
		cin >> t;

		if(t == 1){
			A.push_back(mmul(A1, A[i]));
		}else if(t == 2){
			A.push_back(mmul(A2, A[i]));
		}else if(t == 3){
			int p;
			cin >> p;

			A3[0][2] = 2 * p;
			A.push_back(mmul(A3, A[i]));
		}else{
			int p;
			cin >> p;

			A4[1][2] = 2 * p;
			A.push_back(mmul(A4, A[i]));
		}
	}

	mat t = {{0}, {0}, {1}};
	int q;
	cin >> q;

	vector<ll> a(q), b(q);
	rep(i, q){
		cin >> a[i] >> b[i];
		b[i]--;
	}

	rep(i, q){
		t[0][0] = x[b[i]];
		t[1][0] = y[b[i]];
		mat B = mmul(A[a[i]], t);

		cout << B[0][0] << " " << B[1][0] << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int, int> P;
ll gcd(ll a, ll b){return b? gcd(b, a % b): a;}
ll quickpow(ll a, ll b){ll res = 1; while(b){if (b & 1) res = res * a; a = a * a; b >>= 1;} return res;}
// head

const int N = 2e5 + 5;
int a[N], b[N], n, num, ans, tmp[N];

map<pair<int, int>, int> mp;
map<int, int> cnt;

void merge(int l, int r) {
	int mid = (l + r) >> 1, i = l, j = mid + 1, now = l;
	while (i <= mid && j <= r) {
		if (a[i] < a[j]) tmp[now++] = a[i++];
		else {
			ans += mid - i + 1;
			tmp[now++] = a[j++];
		}
	}
	while (i <= mid) tmp[now++] = a[i++];
	while (j <= r) tmp[now++] = a[j++];
	for (int i = l; i <= r; i++) a[i] = tmp[i];
}

void merge_sort(int l, int r) {
	if (l == r) return;
	int mid = (l + r) >> 1;
	merge_sort(l, mid);
	merge_sort(mid + 1, r);
	merge(l, r);
}

signed main(void){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += i;
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
		b[i] += i;
	}
	for (int i = 1; i <= n; i++) {
		mp[make_pair(++cnt[b[i]], b[i])] = ++num;
	}
	cnt.clear();
	for (int i = 1; i <= n; i++) {
		pair<int, int> now = make_pair(++cnt[a[i]], a[i]);
		if (!mp.count(now)) {
			cout << -1 << endl;
			return 0;
		}
		a[i] = mp[now];
		//cout<<a[i]<<" ";
	}//cout<<endl;
	merge_sort(1, n);
	cout << ans << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(i=(a);i<=(b);++i)
#define per(i,a,b) for(i=(a);i>=(b);--i)
#define REP(i,a,b) for(i=(a);i< (b);++i)
#define PER(i,a,b) for(i=(a);i> (b);--i)
#define ERR(...) fprintf(stderr,__VA_ARGS__)
template<class T>inline void cmn(T &x,const T &a){if(a<x)x=a;}
template<class T>inline void cmx(T &x,const T &a){if(x<a)x=a;}
template<class T>inline bool bmn(T &x,const T &a){if(a<x){x=a;return true;}else return false;}
template<class T>inline bool bmx(T &x,const T &a){if(x<a){x=a;return true;}else return false;}
const ll p=998244353ll,pp=p*p;const int ps2=p-2ll;
inline void add(ll &x){if(x>= p)x-=p ;}
inline void sub(ll &x){if(x<0ll)x+=p ;}
inline void adp(ll &x){if(x>=pp)x-=pp;}
inline void sup(ll &x){if(x<0ll)x+=pp;}
inline ll expo(ll a,int b=ps2,ll m=p){
	ll s=1ll;
	while(b){
		if(b&1)s=s*a%p;
		b>>=1; a=a*a%p;
	}
	return s;
}

inline void ac();
//inline void in();int main(){in();int t;scanf("%d",&t);while(t--)ac();return 0;}
//int main(){int t;scanf("%d",&t);while(t--)ac();return 0;}
int main(){ac();return 0;}

const int MAXN=200005;
map<int,int>AM,BM;
map<pair<int,int>,int>M;
ll Ans;
int Tmp,S[MAXN];
inline void inc(const int &x){
	if(!x){puts("-1");exit(0);}
	Tmp=0;
	int i;
	for(i=x;i     ;i-=i&-i)Tmp+=S[i];
	for(i=x;i<MAXN;i+=i&-i)   ++S[i];
	Ans+=Tmp;
}
inline void ac(){
	int n,i,a,s=0;
	scanf("%d",&n);
	per(i,n,1){scanf("%d",&a);a-=i;    M[make_pair(a,++AM[a])]=i;}
	per(i,n,1){scanf("%d",&a);a-=i;inc(M[make_pair(a,++BM[a])]) ;}
	printf("%lld\n",Ans);
}
/*
0. int overflow, array bounds
1. special cases (n=1? n=0?)
2. do smth instead of nothing and stay organized
3. WRITE STUFF DOWN
4. DON'T GET STUCK ON ONE APPROACH
5. STAY CALM AND DON'T GET EXPLODED
*/


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

int main()
{
    io;
    int a, b;
    cin >> a >> b;
    double res = 100*((double)a-b)/a;
    cout << setprecision(5) << res << endl;
    return 0;
}

#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <string>
#include <fstream>
#include <ios>
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdlib>
#include <cstddef>
#include <cstdarg>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <cwchar>
#include <cwctype>
using namespace std;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
using ll = long long;
using ull = unsigned long long;

#define ALL(c) (c).begin(), (c).end()
#define CLEAR(v) memset(v,0,sizeof(v))
#define MP(a,b) make_pair((a),(b))
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ABS(a) ((a)>0?(a):-(a))
template<class T> T MIN(const T& a, const T& b) { return a < b ? a : b; }
template<class T> T MAX(const T& a, const T& b) { return a > b ? a : b; }
template<class T> void MIN_UPDATE(T& a, const T& b) { if (a > b) a = b; }
template<class T> void MAX_UPDATE(T& a, const T& b) { if (a < b) a = b; }

constexpr int mo = 1000000007;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	std::ios::sync_with_stdio(false);
	int N;
	ll K;
	cin >> N >> K;
	std::multiset<std::pair<ll, ll> > AtoBs;
	REP(n, N) {
		ll A, B;
		cin >> A >> B;
		AtoBs.emplace(A, B);
	}

	ll current = K;
	while (!AtoBs.empty() && AtoBs.begin()->first <= current) {
		current += AtoBs.begin()->second;
		AtoBs.erase(AtoBs.begin());
	}
	cout << current << endl;
}


#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back
#define endl '\n'

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int k;
	cin>>k;
	int ans=0;
	for(int i=1; i<=k; i++){
		for(int j=1; j*i<=k; j++){
			ans+=(k/(i*j));
		}
	}
	cout<<ans;
	return 0;
}

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

#define int long long int
typedef pair<int, int> pii;
#define f(i,a,b) for(int i=a;i<b;i++)
#define fo(i,a,b) for(int i = a; i<=b;i+=1)
#define rf(i,a,b)  for(int i=a;i>=b;i--)
#define vll vector<int>
#define sz(a) int(a.size())
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define debug(x) cout << '>' << #x << ':' << x << " ";
#define nl '\n'
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \

void solve(){
    int k;
    cin >> k;
    int ans = 0;
    fo(i, 1, k){
        if(i*i*i <= k){
            ans++;
        }
        else {
            break;
        }
    }
    fo(i, 1, k){
        if(i*i > k)break;
        fo(j, i+1, k){
            if(i*i*j <= k){
                ans+=3;
            }
            else {
                break;
            }
        }
    }

    fo(i, 1, k){
        fo(j, i+1, k){
            if(i*j*j <= k){
                ans+=3;
            }
            else {
                break;
            }
        }
    }
    fo(i, 1, k){
        f(j, i+1, k){
            if(i*j > k)break;
            fo(x, j+1, k){
                if(i*j*x <= k){
                    ans += 6;
                }
                else break;
            }
        }
    }

    cout << ans << nl;
    return ;
}
main()
{
    IO;
    int T = 1;
    // cin >> T;
    for(int c=1; c <= T; c++){
        solve();
        // cout<<"Case #"<<c<<": ";
    }
    return 0;
}


#include <iostream>
#include <iomanip>
#include <limits>
#include <cmath>
#include <vector>
typedef long long ll;

using namespace std;
int main() {
	int n;
	cin >> n;
	ll x;
	cin >> x;
	vector<ll> v;
	for(int i = 0;i < n;i++){
		ll a;
		cin >> a;
		if(a == x){
			continue;
		}
		else{
			v.push_back(a);
		}
	}
	for(int i = 0;i < v.size();i++){
		cout << v[i] << " ";
	}
	cout << endl;
	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <sstream>
#define INF 100000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;

int main() {

    int n, x;
    vector<int> ans;
    cin >> n >> x;
    rep(i,n){
        int a;
        cin >> a;
        if(a != x) ans.push_back(a);
    }
    rep(i,ans.size()) cout << ans[i] << " ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(), c.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, a, b) for (int i = a; i <= b; ++i)
#define rep3(i, a, b) for (int i = a; i >= b; --i)
#define endl '\n'
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
const string YESNO[2] = {"NO", "YES"};
const string YesNo[2] = {"No", "Yes"};
const string yesno[2] = {"no", "yes"};
void YES(bool t = 1) { cout << YESNO[t] << endl; }
void Yes(bool t = 1) { cout << YesNo[t] << endl; }
void yes(bool t = 1) { cout << yesno[t] << endl; }

template <class T, class S>
inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); }
template <class T, class S>
inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); }
#define INT(...)     \
    int __VA_ARGS__; \
    IN(__VA_ARGS__)
#define LL(...)     \
    ll __VA_ARGS__; \
    IN(__VA_ARGS__)
#define VEC(type, name, size) \
    vector<type> name(size);  \
    IN(name)
#define DBL(...)    \
    ld __VA_ARGS__; \
    IN(__VA_ARGS__)
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define VV(type, name, h, w)                       \
    vector<vector<type>> name(h, vector<type>(w)); \
    IN(name)
int scan() { return getchar(); }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
template <class T, class S>
void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T>
void scan(vector<T> &);
template <class T>
void scan(vector<T> &a) {
    for (auto &i : a)
        scan(i);
}
template <class T>
void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail>
void IN(Head &head, Tail &...tail) {
    scan(head);
    IN(tail...);
}
template <class T>
vector<T> divisor(T x) {
    vector<T> ans;
    for (T i = 1; i * i <= x; i++)
        if (x % i == 0) {
            ans.pb(i);
            if (i * i != x)
                ans.pb(x / i);
        }
    return ans;
}
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
typedef int64_t ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
constexpr int inf = 1e9;
// constexpr i64 inf = 1e18;
// const int N = 500 * 1000 + 5; // use for N <= 5 * 10^5
// const int MX = 1e9 + 7; // For convenience, find the answer modulo 10^9+7
// cout << rng();
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    INT(n, m);
    vector<vector<pair<int, int>>> g(n);
    rep(i, m) {
        INT(a, b, c);
        --a, --b;
        g[a].emplace_back(b, c);
    }
    auto dijkstra = [&](int u) {
        vi d(n, inf);
        priority_queue<pair<int, int>> pq;
        // variation.
        for (auto [v, w] : g[u]) {
            if (w < d[v]) {
                d[v] = w;
                pq.emplace(-d[v], v);
            }
        } // push과정에서 시작노드만이아니라 시작노드에서 모든방향 넣기.
        // pq.push({s,0});
        // d[s] = 0; /
        while (!pq.empty()) {
            auto [dist, c] = pq.top();
            dist = -dist;
            pq.pop();
            if (dist > d[c])
                continue;
            if (c == u)
                return dist;
            for (auto [v, w] : g[c]) {
                if (w + d[c] < d[v]) {
                    d[v] = w + d[c];
                    pq.emplace(-d[v], v);
                }
            }
        }
        return -1;
    };
    rep(i, n) {
        cout << (dijkstra(i)) << endl;
    }
    return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
const int N = 200001;
// #define float long double

// int fexp(int a, int b,int m){int ans = 1;while(b){if(b&1)ans=(ans*a)%m; b/=2;a=(a*a)%m;}return ans;}
// int inverse(int a, int p){return fexp(a, p-2,p);}

// int fac[2000001];

// int nCrModPFermat(int n, int r,int p) {
//     // cout<<1<<endl;
//     if (r==0) return 1;
//     return (((fac[n]*((((inverse(fac[r],p)%p)*inverse(fac[n-r],p))%p))))%p);
// }

// vi prime(555,1);

vector<vector<int>> way(200005);
vi parent(200005);
vi val(200005);

void dfs(int cur,int par){
    parent[cur]=par;
    for(auto to:way[cur]){
        if(to!=par)dfs(to,cur);
    }
}
void dfs1(int cur,int par){
    for(auto to:way[cur]){
        if(to!=par){
            val[to]+=val[cur];
            dfs1(to,cur);
        }
    }
}

void solve(){
    int n;cin>>n;
    vi a(n+1);vi b(n+1);
    rep(i,1,n){
        cin>>a[i]>>b[i];
        way[a[i]].pb(b[i]);
        way[b[i]].pb(a[i]);
    }
    dfs(1,1);
    int q;cin>>q;
    rep(i,0,q){
        int t,e,x;cin>>t>>e>>x;
        if(t==1){
            if(b[e]==parent[a[e]])val[a[e]]+=x;
            else{
                val[b[e]]-=x;
                val[1]+=x;
            }
        }
        else{
            if(a[e]==parent[b[e]])val[b[e]]+=x;
            else{
                val[a[e]]-=x;
                val[1]+=x;
            }
        }
    }
    dfs1(1,1);
    rep(i,1,n+1)cout<<val[i]<<" ";
}

signed main(){
        IOS;

        int t=1;
        // cin>>t;
        // for(int i=2; i*i<=550; i++)
        // if(prime[i])
        //     for(int j=i*i; j<=550; j+=i)
        //         prime[j]=0;
        // fac[0] = 1;
        // for (int i=1 ; i<=100001; i++) fac[i] = fac[i-1]*i%mod;
        rep(i,0,t){
            // cout<<"Case #"<<i+1<<": ";
            solve();
            cout<<"\n";
        }
    //    return 0;
}


#include <bits/stdc++.h>
#define forn(i,s,t) for(register int i=(s);i<=(t);++i)
using namespace std;
const int N = 1e3 + 3;
int H, W;
char mp[N][N];
int fa[N<<1];
inline void init() {forn(i,1,H + W) fa[i] = i;}
int Fnd(int u) {return fa[u] == u ? u : fa[u] = Fnd(fa[u]);}
void Mrg(int u, int v) {fa[Fnd(u)] = Fnd(v);}
set<int> s1, s2;
int main() {
	scanf("%d%d", &H, &W); init();
	forn(i,1,H) scanf("%s", mp[i] + 1);
	fa[H] = fa[H + 1] = fa[H + W] = fa[1];
	forn(i,1,H) forn(j,1,W) if(mp[i][j] == '#')
		Mrg(i, H + j);
	int res1 = 0, res2 = 0;
	forn(i,1,H) s1.insert(Fnd(i));
	forn(i,1,W) s2.insert(Fnd(i + H));
	printf("%d\n", min(s1.size(), s2.size()) - 1);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
template <class T1, class T2>
bool chmax(T1 &a, const T2 b) { return a < b ? a = b, true : false; }
template <class T1, class T2>
bool chmin(T1 &a, const T2 b) { return a > b ? a = b, true : false; }
template <class T>
istream &operator>>(istream &is, vector<T> &v) { for (T &i : v) is >> i; return is; }
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &i : v) os << i << ' '; return os; }
void _co() { cout << '\n'; }
template <class Head, class... Tail>
void _co(Head&& head, Tail&&... tail) { cout << ' ' << head; _co(forward<Tail>(tail)...); }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) { cout << head; _co(forward<Tail>(tail)...); }
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) { cerr << head << ' '; ce(forward<Tail>(tail)...); }
void sonic() { ios::sync_with_stdio(false); cin.tie(nullptr); }
void setp(const int n) { cout << fixed << setprecision(n); }
constexpr int64_t INF = 1000000000000000001;
constexpr int64_t MOD = 1000000007;
constexpr int64_t MOD_N = 998244353;
constexpr long double EPS = 1e-11;
const double PI = acos(-1);

struct union_find {
    vector<int64_t> par;
    vector<int64_t> sz;

    union_find(int64_t _n) : par(_n), sz(_n, 1) {
        for (int64_t i = 0; i < _n; ++i) par[i] = i;
    }

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

    void unite(int64_t x, int64_t y) {
        x = root(x), y = root(y);
        if (x != y) {
            if (sz[x] < sz[y]) swap(x, y);
            par[y] = x;
            sz[x] += sz[y];
        }
    }

    int64_t size(int64_t x) { return sz[root(x)]; }

    bool is_same(int64_t x, int64_t y) { return root(x) == root(y); }
};

int main(void) {
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (auto &i : s) cin >> i;
    union_find uf(h + w);

    uf.unite(0, h - 1);
    uf.unite(h, h + w - 1);
    uf.unite(0, h);
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#')
                uf.unite(i, h + j);
        }
    }

    union_find x = uf, y = uf;

    ll a = 0, b = 0;
    rep(i, h - 1) {
        if (!x.is_same(i, h - 1)) {
            ++a;
            x.unite(i, h - 1);
        }
    }
    REP(i, h, h + w - 1) {
        if (!y.is_same(i, h + w - 1)) {
            ++b;
            y.unite(i, h + w - 1);
        }
    }
    co(min(a, b));

    return 0;
}


#define _USE_MATH_DEFINES
#include <iostream>                         // cout, endl, cin
#include <cstdio>                           // printf, scanf
#include <string>                           // string, to_string, stoi
#include <algorithm>                        // min, max, swap, lower_bound, upper_bound
// & stable_sort, sort, reverse
#include <cmath>                            //sin(rad),cos,tan, abs, pow, sqrt, cbrt,  exp, log, log10, log2
#include <utility>                          // pair, make_pair
#include <map>                              // map
#include <set>                              // set
#include <vector>                           // vector
#include <queue>                            // queue, priority_queue
#include <stack>                            // stack
#include <list>                             // list
#include <deque>                            // deque
#include <iomanip>
#include <numeric>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef set<int> si;
typedef map<string, int> msi;
typedef map<string, bool> msb;
typedef priority_queue<int> pqi;
typedef stack<int> sti;
typedef queue<int> qi;

#define infi 1147483647
#define infl 9223372036854775806
#define MOD  1000000007
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repa(i,n) for(int i=1;i<=(int)n;i++)
#define irep(i,n) for(int i=(int)n-1;i>=0;i--)

using std::cin;
using std::string;

template <typename T>
T in() {
	T temp; cin >> temp; return temp;
}

template <>
int in() {
	int temp; (void)scanf("%d", &temp); return temp;
}
template <>
double in() {
	double temp; (void)scanf("%lf", &temp); return temp;
}
template <>
char in() {
	char temp; (void)scanf("%c", &temp); return temp;
}

template<typename T1, typename T2>
constexpr auto equals(T1 a, T2 b) { return (fabs(a - b) < EPS); }

//その他便利なメソッド
void clear(std::queue<int>& q)
{
	std::queue<int> empty;
	std::swap(q, empty);
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first > b.first;
	}
}

//---------------------------------------------------
vector<pii> a, b;
int n;

int main() {
	//int a = in<int>(); string b = in<string>(); char c = in<char>();
	//double d = in<double>();
	//(void)scanf("%d",&);
	//(void)scanf("%d%d",& ,&);
	cin >> n;
	int x, y;
	int mini = infi;
	repa(i, n) {
		(void)scanf("%d%d", &x, &y);
		if (x + y <= mini) mini = x + y;
		a.push_back(make_pair(x, i));
		b.push_back(make_pair(y, i));
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	int mini2 = max(a[0].first,b[0].first);
	if (a[0].second == b[0].second) {
		mini2 = max(mini2,min(a[1].first,b[1].first));
	}
	cout << min(mini, mini2) << endl;

	return 0;
}

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

int s(string t){
  int val = 0;
  for(auto& c : t){
    val += c - '0';
  }
  return val;
}
int main(){
    string A,B;
    cin >>A>>B;
    int ans;
    ans = max(s(A),s(B));
    cout << ans << "\n";
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<math.h>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rrep(i,l,r) for(int i=l;i<=r;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define unq(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define mod 1000000007
//#define mod 998244353
#define ad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
void readv(vector<ll> &a,ll n){
	rep(i,n){
		ll x;
		cin>>x;
		a.push_back(x);
	}
}
void outv(vector<ll> &a,ll n){
	rep(i,n){
		if(i>0)cout<<" ";
		cout<<a[i];
	}
	cout<<"\n";
}
ll po(ll x,ll y){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
ll gcd(ll a,ll b){
	return (b?gcd(b,a%b):a);
}
#define FACMAX 200010
ll fac[FACMAX],inv[FACMAX],ivf[FACMAX];
void initfac(){
	fac[0]=ivf[0]=inv[1]=1;
	for(ll i=1;i<FACMAX;i++)fac[i]=fac[i-1]*i%mod;
	for(ll i=1;i<FACMAX;i++){
		if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
		ivf[i]=po(fac[i],mod-2);
	}
}
ll P(ll n,ll k){
	if(n<0||n<k)return 0;
	return fac[n]*ivf[n-k]%mod;
}
ll C(ll n,ll k){
	if(k<0||n<k)return 0;
	return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
ll H(ll n,ll k){
	return C(n+k-1,k);
}

#define X 400010
vector<ll> g[X];
bool vis[X];
pll dfs(ll x){
	if(vis[x])return mp(0,0);
	vis[x]=1;
	pll res=mp(1,g[x].size());
	for(auto y:g[x]){
		pll cur=dfs(y);
		res.first+=cur.first;
		res.second+=cur.second;
	}
	return res;

}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	ll n;
	cin>>n;
	rep(i,n){
		ll a,b;
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	rep(i,X)vis[i]=0;
	ll ans=X;
	rep(i,X){
		if(vis[i])continue;
		pll res=dfs(i);
		if(res.first>res.second/2)ans--;
	}
	cout<<ans<<endl;
}

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

//-------------------------------------------------

constexpr int INF = 1e9;
constexpr int N_MAX = 1000;
struct Edge {int to, c;};
vector<Edge> G[N_MAX];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin>>N>>M;
    rep(i,M){
        int a,b; char c; cin>>a>>b>>c;
        a--; b--; c-='a';
        G[a].pb({b,c});
        G[b].pb({a,c});
    }
    using P = pi;
    queue<P> que;
    que.emplace(0,N-1);
    vector<vi> dist(N,vi(N,INF));
    dist[0][N-1] = 0;
    while(!que.empty()){
        int u,v;
        tie(u,v) = que.front(); que.pop();
        for(auto e:G[u]){
            for(auto f:G[v]){
                if (e.c==f.c && dist[e.to][f.to]>dist[u][v]+1){
                    dist[e.to][f.to]=dist[u][v]+1;
                    que.emplace(e.to,f.to);
                }
            }
        }
    }
    int ans = INF;
    rep(v,N){
        chmin(ans,dist[v][v]*2);
        for(auto e:G[v]){
            chmin(ans,dist[v][e.to]*2+1);
        }
    }
    cout<<(ans==INF?-1:ans)<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
using namespace std;
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; }
typedef long long ll;
const int INF = INT32_MAX;
using P = pair<int, int>;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if(a + b == 2 * c){
        cout << "Yes" << endl;
        return 0;
    }
    if(a + c == 2 * b){
        cout << "Yes" << endl;
        return 0;
    }
    if(c + b == 2 * a){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}

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

int main() {

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

    if(a > b) swap(a,b);
    if(a>c) swap(a,c);
    if(b>c) swap(b,c);

    if(b-a == c-b) cout << "Yes";
    else cout << "No";

    return 0;
}


/*
  In the name of ALLAH
  Author : Raashid Anwar
*/

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

#define int int64_t
const int M1 =  998244353;
const int M2 =  1000000007;
mt19937 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());

void solve() {
  int n, m;
  cin >> n >> m;
  vector <int> mask(n), dp(1 << n, n);
  while (m--) {
    int u, v;
    cin >> u >> v;
    mask[u - 1] |= 1 << (v - 1);
    mask[v - 1] |= 1 << (u - 1);
  }
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int nmask = 0; nmask < (1 << n); nmask++) {
      if (dp[nmask] == 1 && (mask[i] & nmask) == nmask) {
        dp[nmask | (1 << i)] = 1;
      }
    }
  }
  for (int nmask = 1; nmask < (1 << n); nmask++) {
    for (int j = nmask; j; j = (j - 1) & nmask) {
      dp[nmask] = min(dp[nmask], dp[nmask ^ j] + dp[j]);
    }
  }
  cout << dp[(1 << n) - 1] << "\n";
}

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

#include<bits/stdc++.h>

using namespace std;

using ll = long long;

/*-----for personal-----*/
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n)  rep(i,0,n)

/*-----for lib-----*/
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) std::begin(x), std::end(x)

const double EPS = 1e-5;
const int MOD = 1e9+7;
const int INF = INT_MAX / 2;
const ll LLINF = LLONG_MAX / 2;
//for(auto &h : H){ cout << h << " ";} cout << endl;
//for(auto &h : H){for(auto &k:h){cout << k << " ";}cout << endl;}
//for(auto [k,v] : mp){cout << k << " " << v << endl;}
//for(auto [k,v] : mp){cout << k << " "; for(auto &u:v){cout << u << " ";}cout << endl;}

/*
dp[bit] : the minimal number of clique in the subset bit
dp[bit] = max_{subbit \in bit}(dp[sub_bit] + dp[bit&~sub_bit])
O(2^N(subbit \in bit) * 2^N (cases of bit)) = O(4^N) = 68719476736 -> O(3^N)
dp[(1<<N)-1] : answer
dp[0] = 0 : initial
*/

const int N = 18;
vector<ll> dp((1<<N)+1, -1);
vector<vector<bool>> am(N, vector<bool>(N,false));
vector<bool> ok((1<<N)+1, true);
vector<bool> visited((1<<N)+1, false);

ll f(ll bit){
  visited[bit] = true;
  if(dp[bit]!=-1) return dp[bit];
  if(bit==0) return dp[bit] = 0;
  if(ok[bit]) return dp[bit] = 1;
  //cout << (bitset<N>)bit << endl;

  ll min = LLINF;
  for(ll s_bit = bit; ; --s_bit&=bit){
    //cout << bit << " " << s_bit << endl;
    //if(visited[s_bit]) cout << "visited" << endl;
    if(s_bit==bit) continue;
    if(s_bit==0) break;
    ll res = f(s_bit) + f(bit & ~s_bit);
    if(res < min) min = res;
  }
  return dp[bit] = min;
}

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

  repn(i,m){
    int a, b; cin >> a >> b; a--; b--;
    am[a][b] = true;
    am[b][a] = true;
  }

  for(ll bit=0; bit<(1<<n); bit++){
    vector<int> vs;
    for(int i=0; i<n; i++){
      if(bit & (1 << i)) vs.emplace_back(i);
    }

    for(int i=0;i<vs.size()&&ok[bit];i++){
      for(int j=i+1;j<vs.size()&&ok[bit];j++){
        if(!am[vs[i]][vs[j]]) ok[bit] = false; //O(N^2)
      }
    }
  }

  ll res = f((1<<n)-1);
  cout << res << endl;

}


// author: xay5421
// created: Sat May 29 20:25:20 2021
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
//#define NDEBUG
#endif
#include<bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
const int N=505;
int T,n,a[N];
bool ok(){
	rep(i,1,n)if(a[i]!=i)return 0;
	return 1;
}
int main(){
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif
	scanf("%d",&T);
	rep(_,1,T){
		D("_=%d\n",_);
		scanf("%d",&n);
		rep(i,1,n)scanf("%d",&a[i]);
		vector<int>ans;
		while(1){
			if(ok())break;
			bool flg=0;
			for(int i=(n-1)&1?n-1:n-2;i>=1;i-=2){
				if(a[i]>a[i+1]){
					swap(a[i],a[i+1]),ans.push_back(i);
					flg=1;
					break;
				}
			}
			if(flg==0){
				swap(a[1],a[2]),ans.push_back(1);
			}
			if(ok())break;
			flg=0;
			for(int i=2;i<n;i+=2){
				if(a[i]>a[i+1]){
					swap(a[i],a[i+1]),ans.push_back(i);
					flg=1;
					break;
				}
			}
			if(flg==0){
				swap(a[2],a[3]),ans.push_back(2);
			}
		}
		printf("%d\n",SZ(ans));
		for(int x:ans)printf("%d ",x);
		puts("");
	}
	return 0;
}

#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

void solve0(int n){
  rep(i,n){
    print(2*i+1,2*i+2);
  }
}

void solve1(int n,int m){
  if(m+2>n){
    print(-1);
    return;
  }
  li p=n-m+1;
  print(2,p);
  rep(i,n-m-2){
    print(p-(i+1),p+(i+1));
  }
  li q=p+((n-m-3)+1)+1;
  rep(i,m-1){
    print(q+2*i,q+2*i+1);
  }
  li r=2*(m-2)+q+1+1;
  print(r,r+2);
  print(1,r+1);
}

void solve2(int n,int m){
  m*=-1;
  if(m+2>n){
    print(-1);
    return;
  }
  print(-1);
}

int main(){
  int n,m; cin >>n >>m;
  if(m==0) solve0(n);
  if(m>0) solve1(n,m);
  if(m<0) solve2(n,m);
}


#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
  lll ii,jj,kk;
  vector<int> ret;

  string s,t;
  char ans;
  cin >> s >> t;

  if(s == "Y"){
    ans = t[0] + 'A' - 'a';
    cout << ans << endl;
  }
  else{
    cout << t << endl;
  }

  return 0;
}

#include <iostream>
using namespace std;

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

    cout<<n/w;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  int a[n+1],i;
  for(i=0;i<n;i++)
      cin>>a[i];
  long long sum=0;
  for(i=0;i<n;i++)
  {
    if(a[i]>10)
       sum+=a[i]-10;
  }
  cout<<sum<<endl;

}

//This Code was made by Chinese_zjc_.
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <time.h>
// #include<windows.h>
#define int long long
#define double long double
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
std::bitset<100005> can;
int n, a[105], sum, ans = INF;
signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin >> n;
    can[0] = true;
    for (int i = 1; i <= n; ++i)
        std::cin >> a[i], sum += a[i], can |= can << a[i];
    for (int i = 0; i <= sum; ++i)
        if (can[i])
            ans = std::min(ans, std::max(i, sum - i));
    std::cout << ans << std::endl;
    return 0;
}


// A - 106
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	ll n; cin>>n;
	ll na = 1;
	rp(a, 1, 38){
		na *= 3;
		ll nb = 1;
		rp(b, 1, 26){
			nb *= 5;
			if(n == na+nb){
				cout<< a <<" "<< b <<endl;
				return 0;
			}
		}
	}
	puts("-1");
}

#include <bits/stdc++.h>
using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...)
#endif

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N;
inline void input(){
    fast_io();
    cin >> N;
}

inline int solve(){
    if(N%2){
        cout << -1 << endl;
        return 0;
    }
    ll a3 = 3;
    ll a = 1;
    while(a3 < N && a3 < 1e18){
        ll b5 = 5;
        ll b = 1;
        while(b5 < N && b5 < 1e18){
            if(a3 + b5 == N){
                cout << a << " " << b << endl;
                return 0;
            }
            b5 *= 5;
            b++;
        }

        a3 *= 3;
        a++;

    }
    cout << -1 << endl;

    return 0;
}

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


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,m,n) for (int i = (m); i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; --i)
#define RREP(i,m,n) for (int i = (n)-1; i >= (m); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using vecll = vector<ll>;
using P = pair<int,int>;
const int INF = 1e9+7;

void dfs(int a, int b, ll k) {
  ll now = 1;
  rep(i,a+1) {
    if (k - now < 0) {
      rep(j,a-i) {
        cout << 'a';
      }
      cout << 'b';
      if (b > 1) dfs(i, b-1, k);
      else rep(j,i) cout << 'a';
      break;
    }
    k -= now;
    now = now * (b+i) / (i+1);
  }
}

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

  vector<vecll> dp(a+1, vecll(b+1, 1));
  REP(i,1,a+1) {
    REP(j,1,b+1) {
      dp[i][j] = dp[i-1][j] + dp[i][j-1];
    }
  }
  int ii = a, jj = b;
  string s;
  rep(i, a+b) {
    if (ii == 0) {
      jj--;
      cout << 'b';
    } else if (k < dp[ii-1][jj]) {
      ii--;
      cout << 'a';
    } else {
      k -= dp[ii-1][jj];
      jj--;
      cout << 'b';
    }
  }

  cout << s << endl;
}

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <string>
#include <cstdio>
#include <cmath>
#include <climits>
#include <fstream>
#include <functional>
using namespace std;

const long long INF = 1LL << 60;
const long long MOD = 1000000007;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

long long comb(long long n, long long r)
{
    if (n == 1) return 1LL;

    long long ans = 1;
    for (int i = 1; i <= r; ++i)
    {
        ans *= n;
        ans /= i;

        --n;
    }

    return ans;
}

int main(void)
{
    long long a,b,k;
    cin >> a >> b >> k;
    long long s = a + b;

    string ans;
    int count_a = 0;
    int count_b = 0;
    for (int i = 0; i < s; ++i)
    {
        if (i == s-1)
        {
            if (count_a < a)
            {
                ans += 'a';
            }
            else
            {
                ans += 'b';
            }
            break;
        }

        long long c = comb(s-count_a-count_b-1, a-count_a-1);
        // cout << c << endl;
        if (k <= c)
        {
            ans += 'a';
            count_a += 1;
        }
        else
        {

            k -= c;
            ans += 'b';
            count_b += 1;
        }

        if (count_a == a)
        {
            for (int j = 0; j < b - count_b; ++j)
            {
                ans += 'b';
            }
            break;
        }
        if (count_b == b)
        {
            for (int j = 0; j < a - count_a; ++j)
            {
                ans += 'a';
            }
            break;
        }
    }

    cout << ans << endl;
}


#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
// using namespace atcoder;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
const int MAX_N = 300005;

class Tentousuu{
public:
    Tentousuu() = delete;
    Tentousuu(vector<int> a_){
        a = a_; b = a_;
        sort(b.begin(), b.end());
        n = a.size();
        nn = 10;
        while(nn <= n + 3) nn *= 2;
        G.resize(nn);
        now.resize(nn);
        bit.resize(nn);
    }
    Tentousuu(vector<int> a_, vector<int> b_){
        a = a_; b = b_;
        n = a.size();
        nn = 10;
        while(nn <= n + 3) nn *= 2;
        G.resize(nn);
        now.resize(nn);
        bit.resize(nn);
    }

    ll Calc(){
        vector<int> c(n*2);
        rep(i,n){
            c[i] = a[i];
            c[i+n] = b[i];
        }

        vector<int> z = zaatsu(c);
        rep(i,n){
            a[i] = z[i];
            b[i] = z[i+n];
        }
        rep(i,n){
            G[a[i]].push_back(i+1);
        }

        ll ans = 0;

        rep(i,n){
            int x = b[i];
            int ite = G[x][now[x]];
            now[x]++;
            int real = ite + sums(ite);
            ans += real - (i+1);
            adds(1,1);
            adds(ite,-1);
        }

        return ans;
    }

private:
    int n;
    vector<int> a, b, c;
    vector<vector<int>> G;
    vector<int> now;
    vector<ll> bit;
    int nn;

    // 座標圧縮 a[n] -> z[n](zは1-index)
    vector<int> zaatsu(vector<int> a){
        int n = a.size();
        vector<int> b, pre_b, z;
        rep(i,n)pre_b.push_back(a[i]);
        sort(pre_b.begin(), pre_b.end());
        rep(i,n){
            if(i == 0){
                b.push_back(pre_b[i]);
            }else{
                if(pre_b[i] != pre_b[i-1]){
                    b.push_back(pre_b[i]);
                }
            }
        }
        rep(i,n){
            int tmp_z = lower_bound(b.begin(), b.end(), a[i]) - b.begin() + 1;
            z.push_back(tmp_z);
        }

        return z;
    }

    void adds(int a, ll w){
        for(int x = a; x <= nn; x += x & -x) bit[x] += w;
    }
    ll sums(int a){ // bit[1,a]の和を返す.
        ll ret = 0;
        for(int x = a; x > 0; x -= x & -x) ret += bit[x];
        return ret;
    }
};

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

    rep(i,n){
        a[i] -= n - 1 - i;
        b[i] -= n - 1 - i;
    }
    int aa[n] = {};
    int bb[n] = {};
    rep(i,n){
        aa[i] = a[i];
        bb[i] = b[i];
    }
    sort(aa,aa+n);
    sort(bb,bb+n);

    rep(i,n){
        if(aa[i] != bb[i]){
            cout << -1 << endl;
            return 0;
        }
    }

    Tentousuu t(a, b);
    ll ans = t.Calc();

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

// My favourite LGM is Jiangly :>)
#pragma GCC optimize("O3","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zeroupper") //Enable AVX
#pragma GCC target("avx","popcnt")  //Enable AVX
#include <x86intrin.h> //SSE Extensions
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define mp make_pair
#define hello cout<<"hello"<<"\n"
#define forr(i,a,b) for(int i=a;i<b;i++)
#define it(s)	for(auto itr:s)
#define dvg(s) 	for(auto itr:s)	cout<<itr<<" ";cout<<endl;
#define dbg(s)	cout<<#s<<"= "<<s<<endl;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF=(lli)1e17+5;
const ulli MOD=1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;cin>>n;vector<int> v(n,0);bitset<(int)1e5+5> vis;vis.reset();vis.set(0);
	int s=0;
	for(int i=0;i<n;i++)
	{
		cin>>v[i];s+=v[i];
		for(int j=(int)1e5+1;j>=v[i];j--)
		{
			if(vis[j-v[i]]) vis.set(j);
		}
	}
	int ans=0;
	int start=0;if(s&1) start=s/2+1;else start=s/2;
	for(int i=start;i<=s;i++)
	{
		if(vis[i])	{ans=i;break;}
	}
	cout<<ans<<"\n";

    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    printf("%.6lf", (((double)(a - b) / (double)a) * 100));
}

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

int main(){
	double a,b;
	cin >> a>> b;
	cout << fixed << setprecision(15) << (a-b)/a*100 << endl;
	return 0;
}

// cout << fixed << setprecision(15) <<  << endl;


#include<bits/stdc++.h>
const int N=4e6+10;
using namespace std;

int n,m,q,op,x;
long long y,aa[N],bb[N],ans;

struct node {
	int ls,rs;
	long long tot,sum;
} A[N],B[N];

int rta=0,cnta=0;
void updateA(int p) {
	A[p].sum=A[A[p].ls].sum+A[A[p].rs].sum;
	A[p].tot=A[A[p].ls].tot+A[A[p].rs].tot;
}
void insertA(int &p,int l,int r,int x,int pos) {
	if(!p) p=++cnta;
	if(l==r) {
		A[p].sum+=pos;
		A[p].tot+=pos*x;
		return;
	}
	int mid=l+r>>1;
	if(x<=mid) insertA(A[p].ls,l,mid,x,pos);
	else insertA(A[p].rs,mid+1,r,x,pos);
	updateA(p);
}
long long queryA1(int p,int l,int r,int pos) {
	if(!p) return 0;
	if(r<=pos) return A[p].sum;
	int mid=l+r>>1;
	if(pos>mid) return A[A[p].ls].sum+queryA1(A[p].rs,mid+1,r,pos);
	else return queryA1(A[p].ls,l,mid,pos);
}
long long queryA2(int p,int l,int r,int pos) {
	if(!p) return 0;
	if(l>pos) return A[p].tot;
	int mid=l+r>>1;
	if(pos<=mid) return A[A[p].rs].tot+queryA2(A[p].ls,l,mid,pos);
	else return queryA2(A[p].rs,mid+1,r,pos);
}

int rtb,cntb;
void updateB(int p) {
	B[p].sum=B[B[p].ls].sum+B[B[p].rs].sum;
	B[p].tot=B[B[p].ls].tot+B[B[p].rs].tot;
}
void insertB(int &p,int l,int r,int x,int pos) {
	if(!p) p=++cntb;
	if(l==r) {
		B[p].sum+=pos;
		B[p].tot+=pos*x;
		return;
	}
	int mid=l+r>>1;
	if(x<=mid) insertB(B[p].ls,l,mid,x,pos);
	else insertB(B[p].rs,mid+1,r,x,pos);
	updateB(p);
}
long long queryB1(int p,int l,int r,int pos) {
	if(!p) return 0;
	if(r<=pos) return B[p].sum;
	int mid=l+r>>1;
	if(pos>mid) return B[B[p].ls].sum+queryB1(B[p].rs,mid+1,r,pos);
	else return queryB1(B[p].ls,l,mid,pos);
}
long long queryB2(int p,int l,int r,int pos) {
	if(!p) return 0;
	if(l>pos) return B[p].tot;
	int mid=l+r>>1;
	if(pos<=mid) return B[B[p].rs].tot+queryB2(B[p].ls,l,mid,pos);
	else return queryB2(B[p].rs,mid+1,r,pos);
}

int main() {
	scanf("%d%d%d",&n,&m,&q);
	insertA(rta,0,1e8,0,n),insertB(rtb,0,1e8,0,m);
	while(q--) {
		scanf("%d%d%lld",&op,&x,&y);
		if(op==1) {
			ans=ans-aa[x]*queryB1(rtb,0,1e8,aa[x])-queryB2(rtb,0,1e8,aa[x]);
			insertA(rta,0,1e8,aa[x],-1);
			insertA(rta,0,1e8,y,1);
			aa[x]=y;
			ans=ans+y*queryB1(rtb,0,1e8,y)+queryB2(rtb,0,1e8,y);
		} else {
			ans=ans-bb[x]*queryA1(rta,0,1e8,bb[x])-queryA2(rta,0,1e8,bb[x]);
			insertB(rtb,0,1e8,bb[x],-1);
			insertB(rtb,0,1e8,y,1);
			bb[x]=y;
			ans=ans+y*queryA1(rta,0,1e8,y)+queryA2(rta,0,1e8,y);
		}
		printf("%lld\n",ans);
	}
	return 0;
}

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

using P = pair<int, int>;
using PP = pair<double, P>;

const double INF = 1000000010.0;
int di[4] = {0, 0, 1, -1};
int dj[4] = {1, -1, 0, 0};

vector<vector<double>> h;
vector<vector<double>> v;
int si,sj,ti,tj,a;
double e;

vector<vector<double>> dist;
vector<vector<P>> pre;

double get_distance(int itr, int i, int j){
  double dis;
  switch (itr) {
		case 0:
      dis = h[i][j];
      break;
		case 1:
      dis = h[i][j-1];
			break;
    case 2:
      dis = v[i][j];
      break;
		case 3:
      dis = v[i-1][j];
			break;
	}
  return dis;
}

void dijkstra() {
    dist = vector<vector<double> >(30, vector<double>(30, INF));
    pre = vector<vector<P> >(30, vector<P>(30, P(-1, -1)));
    dist[si][sj] = 0;
    priority_queue<PP, vector<PP>, greater<PP> > pq;
    pq.push(PP(0, P(si, sj)));

    while (!pq.empty()) {
        PP p = pq.top();
        pq.pop();
        double c = p.first;
        int vi = p.second.first, vj = p.second.second;

        for (int i = 0; i < 4; i++)
         {
            int ni, nj;
            ni = vi + di[i], nj = vj + dj[i];
            if (ni < 0 || nj < 0 || ni >= 30 || nj >= 30) continue;
            double dis = get_distance(i,vi,vj);
            if (dist[ni][nj] <= dis + c) continue;
            dist[ni][nj] = dis + c;
            pre[ni][nj] = P(vi, vj);
            pq.push(PP(dist[ni][nj], P(ni, nj)));
        }
    }
}

string get_path_str(int diff_i, int diff_j){
  string str = "";
  if(diff_i == -1) str = "D";
  if(diff_i == 1) str = "U";
  if(diff_j == -1) str = "R";
  if(diff_j == 1) str = "L";
  return str;
}

string restore() {
    vector<P> path;
    string path_str = "";

    int i = ti, j = tj;
    int pre_i = pre[i][j].first, pre_j = pre[i][j].second;
    for (; pre_i != -1 || pre_j != -1;) {
        int diff_i = pre_i - i;
        int diff_j = pre_j - j;
        path.push_back(P(pre_i, pre_j));
        path_str += get_path_str(diff_i, diff_j);
        i = pre_i, j = pre_j;
        pre_i = pre[i][j].first, pre_j = pre[i][j].second;
    }
    reverse(path.begin(), path.end());
    reverse(path_str.begin(), path_str.end());

    return path_str;
}

void read_hv(){
  for(int i = 0; i < 30; i++) for(int j = 0; j < 29; j++) cin >> h[i][j];
  for(int i = 0; i < 29; i++) for(int j = 0; j < 30; j++) cin >> v[i][j];
}
void read_st(){
  cin >> si >> sj >> ti >> tj;
}
void read_ae(){
  cin >> a >> e;
}
string generate_path(){
  string path = "";
  dijkstra();

  path = restore();
  return path;
}
int compute_path_length(string path){
  return 10;
}

void update_hv(int prev_result, string path){
  int ci = si, cj = sj;
  double ave_dis = (double)prev_result / path.size();
  int ratio = 7;
  for (int i = 0; i < (int)path.size(); i++)
  {
    char c = path[i];
    if(c=='D'){
      v[ci][cj] = (v[ci][cj]*ratio + ave_dis*(10-ratio))/10;
      ci++;
    }
    if(c=='U'){
      v[ci-1][cj] = (v[ci-1][cj]*ratio + ave_dis*(10-ratio))/10;
      ci--;
    }
    if(c=='R'){
      h[ci][cj] = (h[ci][cj]*ratio + ave_dis*(10-ratio))/10;
      cj++;
    }
    if(c=='L'){
      h[ci][cj-1] = (h[ci][cj-1]*ratio + ave_dis*(10-ratio))/10;
      cj--;
    }
  }
}

int main(int argc, char *argv[]){
  double init_dis = 4000.0;

  h.assign(30,vector<double>(30, init_dis));
  v.assign(30,vector<double>(30, init_dis));

  bool is_test = false;

  if(is_test) read_hv();

  for (int i = 0; i < 1000; i++)
  {

    read_st();
    if(is_test) read_ae();

    string path = generate_path();
    cout << path << endl;

    int prev_result;
    if(is_test){
      prev_result = compute_path_length(path);
    }
    else{
      cin >> prev_result;
      update_hv(prev_result, path);
    }
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define all(v) v.begin(), v.end()
#define rep(i, begin, end) for(int i = begin; i < (int)(end); i++)
#define contains(v, x) (find(all(v), x) != v.end())
template<class T> bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
template<class T> T roundup(T a, T b){ return (a + b - 1) / b; }
const vector<int> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
const vector<int> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};
using ll = long long;
const ll INF = 1e9;
const double EPS = 1e-10;
/* #include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using d32 = mp::number<mp::cpp_dec_float<32>>; */
const ll MOD = 1e9 + 7;
/* #include <atcoder/all>
using namespace atcoder;
using mint = modint; */
using P = pair<int, int>;
using Graph = vector<vector<int>>;
struct Edge{ int to; ll cost; Edge(int to, ll cost) : to(to), cost(cost) {} };

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // mint::set_mod(MOD);

    string s;
    cin >> s;

    while(s.back() == '0') s.erase(s.end() - 1);
    string t = s;
    reverse(all(t));
    cout << (s == t ? "Yes" : "No") << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define pb push_back
#define MOD 1000000007
#define sz5 100005
#define sz6 1000005
#define UP upper_bound
#define LB lower_bound
#define F first
#define S second
#define PI pair<int,int>
#define PL pair<ll,ll>
#define VI vector<int>
#define VL vector<ll>

int main() {
    FAST

    ll n;   cin>>n;
    ll b=0, cur=1, ans=n;

    while(cur<=n){
        ll a=n/cur;
        ll c=n%cur;
        ans=min(ans, a+b+c);

        b++;
        cur*=2;
    }

    cout<<ans<<endl;

    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define pb push_back
//#define mp make_pair
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vi vector<ll>
#define cs(ele) cout<<ele<<'\n'
#define pii pair<ll,ll>
#define MAXN   100001
#define all(d) d.begin(),d.end()
const ll mod=1e9 +7;
//const ll mod=998244353;
//ll Mod(ll n){return ((n%mod)+mod)%mod;}
//ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=mod(res*x);x=mod(x*x);y=mod(y>>1);}return mod(res);}

void fast(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

}
ll f[200005];
ll invfact[200005];
ll power(ll x,ll y){
     ll res=1;
     while(y>0){
         if(y&1){
             res=(res*x)%mod;
         }
         x=(x*x)%mod;
         y>>=1;
    }
    return res;
}
void precal(){
    f[0]=1;
    invfact[0]=1;
    for(int i=1;i<200005;i++){
        f[i]=(f[i-1]*i)%mod;
        invfact[i]=power(f[i],mod-2);
    }
}
ll ncr(ll n,ll k){
    if(n<k||n<0||k<0){
        return 0;
    }
    return ((f[n]*invfact[k])%mod*invfact[n-k])%mod;
}

bool prime[10000011];
void primenumbers(ll n)
{

    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

}
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}
int spf[MAXN];

void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        spf[i] = i;

    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j=i*i; j<MAXN; j+=i)

                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
vector<int> getFactorization(int x)
{
    vector<int> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}

int main()
{
  fast();
      ll a,b,m;
      cin>>a>>b>>m;
      m=m*1000;
      ll ma=m/a;
      ll k=m%a;
      ll mi=m/b;
      ll k1=m%b;
      if(ma*(b-a)>=k){
        if(k1>0){mi++;}
        ce(mi);
        cs(ma);
      }
      else{
        cs("UNSATISFIABLE");
      }

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,w;
  cin >> a >> b >> w;
  int m=1e9,M=0;
  for(int n=1;n<=1000000;n++){
    if(a*n<=1000*w && 1000*w<=b*n){
      m=min(m,n);
      M=max(M,n);
    }
  }
  if(M==0)cout << "UNSATISFIABLE";
  else cout << m << ' ' << M;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
using ll = long long ;
#define rep(i,n) for (int i=0; i < (n); ++i)

const ll lim = 1e18 ;

int main() {
    int n,m ;
    cin >> n >> m ;
    if(m==0){
        cout << 1 << endl ;
        return 0 ;
    }
    if(n==m){
        cout << 0 << endl ;
        return 0 ;
    }
    vector<int> a(m) ;
    rep(i,m){
        cin >> a[i] ;
    }
    a.push_back(0) ;
    a.push_back(n+1) ;
    sort(a.begin(),a.end()) ;

    int st = 1e9 ;
    for(int i=0;i<a.size()-1;i++){
        if(a[i+1]-a[i]-1==0) continue ;
        st = min(a[i+1]-a[i]-1,st) ;
    }
    //cout << st << endl ;

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

#include <bits/stdc++.h>
#define loop(n) for(ll i=0;i<n;i++)
#define loopj(n) for(ll j=0;j<n;j++)
#define loopR(i,a,b,c) for(ll i=a;i>=b;i-=c)
#define rng(i,a,b,c) for(ll i = a; i<b;i+=c)
#define loop2(i,a,b) for(long long i = a; i>=b;i--)
#define loop3(j,a,b) for(int j = a; j<b;j++)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define ld long double
#define SET set<ll>
#define pb push_back
#define mp make_pair
#define gc getchar_unlocked
#define in ll n;cin>>n;
#define all(s) s.begin(),s.end()

ll mod=pow(10,9)+7;
using namespace std;
//--------------------------\\
//code once think twice

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

	return gcd(b,a%b);
}

void go()
{
	ll a,b;
	cin>>a>>b;
	if(min(a,b)+3>max(a,b))
	cout<<"Yes";
	else
	cout<<"No";

}

int main()
{

int t;

fast;
//cin>>t;
//
//loop(t)
go();
}


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

using P = pair<int, int>;

//Graph[i][j][k] ==> i 番目のアルファベットが置かれている
//辺のうち、j から出ている k 番目の辺がつなぐ j 以外の頂点

vector<int> Graph[26][1000];

int main()
{
    int N, M;
    cin >> N >> M;
    //作れるどんな回文の大きさよりも大きい数（今回はどんなに長くても N * N * 2 とかだねたぶん）
    int inf = 1 << 30;
    //真ん中に一文字入れたら回文ができるところで使う
    vector<P> edges;
    //辺の情報を入力
    for (int i = 0; i < M; i++)
    {
        int u, v;
        char c;
        cin >> u >> v >> c;
        u--;
        v--;
        int type = c - 'a';
        Graph[type][v].push_back(u);
        Graph[type][u].push_back(v);
        edges.push_back(P(u, v));
        edges.push_back(P(v, u));
    }
    //ここまでで作る回文の最短の長さをいれる配列
    vector<vector<int>> LEN_up_to_here(N, vector<int>(N, inf));
    LEN_up_to_here[0][N - 1] = 0;
    //この queue に次に見ていく始点と終点の組を入れる
    queue<P> que;
    que.push(P(0, N - 1));
    //次に見る始点と終点の組がなくなるまで
    //始点終点両方から幅優先探索をするイメージ
    //（既にみたものは書き換える必要がないね）
    while (!que.empty())
    {
        //queue の先頭を見る
        P now = que.front();
        que.pop();
        auto [start, goal] = now;
        for (int i = 0; i < 26; i++)
        {
            //start と goal からそのアルファベットの辺が生えているときを考える
            if (Graph[i][start].size() == 0 || Graph[i][goal].size() == 0)
            {
                continue;
            }
            for (auto to0 : Graph[i][start])
            {
                for (auto to1 : Graph[i][goal])
                {
                    if (LEN_up_to_here[to0][to1] != inf)
                    {
                        continue;
                    }
                    //回文の長さは 2 づつ増えるよね（両端から作っていくので）
                    LEN_up_to_here[to0][to1] = LEN_up_to_here[start][goal] + 2;
                    que.push(P(to0, to1));
                }
            }
        }
    }
    int ans = inf;
    //回文ができたよ～～うれしいね
    for (int i = 0; i < N; i++)
    {
        ans = min(ans, LEN_up_to_here[i][i]);
    }
    //あと一文字真ん中に入れたら回文になるよ～～
    for (int i = 0; i < 2 * M; i++)
    {
        auto [start, goal] = edges[i];
        ans = min(ans, LEN_up_to_here[start][goal] + 1);
    }
    // ans==inf となっている時は構築できない時と同値だよね～～（作れるときは inf 未満になるようにしたので）
    if (ans != inf)
    {
        cout << ans << endl;
        return 0;
    }
    cout << -1 << endl;
}
//計算量は幅優先探索以外は平気そう
//幅優先探索での計算量は実質的に
//頂点数 N*N, 辺 M*M とみなせるから、
//O(N*N+M*M)になる...タブンネ

//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<cstdio>
#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

int N, M, K;
int to[200001], ne[200001], he[100001];
int D[100001], C[20], Q[100001], q;
int DD[20][20];
int dp[1 << 17][17];

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

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

	N = getint();
	M = getint() * 2;
	rep1(i, M) {
		int a = getint(), b = getint();
		to[i] = b;
		ne[i] = he[a];
		he[a] = i++;
		to[i] = a;
		ne[i] = he[b];
		he[b] = i;
	}
	K = getint();
	rep(i, K) C[i] = getint();

	if (K == 1) {
		printf("1");
		return 0;
	}

	const int dekai = 1e8, choidekai = 5e6;
	for (int p = 1; p < K; p++) D[C[p]] = dekai + p;

	rep(k, K - 1) {

		int b = -choidekai * k;
		D[C[k]] = b - choidekai;

		int mada = 0;
		for (int i = K - 1; i > k; i--) mada |= (1 << i);
		int p = 0;
		q = 0;
		Q[q++] = C[k];
		while (mada && p < q) {
			int i = Q[p++];
			int d = D[i] + 1;
			for (int t = he[i]; t; t = ne[t]) {
				int T = to[t];
				if (D[T] >= b) {
					if (D[T] >= dekai) mada ^= 1 << (D[T] - dekai);
					D[T] = d;
					Q[q++] = T;
				}
			}
		}
		rep(p, K) {
			if (p > k) {
				DD[k][p] = D[C[p]] - b + choidekai;
				DD[p][k] = D[C[p]] - b + choidekai;
			}
			if (p > k + 1) D[C[p]] = dekai + p;
		}
	}
	rep(i, K) dp[1 << i][i] = 1 - choidekai;

	rep1(b, (1 << K) - 1) {
		int X[17], Y[17];
		auto x = X, y = Y;
		rep(i, K) {
			if (b >> i & 1) *x++ = i;
			else *y++ = i;
		}
		auto dp0 = dp[b];
		for (auto j = Y; j < y; j++) {
			int saishou = 0;
			for (auto i = X; i < x; i++) {
				if (saishou > dp0[*i] + DD[*j][*i]) saishou = dp0[*i] + DD[*j][*i];
			}
			dp[1 << *j | b][*j] = saishou;
		}
	}

	int kotae = 0;
	rep(i, K) chmin(kotae, dp[(1 << K) - 1][i]);

	if (kotae < 0) printf("%d", kotae + choidekai);
	else printf("-1");

	Would you please return 0;
}


#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 210;
#define int ll
const long double pi = 3.14159265358979323846;

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

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

void YES(bool ok){
    cout << (ok ? "Yes" : "No") << endl;
    exit(0);
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<Pll> v(2 * n, {-1, -1});
    rep(i, 0, n) {
        ll a,b; cin >> a >> b;
        if(a != -1){
            a--;
            if (v[a] != Pll{-1, -1}) YES(false);
            v[a] = {0, i};
        }
        if(b != -1){
            b--;
            if (v[b] != Pll{-1, -1}) YES(false);
            v[b] = {1, i};
        }
        if(a != -1 && b != -1){
            if (a > b) YES(false);
        }
    }

    // [l, r]の区間を正しく補完できるかチェック
    auto check = [&](ll l, ll r) {
        if (l & 1) return false;
        if (~r & 1) return false;

        ll len = (r - l + 1) / 2;
        bool res = true;

        rep(i, l, l + len){
            ll j = i + len;
            res &= v[i].first != 1;
            res &= v[j].first != 0;

            if (v[i] != Pll{-1, -1} && v[j] != Pll{-1, -1}) {
                res &= v[j].first == 1 && v[i].second == v[j].second;
            }
        }

        if (res) debug(l, r);
        return res;
    };

    bitset<n_max> dp(0);
    rep(i,0,2 * n){
        if (~i & 1) continue;

        rep(j, 0, i) {
            if (!dp[j]) continue;
            if (check(j + 1, i)){
                dp[i] = 1;
                break;
            }
        }
        if (check(0, i)) dp[i] = 1;
    }
    debug(dp);
    YES(dp[2 * n - 1]);
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 700;
const ll mod = 1e9+7;

#define mst(x, a) memset( x,a,sizeof(x) )
#define rep(i, a, b) for(int i=(a);i<=(b);++i)
#define dep(i, a, b) for(int i=(a);i>=(b);--i)

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*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
void out(ll x) {
	int stackk[40];
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (!x) {
		putchar('0');
		return;
	}
	int top = 0;
	while (x) stackk[++top] = x % 10, x /= 10;
	while (top) putchar(stackk[top--] + '0');
}

int n,m,x[666],y[666],a[666],b[666],vis1[666],vis2[666],ans,vis[666],k;
void dfs(int pos) {
	if(pos==k+1) {
		int temp=0;
		for(int i=1; i<=m ; i++) {
			if(vis[a[i]]&&vis[b[i]]) temp++;
		}
		ans = max(ans,temp);
		return ;
	}
	vis[x[pos]]++;
	dfs(pos+1);
	vis[x[pos]]--;
	vis[y[pos]]++;
	dfs(pos+1);
	vis[y[pos]]--;
}
int main() {
	n=read(),m=read();
	rep(i,1,m) a[i]=read(),b[i]=read();
	k=read();
	rep(i,1,k) x[i]=read(),y[i]=read();
	dfs(1);
	out(ans);
	return 0;
}

/*

*/

#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

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

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

    ll n, mm;
    cin >> n >> mm;
    vector<pair<int, int> >cond(mm);
    for (ll i = 0; i < mm; i++)
        cin >> cond[i].first >> cond[i].second;

    ll k;
    cin >> k;

    vector<pair<int, int> >choice(k);
    for (ll i = 0; i < k; i++)
        cin >> choice[i].first >> choice[i].second;

    ll ans = 0;
    for (ll i = 1; i <= (1ll << k); i++)
    {
        map<ll, ll> m;
        for (ll j = 0; j < k; j++)
        {
            if (i & (1 << j))
            {
                m[choice[j].first]++;
            }
            else
                m[choice[j].second]++;
        }
           /* */

        ll curr = 0;
        for (ll j = 0; j < mm; j++)
            if (m[cond[j].first] && m[cond[j].second])
                curr++;

        ans = max(curr, ans);
    }

    cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/priority_queue.hpp>
//#include <ext/pb_ds/hash_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define pb push_back
#define mkp make_pair
#define endl '\n'
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

//typedef gp_hash_table<int, int> hashmap;
//typedef tree<pii, null_type, std::less<pii>, splay_tree_tag, tree_order_statistics_node_update> splaytree;
//typedef tree<pii, null_type, std::less<pii>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
//typedef __gnu_pbds::priority_queue<int, std::greater<int>, __gnu_pbds::binary_heap_tag> binheap;
//typedef __gnu_pbds::priority_queue<int, std::greater<int>, __gnu_pbds::pairing_heap_tag> pairingheap;

template <typename T>
inline void read(T &x)
{
    T data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    x = f * data;
}
template <typename T, typename... Args>
inline void read(T &t, Args &...args)
{
    read(t);
    read(args...);
}

//mt19937 rnd(time(0));
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 2e5 + 9;
const ll mod = 1e9 + 7;
vi a;
signed main()
{
    //freopen("1.in","r",stdin);
    //freopen("1.out","w",stdout);
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //std::cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1, x; i <= n; ++i)
    {
        cin >> x;
        a.pb(x);
    }
    sort(a.begin(), a.end());
    ll ans = a[0] + 1;
    for (int i = 1; i < n; ++i)
        ans = ans * (a[i] - a[i - 1] + 1) % mod;
    cout << ans << endl;
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}

#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
int main(){
    int n;
    cin>>n;
    V<ll> l(n),r(n);
    for(int i=0;i<2*n;i++){
         if(i<n)cin>>l[i];
         else cin>>r[i-n];
    }
    reverse(all(l));
    ll ans=-inf,res=0;
    priority_queue<ll,V<ll>,greater<ll>> a,b;
    a.emplace(l[0]);
    for(int i=1;i<n;i++){
        a.emplace(l[i]);
        b.emplace(r[i]);
        if(a.top()<b.top()){
              a.pop();
        }else{
             b.pop();
        }
    }
    while(a.size()){
          res+=a.top();
          a.pop();
    }
    while(b.size()){
          res+=b.top();
          b.pop();
    }
    ans=res;
    res=0;
    b.emplace(r[0]);
    for(int i=1;i<n;i++){
        a.emplace(l[i]);
        b.emplace(r[i]);
        if(a.top()<b.top()){
              a.pop();
        }else{
             b.pop();
        }
    }
    while(a.size()){
          res+=a.top();
          a.pop();
    }
    while(b.size()){
          res+=b.top();
          b.pop();
    }
    cout<<max(ans,res)<<"\n";
}


// ＵＴＦ−８

#include<bits/stdc++.h>

using namespace std;
using ll = long long int;
using lc = complex<double>;
template <class T>
bool complex_comparator(const complex<T> &a, const complex<T> &b) {
 return real(a) == real(b) ? imag(a) < imag(b) : real(a) < real(b);
}

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

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

int main(void) {
    constexpr ll MOD = 0 ? 1e9+7 : 998244353;
    const double PI = acos(-1);
    constexpr double eps = 1e-5;
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    if(1) {
        ll n;
        cin >> n;
        vector<lc> s(n), t(n);

        lc gs = 0, gt = 0;
        for(ll i=0; i<n; i++) {
            double x, y;
            cin >> x >> y;
            s[i] = lc(n*x, n*y);
            gs += s[i];
        }
        for(ll i=0; i<n; i++) {
            double x, y;
            cin >> x >> y;
            t[i] = lc(n*x, n*y);
            gt += t[i];
        }
        gs /= n;
        gt /= n;
        for(auto &v: s) v -= gs;
        for(auto &v: t) v -= gt;

        {
            ll i;
            for(i=0; i<n; i++) {
                if(s[i] != 0.0) break;
            }
            if(i == n) {
                for(i=0; i<n; i++) {
                    if(t[i] != 0.0) break;
                }
                cout << (i == n ? "Yes" : "No") << endl;
                return 0;
            }

            lc x = s[i] / abs(s[i]);
            for(ll j=0; j<n; j++)
                s[j] /= x;
        }
        sort(begin(s), end(s), complex_comparator<double>);

        for(ll i=0; i<n; i++) {
            if(t[i] == 0.0) continue;

            vector<lc> tt(n);
            for(ll j=0; j<n; j++)
                tt[j] = t[j] / (t[i] / abs(t[i]));

            sort(begin(tt), end(tt), complex_comparator<double>);

            bool ok = true;
            for(ll j=0; j<n; j++) {
                ok &= norm(tt[j] - s[j]) < eps;
            }
            if(ok) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;

    }
    return 0;
}

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

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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
// or add ll at the end for long long
#define cntleadz(x) __builtin_clz(x)
#define cnttrailz(x) __builtin_ctz(x)
#define cntpop(x) __builtin_popcountll(x)
#define binparity(x) __builtin_parity(x)
#define pb push_back
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define debug_vector(v)			\
	for(auto x : v)             \
		cout<<x<<' ';           \
	cout<<'\n'
#define debug_pvector(v)        \
    for (auto x : v)            \
        cout<<x.fi<<' '<<x.se<<'\n';
#define debug(x) cout<<#x<<" = "<<x<<'\n'
#define mod 1000000007
// #define mod 998244353
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

ll binExp(ll x,ll n,ll m)
{
    ll res=1;
    while(n)
    {
        if(n&1) res=(res*x)%m;
        x=(x*x)%m;
        n>>=1;
    }
    return res;
}

ll modInv(ll i, ll m) {return binExp(i,m-2,m);}
ll add(ll a, ll b) {ll res = a+b; if(res >= mod) res -= mod; if(res < 0) res += mod; return res;}
ll mul(ll a, ll b) {ll res = (a)*(b); res %= mod; if(res < 0) res += mod; return res;}
// ll fact[1000006];
// ll ncr(int n,int r) {return (n>=r?(fact[n]*modInv(fact[r],mod))%mod*modInv(fact[n-r],mod)%mod:0);}

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

    vector<int> a(n), b(n), c(n), d(n);

    int x = 0, y = 0;
    f0(i,0,n)
    {
        cin>>a[i]>>b[i];
        x += a[i];
        y += b[i];
        a[i] *= n;
        b[i] *= n;
    }
    f0(i,0,n)
    {
        a[i] -= x;
        b[i] -= y;
    }

    x = y = 0;
    f0(i,0,n)
    {
        cin>>c[i]>>d[i];
        x += c[i];
        y += d[i];
        c[i] *= n;
        d[i] *= n;
    }
    f0(i,0,n)
    {
        c[i] -= x;
        d[i] -= y;
    }

    f0(i,0,n)
    {
        if(a[i] || b[i])
        {
            swap(a[0],a[i]);
            swap(b[0],b[i]);
        }
    }

    double err = 1e-6;
    string ans = "No";

    f0(i,0,n)
    {
        double shift = atan2(d[i],c[i]) - atan2(b[0],a[0]);
        bool yes = true;
        f0(j,0,n)
        {
            double x = a[j]*cos(shift)-b[j]*sin(shift);
            double y = a[j]*sin(shift)+b[j]*cos(shift);
            bool yes_here = false;
            f0(k,0,n)
            {
                if(abs(x-c[k]) <= err && abs(y-d[k]) <= err) yes_here = true;
            }
            yes &= yes_here;
        }
        if(yes) ans = "Yes";
    }
    cout<<ans<<'\n';
}

signed main()
{
    fast

    clock_t start,end;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    start = clock();

    int tc;
    tc = 1;
    // cin>>tc;
    f1(i,1,tc)
        solve();

    end = clock();
    double time_taken = double(end-start) / double(CLOCKS_PER_SEC);
    // cout<<time_taken<<" sec";
}


#include<bits/stdc++.h>

using namespace std;

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

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
int main(){
  ll n, m;
  cin >> n >> m;
  cout << (modpow((ll)10,n,m*m)/m)%m<<endl;
}


#include <iostream>
#include <string>
#include <vector>

int main() {
  int N;
  std::string S, X;
  std::cin >> N >> S >> X;
  std::vector<bool> state(7);
  state[0] = true;
  for (int i = N - 1; i >= 0; --i) {
    const std::vector<int> digits = {S[i] - '0', 0};
    std::vector<bool> next(7);
    state.swap(next);
    for (int j = 0; j < 7; ++j) {
      state[j] = X[i] == 'A';
      for (const int digit : digits) {
        if (next[(10 * j + digit) % 7] ^ state[j]) {
          state[j] = !state[j];
          break;
        }
      }
    }
  }
  std::cout << (state[0] ? "Takahashi" : "Aoki") << std::endl;
  return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <iomanip>
#include <utility>
#include <cmath>
using namespace std;

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

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
ll gcd(int a, int b){return b ? gcd(b, a%b) : a;}
ll lcm(int a, int b){return a*b / gcd(a, b);}

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

    int MAX = 0, MIN = 1000000;
    w *= 1000;
    for (int n = 1; n <= 1000000; ++n) {
        if(a * n <= w && b * n >= w){
            MAX = max(MAX, n);
            MIN = min(MIN, n);
        }
    }

    if(MAX == 0){
        cout << "UNSATISFIABLE" << endl;
    }
    else{
        cout << MIN << " " <<  MAX << endl;
    }
    return 0;
}


///

#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fodec(i,a,b) for(int i=a;i>b;i--)
#define sz(v) int(v.size())
#define len(s) s.length()
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vvll vector<vector<ll>>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define piii pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define bit_cnt(x) __builtin_popcount(x)
#define fastio ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fileio freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define inf 1e9
const int MOD = 1e9+7;

int n;
vvi adj;
vi cc;
vi ans;

unordered_map<int,bool> uu;

void solve(int s,int par){
    bool f=false;
    if(!uu[cc[s]]){
        f=true;
        ans.pb(s);
        uu[cc[s]]=true;
    }
    for(auto&x:adj[s]){
        if(x==par) continue;
        solve(x,s);
    }
    if(f) uu[cc[s]]=false;
}

int main(){
    cin>>n;
    cc.assign(n,-1);
    fo(i,0,n) cin>>cc[i];
    adj.assign(n,vector<int>());
    fo(i,0,n-1){
        int x,y;
        cin>>x>>y;
        x--; y--;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    ans.clear();
    uu.clear();
    solve(0,-1);
    sort(all(ans));
    for(auto&it:ans) cout<<it+1<<endl;
}

#include "bits/stdc++.h"

#pragma GCC optimize("Ofast")

using namespace std;

#define endl            "\n"
#define all(v)          v.begin(), v.end()
#define debug(x)        cout << #x << " is " << x << endl
#define isOdd(n)        (n&1)
#define pow(n, m)       (ll)powl(n, m)
#define Unique(x)       x.erase(unique(all(x)), x.end())
#define clr(x, last)    memset(x, last, sizeof(x))

using ll = long long;
using ld = long double;
using vi = vector<int>;
using pii = pair<ll, int>;
using tii = tuple<int, int, int>;

const int N = 1e5 + 5, M = 2e5 + 5;

int ne, head[N], nxt[M], to[M], color[N];

void initGraph(int n){
    memset(head, -1, n * sizeof(head[0]));
    ne = 0;
}

void addEdge(int f, int t){
    to[ne] = t;
    nxt[ne] = head[f];
    head[f] = ne++;
}

void addBidirectedEdge(int u, int v){
    addEdge(u, v);
    addEdge(v, u);
}

int f[N];
vector<int> ans;

void dfs(int u, int par){
    if(!f[color[u]]) ans.push_back(u + 1);
    f[color[u]]++;
    for (int k = head[u]; ~k; k = nxt[k]) {
        int v = to[k];
        if(v == par) continue;
        dfs(v, u);
    }
    f[color[u]]--;
}

int main()
{

    ios_base::sync_with_stdio(0), cin.tie(0);

    int n; cin >> n;
    initGraph(n);

    for (int i = 0; i < n; ++i) {
        cin >> color[i];
    }
    for (int i = 0; i + 1 < n; ++i) {
        int u, v; cin >> u >> v;
        --u, --v;
        addBidirectedEdge(u, v);
    }

    dfs(0, -1);
    sort(all(ans));
    for(auto &i: ans)
        cout << i << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  int X,Y,Z;
  cin>>X>>Y>>Z;
  if(Y*Z%X==0){cout<<Y*Z/X-1<<endl;}
  else {cout<<Y*Z/X<<endl;}
}

#include <stdio.h>
#include <stdlib.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;
using ull = unsigned long long int;

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

int main() {
    double x, y, z;
    cin >> x >> y >> z;

    for (double i = 1000000; i > 0; i--) {
        if (i / z < y / x) {
            cout << i << endl;
            return 0;
        }
    }

    cout << 0 << endl;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)

int main(void){
  ld n,d,h;
  cin >> n >> d >> h;
  //vector<pair<int,int>> hd(n);
  ld maxh=0,maxd=0;

  ld x = 100000;
  // REP(i,n){
  //   ld tmpd,tmph;
  //   cin >> tmpd >> tmph;
  //   if(tmph > maxh){
  //     maxh = tmph;
  //     maxd = tmpd;
  //   }
  //   if(tmph == maxh && tmpd < maxd){
  //     maxd = tmpd;
  //   }
  //   if(x > (h-tmph)/(d-tmpd)) x = (h-tmph)/(d-tmpd);
  // }

  REP(i,n){
    ld tmpd,tmph;
    cin >> tmpd >> tmph;
    // if(tmph > maxh){
    //   maxh = tmph;
    //   maxd = tmpd;
    // }
    // if(tmph == maxh && tmpd < maxd){
    //   maxd = tmpd;
    // }
    if(x > (h-tmph)/(d-tmpd)){
      x = (h-tmph)/(d-tmpd);
      maxh = tmph;
      maxd = tmpd;
    }
  }

  // REP(i,n){
  //   ld tmph,tmpd;
  //   cin >> tmpd >> tmph;
  //   if(x > (h-tmph)/(d-tmpd)) x = (h-tmph)/(d-tmpd);
  // }

  ld ans = maxh - x*maxd;
  if(ans < 0) ans = 0;
  cout << fixed << setprecision(15) << ans << endl;
}

#pragma region Macros
#include <bits/stdc++.h>
#if defined(LOCAL) || defined(ONLINE_JUDGE) || defined(_DEBUG)
#include <atcoder/all>
#endif
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>using vec = vector<T>;
template<class T, class U>using umap = unordered_map<T, U>;
template<class T>using uset = unordered_set<T>;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
//using T = tuple<ll, ll, ll>;
using vl = vec<ll>;
#define fi first
#define se second
#define el endl
constexpr ll INF = numeric_limits<ll>::max()/2-1;
#pragma endregion

#pragma region IOMacros
template<class T>
istream &operator>>(istream &stream, vec<T>& o){REP(i, o.size())stream >> o[i];return stream;}
template<class T>
ostream &operator<<(ostream &stream, vec<T>& objs){REP(i, objs.size())stream << objs[i] << " ";stream << el;return stream;}

#define I(T, ...) ;T __VA_ARGS__;__i(__VA_ARGS__);
void __i() {}
template<class T, class... Ts> void __i(T&& o, Ts&&... args){cin >> o;__i(forward<Ts>(args)...);}

void O() {cout << el;}
template<class T, class... Ts> void O(T&& o, Ts&&... args){cerr << o << " ";O(forward<Ts>(args)...);}
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    I(string, S);
    vl C(10);
    REP(i, S.length()){
        if(S[i] == 'o'){
            C[i] = 1;
        }else if(S[i] == '?'){
            C[i] = -1;
        }
    }
    ll cnt = 0;
    // o:1, x:0, ?:-1
    REP(i, 10000){
        ll t = i;
        vl m(10);
        REP(j, 4){
            ll s = t%10;
            m[s] = 1;
            t/=10;
        }
        ll flg = true;
        REP(j, 10){
            if(
                (C[j] == 0 && m[j] == 1) ||
                (C[j] == 1 && m[j] == 0)
            ){
                flg = false;break;
            }
        }
        if(flg){
            cnt++;
        }
    }
    cout << cnt << el;
}


#include<bits/stdc++.h>
using namespace std;
#define m7          1000000007
#define m9          1000000009
#define ll          long long
#define boost       ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define F           first
#define S           second
#define pb          push_back
#define f1(i,n)     for(int i=0;i<n;i++)
#define all(c)      c.begin(),c.end()
#define ldb         long double

int main() {

    int t;
   // cin>>t;
    t = 1;
    while(t--)
    {
        string s;
        cin>>s;
        cout<<s[1]<<s[2]<<s[0]<<'\n';

    }
	return 0;
}

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;

int main()
{
    char c1,c2,c3;
    cin >> c1 >>c2 >>c3;
    string S = "";
    S = S + c2 + c3 + c1;
    cout << S << endl;

}