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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> posx(n, 0);
    vector<int> posy(n, 0);
    iota(posx.begin(), posx.end(), 0);
    iota(posy.begin(), posy.end(), 0);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    sort(posx.begin(), posx.end(), [&](int i, int j) {
        return x[i] < x[j];
    });
    sort(posy.begin(), posy.end(), [&](int i, int j) {
        return y[i] < y[j];
    });
    set<int> candidates;
    candidates.insert(posx[0]);
    candidates.insert(posx[1]);
    candidates.insert(posx[n - 2]);
    candidates.insert(posx[n - 1]);
    candidates.insert(posy[0]);
    candidates.insert(posy[1]);
    candidates.insert(posy[n - 2]);
    candidates.insert(posy[n - 1]);
    vector<int> dis;
    for (auto i = candidates.begin(); i != candidates.end(); i++) {
        for (auto j = i; j != candidates.end(); j++) {
            if (i == j) continue;
            dis.push_back(max(abs(x[*i] - x[*j]), abs(y[*i] - y[*j])));
        }
    }
    sort(dis.begin(), dis.end(), greater<int>());
    cout << dis[1];
    return 0;
}

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

pair<int, int> p[400009];
int st[800009], lz[800009];

void lazy(int tn, int s, int e)
{
	if (lz[tn] != 0) {
		st[tn] += lz[tn];
		if (s != e) {
			lz[tn * 2] += lz[tn];
			lz[tn * 2 + 1] += lz[tn];
		}
		lz[tn] = 0;
	}
}

void update(int tn, int s, int e, int ts, int te, int w)
{
	lazy(tn, s, e);
	if (e < ts || s > te) return;
	if (ts <= s && e <= te) {
		lz[tn] += w;
		lazy(tn, s, e);
		return;
	}
	int md = (s + e) / 2;
	update(tn * 2, s, md, ts, te, w); update(tn * 2 + 1, md + 1, e, ts, te, w);
	if (s != e) st[tn] = min(st[tn * 2], st[tn * 2 + 1]);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 1; i <= 2 * n; i++) {
		cin >> p[i].first;
		if (i <= n) p[i].second = n - i + 1;
		else p[i].second = i - n;
	}
	sort(p + 1, p + 2 * n + 1); reverse(p + 1, p + 2 * n + 1);
	long long ans = 0;
	for (int i = 1; i <= n; i++)
		update(1, 1, n, i, n, 1);
	for (int i = 1; i <= 2 * n; i++) {
		update(1, 1, n, p[i].second, n, -1);
		if (st[1] < 0) {
			update(1, 1, n, p[i].second, n, 1);
			continue;
		}
		ans += p[i].first;
	}
	cout << ans << '\n';
	return 0;
}


//#include <atcoder/maxflow.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#include <iostream>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <iterator>
#include <random>
#include <chrono>
#include <complex>
#include <bitset>
#include <fstream>

#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

//using namespace __gnu_pbds;
//using namespace atcoder;
using namespace std;

//const ll modd = (1000LL * 1000LL * 1000LL + 7LL);
const ll modd = 998244353;

int main(int argc, char *argv[])   {

    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

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

    cout.precision(12);

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n);
        ll pow2 = 1;
        ll b = 0;
        ll ans = n;
        while (true) {
            ll c = n%pow2;
            ll a = n/pow2;
            ans = min(ans, a+b+c);
            if (pow2>n) { break; }
            ++b;
            pow2 *= 2;
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main(){
  vvl tate(29, vl(30,0));
  vvl yoko(30, vl(29,0));
  rep(_,1000){
    int a, b, ato, bto;
    cin >> a >> b >> ato >> bto;
    int ma = a;
    int mb = b;
    string ans;
    while(a != ato || b != bto){
      if (a == ato){
        if (b < bto){
          b++;
          ans.pb('R'); continue; // continueの貼り付けを忘れると
        } else { // バグる ato btoが連続するからです
          b--; // 全てに張り付けておく必要があるので
          ans.pb('L'); continue;
        }
      }
      if (b == bto){
        if (a < ato){
          a++;
          ans.pb('D'); continue;
        } else {
          a--;
          ans.pb('U'); continue;
        }
      }
      if (a < ato && b < bto){
        // 下 右
        if (tate[a][b] < yoko[a][b]){
          a++; // 縦移動優先
          ans.pb('D'); continue;
        } else {
          b++;
          ans.pb('R'); continue;
        }
      }
      if (a < ato && b > bto){
        // 下 左
        if (tate[a][b] < yoko[a][b-1]){
          a++; // 縦移動優先
          ans.pb('D'); continue;
        } else {
          b--;
          ans.pb('L'); continue;
        }
      }
      if (a > ato && b < bto){
        // 上 右
        if (tate[a-1][b] < yoko[a][b]){
          a--; // 縦移動優先
          ans.pb('U'); continue;
        } else {
          b++;
          ans.pb('R'); continue;
        }
      }
      if (a > ato && b > bto){
        // 上 左 ここから続き
        if (tate[a-1][b] < yoko[a][b-1]){
          a--; // 縦移動優先
          ans.pb('U'); continue;
        } else {
          b--;
          ans.pb('L'); continue;
        }
      }
    }
    cout << ans << endl; // flushを炊く
    ll average;
    cin >> average;
    average /= ans.size(); // 一歩当たりのコスト計算
    // cout << average << endl; // debug
    rep(i,ans.size()){
      if (ans[i] == 'U'){
        tate[ma-1][mb] = (tate[ma-1][mb] + average)/2;
        ma--; // 実数値に近づけていく方針にした
      }
      if (ans[i] == 'D'){
        tate[ma][mb] = (tate[ma][mb] + average)/2;
        ma++;
      }
      if (ans[i] == 'L'){
        yoko[ma][mb-1] = (yoko[ma][mb-1] + average)/2;
        mb--;
      }
      if (ans[i] == 'R'){
        yoko[ma][mb] = (yoko[ma][mb] + average)/2;
        mb++;
      }
    }
    // for(auto x : tate){ // コスト計算debug
    //   for(auto y : x){
    //     cout << y << " ";
    //   } cout << endl;
    // }
    // for(auto x : yoko){
    //   for(auto y : x){
    //     cout << y << " ";
    //   } cout << endl;
    // }
  }
}


/* stuff you should look for
	* int overflow, array bounds, uppercase/lowercase
	* special cases (n=1?)
	* do sth. instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/
#include<cstdio>
#include<string>
#include<iostream>
#include<map>
char s[15];
std::map<int,std::string> mp;
int main() {
	int n; scanf("%d",&n);
	for(register int i=1;i<=n;++i) {
		int v;
		scanf("%s%d",s,&v);
		std::string str=s;
		mp[v]=str;
	}
	std::map<int,std::string>::iterator it=mp.end(); --it; --it;
	printf("%s\n",it->second.c_str());
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct sa{
    string nam;
    int gd;
}a[1005];
int n;
bool cmp(sa x,sa y){
    return x.gd<y.gd;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i].nam>>a[i].gd;
    }
    sort(a+1,a+n+1,cmp);
    cout<<a[n-1].nam;
    return 0;
}


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

int k, n, dep[200010];
char vis[200010];
vector <int> gl[200010];
int check(const int &u, const int &d, int &cnt);

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	scanf("%d%d", &n, &k);
	for (int i = 1; i < n; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		gl[--u].push_back(--v); gl[v].push_back(u);
	}
	int l = 1, r = n - 2, ans = n - 1;
	while (l <= r) {
		const int mid = l + r >> 1;
		memset(vis, 0, n);
		int cnt = 0, ret = check(0, mid, cnt);
		if (ret < 0)
			++cnt;
		if (cnt > k)
			l = mid + 1;
		else
			r = mid - 1, ans = mid;
	}
	printf("%d\n", ans);
	return 0;
}

int check(const int &u, const int &d, int &cnt) {
	vis[u] = 1;
	int maxv = 0, minv = 0;
	for (int i = 0; i < gl[u].size(); ++i) {
		int &v = gl[u][i];
		if (vis[v])
			continue;
		int tmp = 0, ret = check(v, d, tmp);
		maxv = max(maxv, ret), minv = min(minv, ret);
		cnt += tmp;
	}
	if (maxv + minv >= 1)
		return maxv - 1;
	else if (minv == -d) {
		++cnt;
		return d;
	}
	else
		return minv - 1;
}

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

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

using namespace std;
const int LOG = 22;
vector<int> G[200010];
int parent[25][200010];
int d[200010];
void dfs(int s, int p){
    parent[0][s] = p;
	for(int v:G[s]){
		if(v==p) continue;
		d[v] = d[s] + 1;
		dfs(v,s);
	}
}

void init(int sz,int root){
	d[root] = 0; dfs(root,-1);
	for(int k=0;k<LOG;k++){
		for(int i=0;i<sz;i++){
			if(parent[k][i]<0) parent[k + 1][i] = -1;
			else parent[k + 1][i] = parent[k][parent[k][i]];
		}
	}
}

int lca(int u, int v){
	if(d[u]>d[v]) swap(u,v);
	for(int k = 0;k<LOG;k++){
		if((d[v] - d[u])&(1<<k)){
			v = parent[k][v];
		}
	}
	if(u==v) return u;
	for(int k = LOG-1;k>=0;k--){
		if(parent[k][u]!=parent[k][v]){
			u = parent[k][u];
			v = parent[k][v];
		}
	}
	return parent[0][u];
}

int dist(int u,int v){return d[u] + d[v] - 2*d[lca(u,v)];}
vector<int> used;
//bool dp[200010][210];
void dfs2(int s,int p,int x){
    used[s] = 1;
    if(x==0) return;
    //if(x==0 || dp[s][x]) return;
    //dp[s][x] = true;
    for(int v: G[s]){
        if(v==p) continue;
        dfs2(v,s,x - 1);
    }
}

int main(){
    int i,n,k; cin >> n >> k;
    for(i=0;i<n - 1;i++){
        int a,b; cin >> a >> b; a--; b--;
        G[a].push_back(b); G[b].push_back(a);
    }
    if(k==n){
        cout << 0 << endl;
        return 0;
    }
    init(n,0);
    vector<pair<int,int>> p;
    for(i=0;i<n;i++) p.push_back({d[i],i});
    sort(p.begin(),p.end()); used.resize(n);
    int l = 0,r = n/k;
    while(r - l>1){
        int mid = (l + r)/2,num = 0;
        vector<int> v;
        for(i=0;i<n;i++) v.push_back(p[i].second), used[i] = 0;
        if(mid<=200 && k>100){
            while(v.size()){
                int u = v.back(); v.pop_back();
                if(used[u]) continue;
                for(i=0;i<mid;i++){
                    if(parent[0][u]==-1) break;
                    u = parent[0][u];
                }
                num++;
                dfs2(u,-1,mid);
            }
        }else{
            vector<int> col;
            while(v.size()){
                int u = v.back(); v.pop_back();
                bool f = true;
                for(i=0;i<col.size();i++){
                    if(dist(u,col[i])<=mid) f = false;
                }
                int x = min(mid,d[u]);
                for(i=LOG;i>=0;i--){
                    if((x>>i)&1) u = parent[i][u];
                }
                if(f) col.push_back(u);
                if(col.size()>k) break;
            }
            num = col.size();
        }
        if(num<=k) r = mid;
        else l = mid;
    }
    cout << r << endl;
}


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

int x[2010];
int y[2010];

int main() {
	int n,t,li,ri,ans;

	cin >> n;
	rep(i,n){
		cin >> t >> li >> ri;
		li*=2;
		ri*=2;
		if(t==2)ri--;
		if(t==3)li++;
		if(t==4){
			li++;
			ri--;
		}
		x[i]=li;
		y[i]=ri;
	}
	ans=0;
	rep(i,n){
		rep(j,n){
			if(i>=j) continue;
			if(y[i]<x[j]) continue;
			if(y[j]<x[i]) continue;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long

const ll INF = 1e9+7;

int main(){
	ll n;
	cin >> n;
	double t, a, b;
	vector<pair<double, double>>v;
	for(ll i=0; i<n; i++){
		cin >> t >> a >> b;
		if(t == 1)
			v.push_back(make_pair(a, b));
		else if(t == 2)
			v.push_back(make_pair(a, b-0.5));
		else if(t == 3)
			v.push_back(make_pair(a+0.5, b));
		else if(t == 4)
			v.push_back(make_pair(a+0.5, b-0.5));
	}
	ll ans = 0;
	for(int i=0; i<n-1; i++){
		for(int j=i+1; j<n; j++){
			if(max(v[i].first, v[j].first) <= min(v[i].second, v[j].second))
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k):    It returns to an iterator to the kth element (counting from zero) in the set
// order_of_key(k) :    It returns to the number of items that are strictly smaller than our item k
#define fast            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb              push_back
#define f               first
#define s               second
#define F(i,a,b)        for(i=a;i<b;i++)
#define nl              "\n"
#define sp              " "
#define all(c)          (c).begin(),(c).end()
#define rev(i,b,a)      for(int i=b;i>=a;i--)
#define iota            cout<<-1<<nl
#define cty             cout<<"YES"<<nl
#define ctn             cout<<"NO"<<nl
#define lmax            LLONG_MAX
#define lmin            LLONG_MIN
#define sz(v)           (v).size()
#define deci(n)         fixed<<setprecision(n)
#define c(x)            cout<<(x)
#define csp(x)          cout<<(x)<<" "
#define c1(x)           cout<<(x)<<nl
#define c2(x,y)         cout<<(x)<<" "<<(y)<<nl
#define c3(x,y,z)       cout<<(x)<<" "<<(y)<<" "<<(z)<<nl
#define c4(a,b,c,d)     cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<nl
#define c5(a,b,c,d,e)   cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<nl
#define c6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<nl
typedef long double     ld;
typedef long long       ll;
typedef vector<ll>      vll;
typedef pair<ll,ll>     pll;
typedef vector<pll>     vpll;
const int mod=998244353;
const int mod1=1000000007;
const double pi=3.14159265358979323846264338327950288419716939937510582097494459230;
// priority_queue<t>
ll max(ll a , ll b){ if(a>b)return a; return b;}
ll min(ll a , ll b){ if(a<b)return a; return b;}
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down
ll pct(ll x) { return __builtin_popcount(x); } // # of bits set
ll poww(ll a, ll b) { ll res=1; while(b) { if(b&1)	res=(res*a); a=(a*a); b>>=1; } return res; }
ll modI(ll a, ll m=mod) { 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;}
ll powm(ll a, ll b,ll m=mod) {ll res=1;	while(b) {	if(b&1)	res=(res*a)%m;	a=(a*a)%m; b>>=1;	}	return res;}
//*******************************************************************************************************************************************//
vector<pair<ll,pll>>v[100001];
bool vis[100001]={0};
ll dp[100001];
ll n;
ll calc(ll st, ll c, ll d)
{

    return max(st,sqrt(d));
}
void bfs(ll s)
{
    ll i,j,d,x,y;
    for(i=1;i<=n;i++)dp[i]=lmax;
    priority_queue<pll>q;
    q.push({0,1});
    dp[1]=0;
    while(q.size())
    {
        x=q.top().s;
        q.pop();
        if(vis[x])
            continue;
        vis[x]=1;
        for(auto u:v[x])
            if(u.f!=x)
        {
            d=calc(dp[x],u.s.f,u.s.s);
            d=u.s.f+fdiv(u.s.s,d+1)+d;

            if(d<dp[u.f])
            {//c2(u.f,d);
                dp[u.f]=d;
             q.push({-1*dp[u.f],u.f});
            }
        }
    }

}
void iamzeus()
{ ll i,j,x=0,y,ans=0,m,d,cnt=0,z,c=2,k;

 cin>>n>>m;
 for(i=0;i<m;i++)
 {
     cin>>x>>y>>z>>d;
     v[x].pb({y,{z,d}}),v[y].pb({x,{z,d}});
 }
 bfs(1);
 if(dp[n]==lmax)
     iota;
 else
 c1(dp[n]);

};
int main()
{fast;
    int t;
 t=1;
//cin >>t;
 while(t--)
     iamzeus();
}

#include<bits/stdc++.h>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int N, M;
vector<pair<int, pii>> G[100010];
int dist[100010];

//時刻tかそれ以降にCi=c,Di=dの道の通行を始めるとき、最短で到着する時刻
int earliest(int c, int d, int t) {
    int T = sqrt(d) - 1;
    int T2 = sqrt(d);
    if (T < t)T = t;
    if (T2 < t)T2 = t;
    return min({t + c + d / (t + 1), T + c + d / (T + 1), T2 + c + d / (T2 + 1)});
}

void dijkstra() {
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    dist[0] = 0;
    for (int i = 1; i < N; ++i)dist[i] = INF;
    pq.emplace(dist[0], 0);
    while (!pq.empty()) {
        pii p = pq.top();
        pq.pop();
        int v = p.second;
        if (dist[v] < p.first)continue;
        for (auto e:G[v]) {
            int to = e.first;
            int c = e.second.first;
            int d = e.second.second;
            int time = earliest(c, d, dist[v]);
            if (dist[to] > time) {
                dist[to] = time;
                pq.emplace(dist[to], to);
            }
        }
    }
}

signed main() {
    cin >> N >> M;
    rep(i, M) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        --a, --b;
        G[a].emplace_back(b, pii(c, d));
        G[b].emplace_back(a, pii(c, d));
    }
    dijkstra();
    if (dist[N - 1] == INF)cout << -1 << endl;
    else cout << dist[N - 1] << endl;
    return 0;
}


#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#include<queue>
#include<cstdio>
#include<vector>
#include <algorithm>
#include<map>
#define rep(i,n) for (int i=0;i<(n);++i)
using ll = long long;
using namespace std;
using P = pair<int,int>;
#define INF 1000000000

int main(){
	map<char,ll> mp;
	vector<string> s(3);
	set<char> head;
	rep(i,3) cin>>s[i];

	rep(i,3){
		reverse(s[i].begin(),s[i].end());
		ll co = 1;
		if(i == 2) co = -1;
		for(char c : s[i]){
			mp[c] += co;
			co *= 10;
		}
		reverse(s[i].begin(),s[i].end());
		head.insert(s[i][0]);
	}
	if(mp.size() > 10){
		cout<<"UNSOLVABLE"<<endl;
		return 0;
	}
	vector<int> p(10);
	iota(p.begin(),p.end(),0);
	do{
		int i = 0;
		ll tot = 0;
		for(auto x:mp){
			char c = x.first;
			ll co = x.second;
			if(p[i] == 0 && head.count(c)) tot = 1e18;
			tot += co*p[i];
			++i;
		}
		if(tot == 0){
			i = 0;
			for(auto& x:mp){
				x.second = p[i];
				++i;
			}
			rep(i,3){
				ll k = 0;
				for(char c : s[i]){
					k = k*10 + mp[c];
				}
				cout<<k<<endl;
			}
			return 0;
		}
	}while(next_permutation(p.begin(),p.end()));
	cout<<"UNSOLVABLE"<<endl;
	return 0;
}

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define pb push_back
#define INF 1000000000
#define LL_MAX 1000000000000000000
#define LL_MIN -1000000000000000000
#define mod 1000000007
#define mod2 998244353
#define PI 3.14159265358979323846264338327950288419716939937510
#define ll int64_t
#define ld long double
#define vi vector <int>
#define vb vector<bool>
#define vvi vector <vector<int>>
#define vll vector<ll>
#define vvl vector <vector<ll>>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int>>
#define pld pair<ld,ld>
#define vpll vector<pair<ll,ll>>
#define vpld vector<pair<ld,ld>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define FIO   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fs(x) fixed<<setprecision(x)
#define print(a) {for(auto x:a){cout << x << " ";}}
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// template <typename T>
// using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

bool chmin(ll& a, const ll& b) {
	return b < a ? a = b, 1 : 0;
}
bool chmax(ll& a, const ll& b) {
	return a < b ? a = b, 1 : 0;
}
constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int bits(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

const int N = 1e7;

void run_case() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	map<char, int> mp;
	for (char c : s1) mp[c]++;
	for (char c : s2) mp[c]++;
	for (char c : s3) mp[c]++;
	if (mp.size() > 10) {
		cout << "UNSOLVABLE" << endl;
		return ;
	}
	string s0;
	for (auto p : mp) s0 += p.first;
	int m = s0.size();
	vector<int> v(10);
	for (int i = 0; i < 10; i++) v[i] = i;
	auto val = [&](char c) {
		for (int i = 0; i < m; i++) {
			if (c == s0[i]) {
				return v[i];
			}
		}
		return -1;
	};
	while (next_permutation(all(v))) {
		if (val(s1[0]) == 0 || val(s2[0]) == 0 || val(s3[0]) == 0)continue;
		ll x1 = 0, x2 = 0, x3 = 0;
		for (auto x : s1) {
			x1 *= 10;
			x1 += val(x);
		}
		for (auto x : s2) {
			x2 *= 10;
			x2 += val(x);
		}
		for (auto x : s3) {
			x3 *= 10;
			x3 += val(x);
		}
		if (x1 + x2 == x3) {
			cout << x1 << endl;
			cout << x2 << endl;
			cout << x3 << endl;
			return;
		}
	}
	cout << "UNSOLVABLE\n";
}
auto clk = clock();
int main()
{

	FIO
#ifndef ONLINE_JUDGE
	//for getting input from input.txt
	freopen("input.txt", "r", stdin);
	//for writting output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		run_case();
	}
// #ifndef ONLINE_JUDGE
// 	cout << endl
// 	     << "Time elapsed: " << fs(10) << (double)(clock() - clk) / CLOCKS_PER_SEC << endl
// 	     << endl;
// #endif
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * in case of segmentation fault check for ex- a variable declared more than once , or index becoming negative
    * check TLE due to not clearing adjacency list for each test
    * do smth instead of nothing and stay organized
    * BELIEVE in yourself
*/


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

#define ll long long
int main()
{
    string s;
    string tmp = "110";
    int n;
    cin >> n;
    cin >> s;

    ll ans = 0;
    for (int i = 0; i < 3; i++)
    {
        bool ok = 1;
        for (int j = 0; j < n; j++)
            if (s[j] != tmp[(i + j) % 3])
            {
                ok = 0;
                break;
            }
        if (ok)
            ans += (10000000000LL * 3 - i - n) / 3 + 1;
    }
    cout << ans << endl;
}

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

const int64_t MAX = 10000000000;

int64_t is_valid(string &S, string &T){
  int64_t ret = -1;
  for(int i=0; i<S.size() - T.size()+1; i++){
    bool flag = true;
    for(int j=0; j<T.size(); j++){
      if(S[i+j] != T[j]){
        flag = false;
      }
    }
    if(flag){
      ret = i;
      break;
    }
  }
  return ret;
}

int main(){
  int N;
  cin >> N;
  string T;
  cin >> T;
  if(T == "1"){
    cout << MAX*2 << endl;
    return 0;
  }
  if(T == "11" || T == "0"){
    cout << MAX << endl;
    return 0;
  }

  string A = "110";
  string S = "";
  for(int i=0; i<(N+4)/3; i++){
    S += A;
  }
  //cout << S << endl;

  int64_t x = is_valid(S,T);
  if(x == -1){
    cout << 0 << endl;
  }
  else{
    int64_t ok = 0;
    int64_t ng = MAX+10;
    while(ng - ok > 1){
      int64_t mid = (ok+ng)/2;
      if((mid-1)*3 + N <= MAX*3 - x){
        ok = mid;
      }
      else{
        ng = mid;
      }
    }
    cout << ok << endl;
  }

}


#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int N;
    cin >> N;
    vector<int64_t> A(N), B(N);

    for (auto &a : A)
        cin >> a;

    for (auto &b : B)
        cin >> b;

    vector<int64_t> change;
    int64_t sum = 0;

    for (int i = 0; i < N; i++) {
        int64_t take = i % 2 == 0 ? A[i] : B[i];
        int64_t other = i % 2 == 0 ? B[i] : A[i];
        sum += take;
        change.push_back(other - take);
    }

    nth_element(change.begin(), change.begin() + N / 2, change.end(), greater<int64_t>());

    for (int i = 0; i < N / 2; i++)
        sum += change[i];

    cout << sum << '\n';
}

#include <cmath>
#include <iostream>
#include <map>
#include <utility>
#include <vector>

#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using std::map;
using std::vector;

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

    ll a[n];
    ll max = 0;
    ll cursumA = 0;
    ll b = 0;
    REP(i, n) {
        cin >> a[i];
        max = std::max(max, a[i]);
        b += cursumA + a[i];
        cout << max * (i + 1) + b << endl;
        cursumA += a[i];
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool _DD = false;
#define _D(a)if(_DD)cout<<#a<<':'<<a<<" | ";
#define DBG(a){_D(a);if(_DD)cout<<'\n';}
#define DBG2(a,b){_D(a);_D(b);if(_DD)cout<<'\n';}
#define DBG3(a,b,c){_D(a);_D(b);_D(c);if(_DD)cout<<'\n';}
#define DBG4(a,b,c,d){_D(a);_D(b);_D(c);_D(d);if(_DD)cout<<'\n';}
#define DBG5(a,b,c,d,e){_D(a);_D(b);_D(c);_D(d);_D(e);if(_DD)cout<<'\n';}
#define DBG6(a,b,c,d,e,f){_D(a);_D(b);_D(c);_D(d);_D(e);_D(f);if(_DD)cout<<'\n';}
#define PB push_back
#define EB emplace_back
#define btoe(v) (v).begin(),(v).end()
#define etob(v) (v).rbegin(),(v).rend()
#define F first
#define S second
#define SZ size()

typedef unsigned long long int ulli;
typedef long long int lli;
typedef long double ldbl;
#define f(i,a,b) for(int i=(a); i<(b); ++i)
#define fr(i,a,b) for(int i=(a); i>(b); --i)
#define fl(i,a,b) for(lli i=(a); i<(b); ++i)
#define flr(i,a,b) for(lli i=(a); i>(b); --i)
#define w(x) lli x; cin>>x; while(x--)
#define inpn(n,v,T) T n; cin>>n; vector<T> v(n); fl(i,0,n) cin>>v[i];
#define inp(n,v,T) vector<T> v(n); fl(i,0,n) cin>>v[i];

typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<pii> vpii;typedef vector<vector<pii>> vvpii;typedef pair<lli,lli> plli;typedef vector<lli> vlli;typedef vector<vlli> vvlli;typedef vector<plli> vplli;typedef vector<vector<plli>> vvplli;typedef vector<bool> vb;typedef vector<vb> vvb;typedef vector<string> vs;typedef vector<vector<string>> vvs; typedef vector<char> vc; typedef vector<vc> vvc;
#define unmp unordered_map

const lli PRIME = 1000000007ll;
const lli PRIME2 = 998244353ll;

inline void debugORfast(bool a=0,bool b=1){
    if(a) _DD=1;
    if(b){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
}

//Question Link

int main(int argc,char* argv[])
{
    if(argc>1 and strcmp(argv[1],"1")==0) debugORfast(1,1);
    else debugORfast(0,1);

	int x,y; cin>>x>>y;
	if(x>y) swap(x,y);
	if(y-x<3) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

    return 0;
}

#include <iostream>
int a[100];
int b[100];
int used[200];
int main() {
    int n;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i] >> b[i];
        if (a[i] != -1) ++used[a[i] - 1];
        if (b[i] != -1) ++used[b[i] - 1];
        if (a[i] != -1 and b[i] != -1 and a[i] >= b[i]) {
            std::cout << "No\n";
            return 0;
        }

        if (a[i] != -1 and used[a[i] - 1] == 2) {
            std::cout << "No\n";
            return 0;
        }

        if (b[i] != -1 and used[b[i] - 1] == 2) {
            std::cout << "No\n";
            return 0;
        }
    }
    int ilen, jlen, idx;
    for (int i = 0; i < n; ++i) {
        for (int j = i - 1; j < n; ++j) {
            if (i == j) continue;
            if (j < 0) continue;
            if (a[i] == -1 or b[i] == -1) continue;
            if (a[i] <= a[j] and a[j] <= b[i] and a[i] <= b[j] and b[j] <= b[i]) {
                std::cout << "No\n";
                return 0;
            }

            if (b[j] != -1) {
                if (a[i] <= a[j] and a[j] <= b[i]) {
                    ilen = b[i] - a[i] + 1;
                    jlen = b[j] - a[j] + 1;
                    if (ilen != jlen) {
                        std::cout << "No\n";
                        return 0;
                    }
                }
            } else {
                if (a[i] <= a[j] and a[j] <= b[i]) {
                    ilen = b[i] - a[i];
                    idx = a[j] + ilen - 1;
                    if (idx < 0 or 2 * n <= idx or used[idx] == 1) {
                        std::cout << "No\n";
                        return 0;
                    }
                }
            }

            if (a[j] != -1) {
                if (a[i] <= b[j] and b[j] <= b[i]) {
                    ilen = b[i] - a[i] + 1;
                    jlen = b[j] - a[j] + 1;
                    if (ilen != jlen) {
                        std::cout << "No\n";
                        return 0;
                    }
                }
            } else {
                if (a[i] <= b[j] and b[j] <= b[i]) {
                    ilen = b[i] - a[i];
                    idx = b[j] - ilen - 1;
                    if (idx < 0 or 2 * n <= idx or used[idx] == 1) {
                        std::cout << "No\n";
                        return 0;
                    }
                }
            }
        }
    }
    std::cout << "Yes\n";
}


#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>
#include <climits>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
//#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define mkp make_pair
#define no {cout << "NO\n"; return;}

void solve() {
    int n; cin >> n;
    vector <int> ans;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ans.pb(i);
            ans.pb(n / i);
        }
    }
    if (ans[ans.size() - 1] == ans[ans.size() - 2])
        ans.pop_back();
    sort(all(ans));
    for (int x : ans)
        cout << x << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

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

vector<ll> divisors (ll n) {
  vector<ll> dest;
  for (ll i = 1; i < floor(pow(n, 0.5) + 1); i++) {
    if (n % i == 0) {
      dest.push_back(i);
      if (floor(n / i) != i) {
        dest.push_back(floor(n / i));
      }
    }
  }
  sort(dest.begin(), dest.end());
  return dest;
}

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

  auto ans = divisors(n);
  for (ll i = 0; i < (ll)ans.size(); i++) {
    cout << ans[i] << endl;
  }

}


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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int n;
vector<int>v;
string s;

int cache[20][200];

int dp(int i, int sum)
{
    if(i == n)
    {
        if(sum%3 == 0)
            return 0;
        else
            return 1e6;
    }
    int &ans = cache[i][sum];
    if(ans != -1)
        return ans;

    ans = 0;
    int add = s[i] - '0';
    ans = min(dp(i+1, sum+add), 1 + dp(i+1, sum));

    return ans;

}

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

    memset(cache, -1, sizeof(cache));

    cin>>s;
    n = s.size();
    int ans = dp(0, 0);
    if(ans == n)
        cout<<-1;
    else
        cout<<ans;
    return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

#define INF LLONG_MAX/5
#define MOD 1000000007
#define pi 3.14159265358979
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define enld endl

void vout(vector<int>A) {
	rep(i, A.size()) {
		cout << A[i];
		if (i == A.size() - 1) {
			cout << endl;
		}
		else {
			cout << ' ';
		}
	}
}

void vvout(vector<vector<int>>A) {
	rep(i, A.size()) {
		rep(j, A[i].size()) {
			cout << A[i][j];
			if (j == A[i].size() - 1) {
				cout << endl;
			}
			else {
				cout << ' ';
			}
		}
	}
}

signed main() {
	vector<int>V(4);
	rep(i, 4) {
		cin >> V[i];
	}

	int N = 4;
	for (int S = 0; S < 1 << N; S++) {
		//作成
		vector<int>A;
		rep(i, N) {
			A.push_back(S >> i & 1);
		}
		int ans = 0;
		//操作
		rep(i, 4) {
			if (A[i] == 1) {
				ans += V[i];
			}
		}
		if (ans == V[0] + V[1] + V[2] + V[3] - ans) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
//bool vis[1000];
//int x[]={1,-1,0,0};
//int y[]={0,0,1,-1};
//int f=0;
//"'';
ll a,b,k;
ll util(ll a,ll b){
ll dp[a+b+1][a+b+1];
memset(dp,-1,sizeof(dp));
for(int i=0;i<=a+b;i++){
    for(int j=0;j<=i;j++){
        if(j==0||j==i){
            dp[i][j]=1;
            continue;
        }
        dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
        if(dp[i][j]<0){
            return 1e18;
        }
    }
}
return dp[a+b][a];
}
int main() {
cin>>a>>b>>k;
string ans;
while(a>0||b>0){
    ll s=0;
    //cout<<a<<" "<<b<<" "<<k<<endl;
    if(a>0){
        ll z=util(a-1,b);
        s=z;
    }
    //cout<<s<<endl;
    if(s>=k){
        ans.push_back('a');
        a=a-1;
        continue;
    }
    else{
       ans.push_back('b');
       b=b-1;
       k=k-s;
    }

}
cout<<ans<<endl;
}

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

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int H,W,N,M; cin>>H>>W>>N>>M;
    vector<int> A(N),B(N),C(M),D(M);
    rep(i,N)cin>>A[i]>>B[i];
    rep(i,M)cin>>C[i]>>D[i];
    vector<vector<char>> S(H,vector<char>(W,'.'));
    rep(i,N)S[A[i]-1][B[i]-1]='l';
    rep(i,M)S[C[i]-1][D[i]-1]='#';
    vector<vector<int>> E(H,vector<int>(W,0));//(i,j)の上方向に電球があるかどうか
    vector<vector<int>> F(H,vector<int>(W,0));//(i,j)の下方向に電球があるかどうか
    rep(i,W){
        rep(j,H){
            if(S[j][i]=='l')E[j][i]=1;
            else if(S[j][i]=='.'){
                if(j>0){
                    E[j][i]=E[j-1][i];
                }
            }
        }
        for(int j = H-1; j >= 0; j--){
            if(S[j][i]=='l')F[j][i]=1;
            else if(S[j][i]=='.'){
                if(j<H-1){
                    F[j][i]=F[j+1][i];
                }
            }
        }
    }
    vector<vector<int>> G(H,vector<int>(W,0));
    vector<vector<int>> I(H,vector<int>(W,0));
    rep(i,H){
        rep(j,W){
            if(S[i][j]=='l')G[i][j]=1;
            else if(S[i][j]=='.'){
                if(j>0){
                    G[i][j]=G[i][j-1];
                }
            }
        }
        for(int j = W-1; j >= 0; j--){
            if(S[i][j]=='l')I[i][j]=1;
            else if(S[i][j]=='.'){
                if(j<W-1){
                    I[i][j]=I[i][j+1];
                }
            }
        }
    }
    int res = 0;
    rep(i,H){
        rep(j,W){
            if(E[i][j]==1||F[i][j]==1||G[i][j]==1||I[i][j]==1)res++;
        }
    }
    cout<<res<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define inf 1000000000
#define pii pair<int,int>
#define fi first
#define se second
signed main(){
    fastio
    int t;
    //cin>>t;
    t=1;
    while(t--){
        int v,t,s,d;
        cin>>v>>t>>s>>d;
        int l=v*t,r=v*s;
        if(d>=l && d<=r)cout<<"No\n";
        else cout<<"Yes\n";
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define ull               unsigned long long
#define si(x)             int x;cin>>x;
#define w(x)              si(x); while(x--)
#define fo(i,n)           for(int i=0 ; i<n ; i++)
#define rea(a,n)          int a[n];fo(i,n){cin>>a[i];}
#define rea2d(a,n,m)      int a[n][m];fo(i,n){fo(j,m){cin>>a[i][j];}}
#define pra(a,n)          fo(i,n){cout<<a[i]<<" ";}
#define prv(a,n)          for (auto i = a.begin(); i != a.end(); ++i){cout<<*i<<" ";}
#define prg(a,n)          for (auto ir = a.rbegin(); ir != a.rend(); ++ir){cout<<*i<<" ";}
#define pb                push_back
#define mkp               make_pair
#define F                 first
#define S                 second
#define all(v)            v.begin(),v.end()
#define e                 endl
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef deque<pii> dpii;
typedef unordered_map<int,int> um;
// int max 2147483647
void solution()
{
	si(v);si(t);si(s);si(d);
	int q=d/v;
	if(d>=v*t&&d<=v*s){cout<<"No";}
  	else cout<<"Yes";
}

int32_t main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // w(t){
    //     solution();
    // }
    solution();
    return 0;

}


#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
#define ll long long int
#define pb push_back
#define fo(i, n) for (int i = 0; i < n; i++)
#define vct vector<long long int>
const ll INF = 1e18;
const ll NINF = -1e18;
#define f first
#define s second

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, a,b,c;
    cin>>n;
    vector<ll>v;
    for (int i = 0; i < 65; i++)
    {
        // cout<<i<<endl;
        ll z = pow(2, i);
        if(n>=z){

           c = n%z;
           b = i;
           a = (n-c)/z;
           v.pb(a+b+c);
        }
        else {
            break;
        }
    }
    sort(v.begin(), v.end());
    cout<<v[0]<<endl;

    return 0;
}

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    bool first;
    if (N % 2 == 1) {
	first = false;
    } else {
	sort(A, A+N);
	first = false;
	for (int i=0; i<N; i+=2) {
	    if (A[i] != A[i+1]) first = true;
	}
    }

    puts(first? "First": "Second");
}

int main() {
    int TC = 1;
    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}


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

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first
#define sec second
#define DEBUG 0
#define MAXN 1001
#define mod 1000000007
#define eps 1e-9

int n, m;
vector<int> v;
vector<int> k;
int dp[MAXN][MAXN];

int solve(int i, int j)
{
  if (i == n)
  {
    return m - j;
  }
  if (j == m)
  {
    return n - i;
  }
  if (dp[i][j] != -1)
  {
    return dp[i][j];
  }
  int ret = LLONG_MAX;
  ret = (v[i] != k[j]) ? min(ret, 1 + solve(i + 1, j + 1)) : min(ret, 0 + solve(i + 1, j + 1));
  ret = min(ret, 1 + solve(i + 1, j));
  ret = min(ret, 1 + solve(i, j + 1));
  return dp[i][j] = ret;
}
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  v.resize(n);
  k.resize(m);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  for (int i = 0; i < m; i++)
    cin >> k[i];
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0) << endl;
  return 0;
}
// 1 2 1 3
// 1 3 1

// 1 2 1
// 1 3 1

// 1 elemento removido
// apenas 1 par de indices que os caras sao diferentes
// ans = 2

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << " " << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	rep(i, v.size()) {
		if (i) os << " ";
		os << v[i];
	}
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
#ifdef LOCAL
#define dbg(x) cerr << #x << ": " << (x) << '\n'
#define say(x) cerr << (x) << '\n'
#else
#define dbg(x)
#define say(x)
#endif
string solve(bool a) { return ((a) ? "Yes" : "No"); }
int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll b, c, ans = 0LL;
	cin >> b >> c;
	P left, right;
  if(c==0LL){
  	cout<<1<<endl;
    return 0;
  }
  if(c==1LL){
  	if(b==0LL){
      cout<<1<<endl;
  }else{
    cout<<2<<endl;}
    return 0;
  }
  P cost;
	left.F  = -b - (c - 1) / 2;
	right.F = b - c / 2;
  cerr<<left.F<<" "<<right.F<<'\n';
  cost=mp(abs(-b-left.F)*2+1,abs(b-right.F)*2);
  cerr<<cost<<'\n';
  /*
	if (c % 2 == 0) {
		left.S  = -right.F + 1;
		right.S = -left.F;
	} else {
		left.S  = -right.F;
		right.S = -left.F - 1;
	}
    */
  if(c >cost.F){
  	right.S=-left.F;
  }else{
  	right.S=-left.F-1;
  }
  if(c > cost.S){
  	left.S=-right.F;
  }else
  {
    left.S=-right.F-1;
  }
  	if(left.F >left.S){
    	swap(left.F,left.S);
    }
  if(right.F >right.S){
    swap(right.F,right.S);
  }
	 if (left.F <= right.S && right.F <= left.S) {
		ans = abs(min({left.F, left.S,right.F, right.S})-max({left.F, left.S,right.F, right.S}))+1;
       cerr<<"one"<<endl;
	} else {
		ans = abs(right.F - right.S) + abs(left.F - left.S)+2;
	}
  cerr<<left<<right<<endl;
	cout << ans << endl;
}
// https://atcoder.jp/contests/arc112/tasks/arc112_b
/*
[(r-1/2)-B   (r-1/2)+1-B -B     -(r/2)+1-B]   0        [-r/2+B    (r/2)-1+B B
(-(r-1/2)-1 )+B]
[-D-1          -D ...    -B   ... -E] ...  0 ... [      E-1       E ...    B ...
D] 1                      c(r2)  c-2(r2)     0     c(r2)
*/
/*
B-c/2 B
-B-(c-1)/2 -B
*/


#include <bits/stdc++.h>
using namespace std;
const double PI  = acos(-1.0);
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main()
{

    int A, B;
    cin >> A >> B;
    cout << (A + B)/2 << " ";
    cout << (A - B)/2;
    return 0;
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll=long long;
using ld=long double;
//using mint = modint1000000007;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo 2e18
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
//priority_queue<ll, vector<ll>, greater<ll>> Q;
/*
1 = 1
2 = 1,2
3= 1,3
4 = 1,2,4
5 = 1,5
6=1,2,3,6
10^18まで
NlogN
10^9までになっちゃう

8 = 1,2,4,8 = 2^3
10 = 2,5 2とそれ以外の組み合わせが偶数個数
36 = 2,2,3,3= {2,2}{1,3,3}
*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(10);

  ll T;
  cin >> T;
  rep(i, T){
    ll N;
    cin >> N;
    ll two = 0;
    while (N%2 == 0){
      N/= 2;
      two++;
    }
  if (two == 1)
    cout << "Same" << endl;
  else if (two == 0)
    cout << "Odd" << endl;
  else
    cout << "Even" << endl;
  }
}


#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	long long int n;
	cin >> n;
	long long int half = (long long int)(sqrt(n)+1);
	long long int i;
	long long int count = 0;
	vector<long long int> v(0);
	vector<long long int> u(0);
	for (i = 1; i < half; i++) {
		if (n % i == 0) {
			v.push_back(i);
			if (n / i == i) {
				count = count + 1;
			}
			else {
				u.push_back(n / i);
				count = count + 2;
			}
		}
	}

	reverse(u.begin(), u.end());
	copy(u.begin(), u.end(), back_inserter(v));
	for (i = 0; i < count; i++) {
		cout << v[i]<<"\n";
	}

	return 0;
}

#include<iostream>
using namespace std;
int sum(int x)
{
	int ans=0;
	for(int j=2;j<x;j++)
	{
		int s=0;
		if(x%j==0)
		{
			while(x%j==0) x/=j,s++;
		}
		ans+=s;
	}
	if(x>1)	ans++;
	return ans;
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(n==1)
		cout<<"1";
		else
		{
			cout<<" "<<sum(i)+1;
		}
	}
}


#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,cc,n) for(int i=cc;i<(n);++i)
#define dreps(i,cc,n) for(int i=cc;i>(n);--i)
#define llreps(i,cc,n) for(long long i=cc;i<(n);++i)
#define ALL(v) begin(v),end(v)
#define rALL(v) rbegin(v),rend(v)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

int main()
{
	string s;
	cin >> s;
	stack<char> st;
	rep(i, s.length())
	{
		char ch = s[i];
		if (ch == '6')
			ch = '9';
		else if (ch == '9')
			ch = '6';
		st.push(ch);
	}
	string ans = "";
	while(!st.empty())
	{
		ans += st.top();
		st.pop();
	}
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	string s;
	cin>>s;
	string st;
	for(int i=0;i<n;i++)
	{
		st.pb(s[i]);
		int l = sz(st);
		if(l >= 3)
		{
			if(st.substr(l-3,3) == "fox")
			{
				st.pop_back();
				st.pop_back();
				st.pop_back();
			}
		}
	}
	cout<<sz(st)<<"\n";
	return 0;
}


#include<bits/stdc++.h>

#define ll              long long
#define pb              push_back
#define ff              first
#define ss              second
#define mp              make_pair

#define scan(a)         scanf("%d", &a)
#define scanl(a)        scanf("%lld", &a)
#define scand(a)        scanf("%lf", &a)
#define scan2(a, b)     scanf("%d %d", &a, &b)
#define scanl2(a, b)    scanf("%lld %lld", &a, &b)
#define scand2(a, b)    scanf("%lf %lf", &a, &b)

#define yes             cout << "yes\n"
#define no              cout << "no\n"
#define Case(i)         cout << "Case " << int(i) << ": "

#define lop(n)          for(int i = 0; i < n; i++)
#define lopj(n)         for(int j = 0; j < n; j++)
#define loop(k, a, b)   for(int k = a; k < b; k++)
#define loopr(j, b, a)  for(int j = b; j >= a; j--)
#define lopc(i, a, b, c) for(int i = a; i < b; i += c)

#define all(x)          x.begin(), x.end()
#define sorta(x)        sort(x.begin(), x.end())
#define sortd(x)        sort(x.rbegin(), x.rend())
#define mem0(a)         memset(a, 0, sizeof(a))
#define mem1(a)         memset(a, -1, sizeof(a))

#define vin             vector <int>
#define vll             vector <ll>
#define vst             vector <string>
#define pll             pair <ll, ll>
#define pss             pair <string, string>
#define vpll            vector <pll>

#define fread           freopen("input.txt", "r", stdin)
#define fwrite          freopen("output.txt", "w", stdout)
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define mod             (const int) 1e9+7
#define PI              acos(-1.0)
#define inf             (1 << 61)
#define N               (const int) 1e6+5

using namespace std;

int main()
{
	fastio;

	int tt, n;

	cin >> n;
	int a[n], c = 0, ans = 0, k = 0;
	lop(n) cin >> a[i];

	for (int i = 2; i < 1002; i++)
	{
		c = 0;

		for (int j = 0; j < n; j++)
			if (a[j] % i == 0)
				c++;

		if (c > k)
			ans = i, k = c;

	}

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

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

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

    int N; cin >> N;
    vector<int> A(N);
    for(auto& a : A) cin >> a;
    int mx = 0, ans;
    for(int i = 2; i <=1000; i++){
        int cnt = 0;
        for(int j = 0; j < N; j++){
            if(A[j] % i == 0){
                cnt++;
            }
        }
        if(mx < cnt){
            mx = cnt;
            ans = i;
        }
    }
    cout << ans << '\n';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int read(){
    int x = 0, f = 1; char ch;
    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);
    for(x = ch ^ 48 ; isdigit(ch = getchar()) ; x = (x << 3) + (x << 1) + (ch ^ 48));
    return x * f;
}
const int N = 1e6 + 9, p = 998244353;
int a[N],s[N];
int my_pow(int a,int b){
    int ans = 1, base = a;
    while(b){
        if(b & 1) ans = ans * base % p;
        base = base * base % p;
        b >>= 1;
    } return ans;
}
signed main(){
    int n = read(), ans = 0;
    for(int i = 1 ; i <= n ; i ++) a[i] = read();
    sort(a + 1,a + n + 1);
    for(int i = 1 ; i <= n ; i ++) s[i] = my_pow(2,i) * a[i] % p;
    for(int i = n ; i >= 1 ; i --) s[i] += s[i + 1], s[i] %= p;
    for(int i = 1 ; i <= n ; i ++){
        ans += a[i] * my_pow(my_pow(2,i + 1),p - 2) % p * s[i + 1] % p;
        ans += a[i] * a[i] % p, ans %= p;
    } cout<<ans<<"\n";
    return 0;
}

/* dont stick to an approach */
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <chrono>

using namespace std;
using namespace std::chrono;

typedef long long ll;
typedef unsigned long long int ull;
typedef long double ldb;

#define PB push_back

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

#define trav(a,x) for (auto& a : x)

#define PYES cout<<"YES\n"
#define PNO cout<<"NO\n"
#define PYes cout<<"Yes\n"
#define PNo cout<<"No\n"
#define endl '\n'

#define sq(x)           (x*x)

#define vll             vector<ll>
#define rev(v)          reverse(v.begin(),v.end())
#define srt(v)          sort(v.begin(),v.end())
#define grtsrt(v)       sort(v.begin(),v.end(),greater<int>())
#define mnv(v)          *min_element(v.begin(),v.end())
#define mxv(v)          *max_element(v.begin(),v.end())
#define all(v)          v.begin(),v.end()

#define Fas ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

ll M= 998244353;

//--------------------------------------------functions-------------------------------------------------//

ll power(ll a,ll b){ll result=1;while(b>0){if(b%2 == 1){result *= a;} a *= a;b /= 2;}return result;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
ll countSetBits(ll x){ll Count=0;while(x>0){if(x&1) Count++;x=x>>1;}return Count;}
bool isPerfectSquare(ll n){ll sr = sqrt(n);if (sr * sr == n)return true;else return false;}
ll mod(ll x){return ((x%M + M)%M);}
ll add(ll a, ll b){return mod(mod(a)+mod(b));}
ll mul(ll a, ll b){return mod(mod(a)*mod(b));}
ll powerM(ll a,ll b){ll res=1;while(b){if(b%2==1){res=mul(a,res);}a=mul(a,a);b/=2;}return res;}
//------------------------------------sieve of erantothenes-----------------------------------------------//
//ll MAXN=100001;
//vector<ll> fact(MAXN);
//void sieve_of_erantothenes()
//{
//    fact[1] = 1;
//    for (ll i = 2; i <= MAXN; i++)
//        fact[i] = i;
//    for (ll i = 4; i <= MAXN; i += 2)
//        fact[i] = 2;
//    for (ll i = 3; i * i <= MAXN; i++){
//        if (fact[i] == i){
//            for (ll j = i * i; j <= MAXN; j += i)
//                if (fact[j] == j)
//                    fact[j] = i;
//        }
//    }
//}
//----------------------------------------nCr mod------------------------------------------------------//
ll modInverse(ll n){
    return powerM(n,M-2);
}
ll nCrM(ll n,ll r){
    if(n<r) return 0;
    if(r==0) return 1;
    vector<ll> fact(n+1);
    fact[0]=1;
    for(ll i=1;i<=n;i++){
        fact[i]=mul(fact[i-1],i);
    }
    return mul(mul(fact[n],modInverse(fact[r])),modInverse(fact[n-r]));
}
//-----------------------------------------------solve-----------------------------------------------------//
void solve() {
    ll n;cin>>n;
    vll v(n);
    trav(w, v) cin>>w;
    srt(v);
    ll ans;
    if(n>1){
        ll right=v[0];
        ans=mul(v[0],v[1]);
        for(ll i=1;i<n-1;i++){
            right=add(v[i],mul(2,right));
            ans=add(ans,mul(v[i+1],right));
        }
        for(ll i=0;i<n;i++){
            ans=add(ans,mul(v[i],v[i]));
        }
    }else{
        ans=mul(v[0],v[0]);
    }
    cout<<ans<<endl;
}

int main(){
    Fas;
//    ll t=0;
//    cin>>t;
//    while (t--)
        solve();

    return 0;
}


// #pragma GCC optimize("Ofast")

#include <vector>
#include <iostream>
#include <utility>
#include <cmath>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int,int> pii;
// #define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; ++i)
#define REP(i,n) for(int i = 0;i < (n) ; ++i)
#define MP(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
inline unsigned long long xor128() {
	static unsigned long long rx = 123456789, ry = 986960440, rz = 738905609, rw = 23140692;
	unsigned long long rt = (rx ^ (rx << 11));
	rx = ry;ry = rz;rz = rw;
	return (rw = (rw ^ (rw >> 19)) ^ (rt ^ (rt >> 8)));
}
inline float rand128(float min = 0, float max = 1){
	return (float)(xor128() % 0xFFFF) / 0xFFFF * (max - min) + min;
}

inline uint64_t rdtsc(){
	uint32_t hi,lo;
	__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
	return ((uint64_t)lo) | (((uint64_t)hi)<<32);
}
inline double GetSeconds() {
	// return rdtsc()/2.8e9; //Topcoder
	return rdtsc()/3.0e9; // Atcoder
}
double start_time;
const double TL = 1.90;
/*----------------------------------------------------------------*/

/*----------------------------------------------------------------*/
int h[30][29];
int v[29][30];

const int Q = 1000;
const int H = 30;
const int W = 30;

/*----------------------------------------------------------------*/
void input(){
	cerr << "in h" << endl;
	cerr << H << endl;
	cerr << W << endl;
	rep(i,H)rep(j,W-1){
		cin >> h[i][j];
		cerr << h[i][j] << endl;
	}
	cerr << "in v" << endl;
	rep(i,H-1)rep(j,W)cin >> v[i][j];
}

void solve(){
	cerr << "solve" << endl;
    int si,sj,ti,tj,a;
	rep(q,Q){
        cin >> si >> sj >> ti >> tj;
        if(si > ti)rep(i,si-ti)cout << 'U';
        if(ti > si)rep(i,ti-si)cout << 'D';
        if(sj > tj)rep(i,sj-tj)cout << 'L';
        if(tj > sj)rep(i,tj-sj)cout << 'R';
        cout << endl;
        cin >> a;
    }
}

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

int main(){
	cerr << "s" << endl;
	start_time = GetSeconds();
	solve();
}

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

using vi = vector<int>;
#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)
#define sz(v) (int)v.size()
const int INF = 1000000001;

int main() {
    vi _r{-1, 0, 1, 0};
    vi _c{0, 1, 0, -1};
    vector<char> _d{'U', 'R', 'D', 'L'};
    map<char, int> _q;
    _q['U'] = 0;
    _q['R'] = 1;
    _q['D'] = 2;
    _q['L'] = 3;
    vector<vector<vector<double>>> g(30, vector<vector<double>>(30, vector<double>(4, 5000.0)));
    REP(i, 30) {
        g[i][0][3] = -1.0;
        g[i][29][1] = -1.0;
    }
    REP(i, 30) {
        g[0][i][0] = -1.0;
        g[29][i][2] = -1.0;
    }
    int si, sj, ti, tj;
    double score;
    string ans;

    auto trueSearch = [&]() {
        deque<tuple<int, int, double, string>> q;
        q.emplace_back(si, sj, 0.0, "");
        int r, c;
        double d;
        string m;
        vector<vector<double>> h(30, vector<double>(30, INF));
        h[si][sj] = 0.0;
        while (!q.empty()) {
            tie(r, c, d, m) = q.front();
            q.pop_front();

            if (r == ti and c == tj) {
                ans = m;
                continue;
            }

            REP(i, 4) {
                if (g[r][c][i] < 0.0) continue;
                if (g[r][c][i] + d >= min(h[ti][tj], h[r + _r[i]][c + _c[i]])) continue;
                h[r + _r[i]][c + _c[i]] = g[r][c][i] + d;
                q.emplace_back(r + _r[i], c + _c[i], g[r][c][i] + d, m + _d[i]);
            }
        }
        cout << ans << endl;
        cin >> score;
        return h[ti][tj];
    };

    auto horizontalSearch = [&]() {
        double actual = 0.0;
        int r = si;
        int c = sj;
        while (c < tj) {
            actual += g[r][c][1];
            ans += 'R';
            c++;
        }
        while (c > tj) {
            actual += g[r][c][3];
            ans += 'L';
            c--;
        }
        while (r < ti) {
            actual += g[r][c][2];
            ans += 'D';
            r++;
        }
        while (r > ti) {
            actual += g[r][c][0];
            ans += 'U';
            r--;
        }

        cout << ans << endl;
        cin >> score;
        return actual;
    };

    auto virticalSearch = [&]() {
        double actual = 0.0;
        int r = si;
        int c = sj;
        while (r < ti) {
            actual += g[r][c][2];
            ans += 'D';
            r++;
        }
        while (r > ti) {
            actual += g[r][c][0];
            ans += 'U';
            r--;
        }
        while (c < tj) {
            actual += g[r][c][1];
            ans += 'R';
            c++;
        }
        while (c > tj) {
            actual += g[r][c][3];
            ans += 'L';
            c--;
        }

        cout << ans << endl;
        cin >> score;
        return actual;
    };

    REP(i, 1000) {
        cin >> si >> sj >> ti >> tj;

        ans = "";
        auto actual = (i < 80 ? horizontalSearch() : (i < 160 ? virticalSearch() : trueSearch()));

        int l = sz(ans);
        double coefficient = score / actual;
        coefficient = (1.1 + coefficient) / 2.0;
        int r = si;
        int c = sj;
        REP(i, l) {
            int d = _q[ans[i]];
            g[r][c][d] *= coefficient;
            r += _r[d];
            c += _c[d];
            g[r][c][(d + 2) % 4] *= coefficient;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#include <bits/extc++.h>
#define double long double
#define rbtree __gnu_pbds::tree<int,__gnu_pbds::null_type,less<int>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>
#define int ll
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define pb push_back
#define ALL(X) X.begin(),X.end()
#define F(i,n)  FF(i,0,n)
#define F1(i,n)  FF(i,1,n+1)
#define FF(i,n,m) for(int i=(int)n;i<(int)m;++i)
#ifndef LOCAL
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#else
#endif // LOCOL
//#define mp make_pair
using namespace std;
//using namespace __gnu_pbds;
template<typename T> bool remax(T& a, const T& b) {return b>a?a=b,1:0;}
template<typename T> bool remin(T& a, const T& b) {return b<a?a=b,1:0;}
inline ostream& operator << (ostream& os,__int128_t a){if(a==0) {return (os<<'0');}bool flag=0;if(a<0) {a=-a,flag=1;}string s;while(a){s+=a%10+'0';a/=10;}s+=flag?"-":"";reverse(ALL(s));return os<<s;}
inline istream& operator >>(istream& is,__int128_t& a){string s;cin>>s;a=0;for(auto c:s) a=a*__int128_t(10)+__int128_t(c-'0');return is;}
template<typename T,typename P> inline ostream& operator << (ostream& os,pair<T,P> a){os<<a.first<<" "<<a.second; return os;}
template<typename T,typename P> inline istream& operator >> (istream& is,pair<T,P> &a){is>>a.first>>a.second; return is;}
using ll=long long;
using ull=unsigned long long;
using int128= __int128_t;
using uint128= __uint128_t;
using pii =pair<int,int>;
const double pi=acos(-1);
const int N=2E6+5;
const ll M=1000000000;
const ll INF_64=0x3f3f3f3f3f3f3f3f;
const int INF_32=0x3f3f3f3f;
const int16_t INF_16=0x3f3f;
const int klog=20;
const int mod=1E9+7;//998244353
const double eps=1E-8;
void gen(){

}
template <class T>
T qpow(T base,ll power){
    T re=base,tmp=base;
    power--;
    while(power){
        if(power&(1LL)){
            re=re*tmp;re%=mod;
        }
        power>>=1;
        tmp=tmp*tmp;tmp%=mod;
    }
    return re;
}
int pw[N]{};
int invp[N]{};
int val(int n,int m){
    if(n<0||m<0) return 0;
    return pw[n+m]*invp[n]%mod*invp[m]%mod;
}
void sol(){
    pw[0]=1;
    F1(i,N-1) pw[i]=pw[i-1]*i%mod;
    F(i,N) invp[i]=qpow(pw[i],mod-2);
    int n,m,k;cin>>n>>m>>k;
    if(n>m+k){
        cout<<"0\n";
        return;
    }
    int an=val(n,m);
    int sub=val(n-k-1,m+k+1);
    cout<<((an-sub)%mod+mod)%mod<<"\n";
}
int32_t main(){
    #ifdef LOCAL
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    #endif // LOCAL
    IOS;
    int t=1;
    gen();
    //cin>>t;
    FF(i,1,t+1){
        //cout<<"Case #"<<i<<": ";
        sol();
    }
}

#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

const ll MOD = 998244353;

// auto mod int
// ref. https://github.com/atcoder-live/library/blob/master/mint.cpp
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

vector<mint> as;

vector<mint> bs;

vector<mint> factorial;

vector<mint> sum_diagonal;

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

    as.resize(N);
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        as[i] = mint(x);
    }

    factorial.resize(K + 1);
    factorial[0] = mint(1);
    {
        mint acc = mint(1);
        for (int i = 1; i <= K; i++) {
            acc *= i;
            factorial[i] = acc;
        }
    }

    bs.resize(K + 1);
    {
        for (int i = 0; i < N; i++) {
            mint base = as[i];
            mint acc = mint(1);
            for (int x = 0; x <= K; x++) {
                bs[x] += acc;
                acc *= base;
            }
        }
    }

#ifdef DEBUG
    printf("bs: \n");
    for (int i = 0; i <= K; i++) {
        printf("%lld\n", bs[i].x);
    }
    printf("\n");
#endif

    sum_diagonal.resize(K + 1);
    {
        for (int i = 0; i < N; i++) {
            mint base = as[i] * 2;
            mint acc = mint(1);
            for (int x = 0; x <= K; x++) {
                sum_diagonal[x] += acc;
                acc *= base;
            }
        }
    }

    {
        for (int x = 1; x <= K; x++) {
            mint acc = mint(0);
            for (int y = 0; y <= x; y++) {
                acc += (bs[y] / factorial[y]) * (bs[x - y] / factorial[x - y]);
            }
            acc *= factorial[x];
            acc -= sum_diagonal[x];
            acc /= 2;
            printf("%lld\n", acc.x);
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
void __print(int x){cout<<x;}void __print(long x){cout<<x;}
void __print(long long x){cout<<x;}void __print(unsigned x){cout<<x;}
void __print(unsigned long x){cout<<x;}void __print(unsigned long long x){cout<<x;}
void __print(float x){cout<<x;}void __print(double x){cout<<x;}
void __print(long double x){cout<<x;}void __print(char x){cout<<'\''<<x<<'\'';}
void __print(const char *x){cout<<'\"'<<x<<'\"';}void __print(const string &x){cout<<'\"'<<x<<'\"';}
void __print(bool x) {cout<<(x?"true":"false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define lp(i,a,b)       for (int i=a;i<=b;i++)
#define rp(i,a,b)       for (int i=a;i>=b;i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define int             long long
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        (((a)*(b))/(gcd(a,b)))
#define sq(a)           ((a)*(a))
#define sz(a)           (int) a.size()
#define mod             998244353
#define PI              (2*acos(0.0))

const int N=1e6+5;
int cnt[N],A[N],ex[N];

void solve()
{
  int l,r;
  cin>>l>>r;
  lp(i,l,r)
    cnt[i]++;
  for(int i=1;i<N;i++)
  {
    int sum=0;
    for(int j=i;j<N;j+=i)
    {
      sum=(sum+cnt[j]);
    }
    A[i]=sum;
  }
  int now=r-l+1;
  int ans=(now*(now-1));
  for(int i=N-1;i>=1;i--)
  {
    ex[i]=(A[i]*(A[i]-1));
    //if(ex[i]>0)
    {
    for(int j=i+i;j<N;j+=i)
      ex[i]=(ex[i]-ex[j]);
    }
  }
  ans-=ex[1];
  if(l==1) l++;
  lp(i,l,r)
  {
    for(int j=i+i;j<=r;j+=i)
      ans-=2;
  }
  cout<<ans;
}

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int T=1;
  //cin>>T;
  while(T--) solve();
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vi = vector<ll>;
int main () {
  int L, R;
  cin >> L >> R;
  Vi num(R + 10, 0);
  bool db[1000100];
  for (int i = 0; i <= R; i ++) {
    db[i] = true;
  }
  ll ans = 0;
  for (int i = 2; i <= R; i ++) {
    if (db[i]) {
      ll kj = (R / i) - ((L - 1) / i);
      kj = kj * (kj - 1);
      kj /= 2;
      ll x = 1;
      if (num[i] > 0 && num[i] % 2 == 0) x = -1;
      ans += kj * x;
    }
    if (num[i] == 0) {
      //cout << i << endl;
      for (int j = 2; j * i <= R; j ++) {
        num[i * j] ++;
      }
      if (i <= 1010) {
        for (int j = 1; j * i * i <= R; j ++) {
          db[i * i * j] = false;
        }
      }
    }
    //cout << i << ' ' << ans << endl;
  }
  //cout << ans << endl;
  for (int i = max(2, L); i <= R; i ++) {
    ans -= R / i;
    ans ++;
  }
  cout << ans * 2 << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vc = vector<T>;
template<class T> using vvc = vc<vc<T>>;
template<class T> using vvvc = vc<vvc<T>>;
template<class T> using vvvvc = vvc<vvc<T>>;
template<class T> using PQ = priority_queue<T>;
template<class T> using invPQ = priority_queue<T, vector<T>, greater<T>>;
using IP = pair<int, int>;
using LP = pair<ll, ll>;
#define all(x) begin(x), end(x)
#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 repr(i, n) for (int i = (n) - 1; (i) >= 0; i--)
#define rep3r(i, m, n) for (int i = (n) - 1; (i) >= (int)(m); i--)
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }
// constexpr int INF = 1070000000;
// constexpr long long LINF = 4611686015206162431;
// constexpr long long MOD = 1000000007;
// constexpr long double PI = 3.1415926535897932;

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

    int N;
    cin >> N;
    vc<ll> a(N), t(N);
    rep (i, N) cin >> a[i] >> t[i];

    ll r = 1e+16, l = -1e+16;
    ll sum = 0;
    rep (i, N) {
        if (t[i] == 1) {
            l += a[i];
            r += a[i];
            sum += a[i];
        }
        else if (t[i] == 2) {
            l = max(l, a[i]);
            if (r < l) r = l;
        }
        else {
            r = min(r, a[i]);
            if (r < l) l = r;
        }
    }

    int Q;
    cin >> Q;
    rep (i, Q) {
        ll x;
        cin >> x;
        x += sum;
        if (x > r) cout << r << endl;
        else if (x < l) cout << l << endl;
        else cout << x << endl;
    }
}

#include<bits/stdc++.h>
using namespace std;
int N;
long long a;
int t;
int Q;
long long x;
long long mi=0x3f3f3f3f3f3f3f3f;
long long ma=0xcfcfcfcfcfcfcfcf;
long long add;
int main()
{
    scanf("%d",&N);
    while(N--)
    {
        scanf("%lld %d",&a,&t);
        if(t==2)
        {
            ma=max(ma,a);
            mi=max(mi,a);
            continue;
        }
        if(t==3)
        {
            ma=min(ma,a);
            mi=min(mi,a);
            continue;
        }
        mi+=a;
        ma+=a;
        add+=a;
    }
    scanf("%d",&Q);
    while(Q--)
    {
        scanf("%lld",&x);
        printf("%lld ",max(min(mi,x+add),ma));
    }
    printf("\n");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
int n,ans[11];
const int P = 1e9+  7;
char caa,cab,cba,cbb;
unordered_map<string,int>mp;
inline void dfs(string s){
	if (mp.count(s)) return;
	++ans[s.size()];
	mp[s] = 1; if (s.size() ==10){ return; }
	for (int i = 0; i < s.size()-1; ++i){
		bool s1 = s[i] == 'a' ? 1 : 0,s2 = s[i+1] == 'a' ? 1 : 0;
		if (s1&&s2) dfs(s.substr(0,i+1) + caa + s.substr(i+1,s.size()-i-1));
		else if (s1&&!s2) dfs(s.substr(0,i+1) + cab + s.substr(i+1,s.size()-i-1));
		else if (!s1&&!s2) dfs(s.substr(0,i+1) + cbb + s.substr(i+1,s.size()-i-1));
		else if (!s1&&s2) dfs(s.substr(0,i+1) + cba + s.substr(i+1,s.size()-i-1));
	}
}
inline int all1(){
	for (int i = 2; i <= 10; ++i) if (ans[i] ^ 1) return 0;
	return 1;
}
inline int pw2(){
	for (int i = 2; i <= 3; ++i) if (ans[i] ^ 1) return 0;
	for (int i = 4,now = 2; i <= 10; ++i,now *= 2) if (ans[i] ^ now) return 0;
	return 1;
}
int fib[1005];
int main(){
//	caa = 'b';
//	cab = 'b';
//	cba = 'a';
//	cbb = 'b';
	fib[2] = 1,fib[3] = 1;
	for (int i = 4; i <= 1000; ++i) fib[i] = (fib[i-1] + fib[i-2]) %P;
	cin>>n>>caa>>cab>>cba>>cbb;
	if (n<=3)cout<<1<<'\n',exit(0);
	caa -= 'A'-'a';
	cab -= 'A'-'a';
	cba -= 'A'-'a';
	cbb -= 'A'-'a';

	dfs("ab");
//	for (int i = 2; i <= 10; ++i) cout<<i<<' '<<ans[i]<<'\n';
	if (all1()) cout<<1<<'\n',exit(0);
	if (pw2()){
		int ans=  1;
		for (int i = 1; i <= n-3; ++i) ans=ans*2%P;
		cout<<ans<<'\n';exit(0);
	}
	cout<<fib[n]<<'\n';
	return 0;
}

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	if (n < 0) {
		ll res = mod_pow(x, -n, m);
		return mod_pow(res, m - 2, m);
	}
	if (abs(x) >= m)x %= m;
	if (x < 0)x += m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
modint operator/=(modint& a, modint b) { a = a / b; return a; }
const int max_n = 1 << 1;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[a - b];
}

void solve() {
	ll a, b, c; cin >> a >> b >> c;
	int ida = 1; int idb = 1;
	if (a < 0 && c % 2)ida = -1;
	if (b < 0 && c % 2)idb = -1;
	a = abs(a); b = abs(b);
	if (ida != idb) {
		if (ida < 0)cout << "<";
		if (idb < 0)cout << ">";
		cout << "\n";
		return;
	}
	if (a == b) {
		cout << "=\n"; return;
	}
	if (ida >= 0) {
		if (a < b)cout << "<";
		else cout << ">";
	}
	else {
		if (a < b)cout << ">";
		else cout << "<";
	}
	cout << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init_f();
	//init(); cout << ps.size() << "\n";
	//expr();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll=long long;
int main(void){
  int n,m; cin >> n >> m;
  if(m==0){
    cout << 1 << endl;
    return 0;
  }
  vector<int> a(m);
  rep(i,m){
    cin >> a[i];
    a[i]--;
  }
  sort(a.begin(),a.end());
  //set<int> s;
  vector<int> s;
  int count=0,sansyo=0;
  rep(i,n){
    if(i!=a[sansyo]) count++;

    if(i==a[sansyo]){
      sansyo++;
      //a.erase(a.begin());
      //s.insert(count);
      if(count!=0) s.push_back(count);
      count=0;
    }
    if(i==n-1&&count!=0) s.push_back(count);

  }
  if(s.size()==0){
    cout << 0 << endl;
    return 0;
  }
  sort(s.begin(),s.end());
  int k=s[0],ans=0;

  rep(i,s.size()){
    if(s[i]%k==0) ans += s[i]/k;
    if(s[i]%k!=0) ans += s[i]/k+1;
  }

  cout << ans << endl;
}

#include <iostream>
#include <algorithm>
using namespace std;
int a[500005];
int main(int argc, char** argv) {
	int n,m;
	cin >> n >> m;
	for(int i=1;i<=m;i++)
		cin >> a[i];
	sort(a+1,a+m+1);
	a[m+1]=n+1;
	int mn=1e9;
	for(int i=1;i<=m+1;i++)
		if(a[i]-a[i-1]-1) mn=min(mn,a[i]-a[i-1]-1);
	int ans=0;
	for(int i=1;i<=m+1;i++)
		ans+=(a[i]-a[i-1]-1+mn-1)/mn;
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<db> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };

int parent[200002];
int find(int x){
	if(parent[x]==x)return x;
	return parent[x]=find(parent[x]);
}
void merge(int x,int y){
	x=find(x),y=find(y);
	if(x!=y)parent[x]=y;
}
ll a[200002],b[200002];
ll asum[200002],bsum[200002];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	fup(i,1,n,1)scanf("%lld",a+i);
	fup(i,1,n,1)scanf("%lld",b+i);
	fup(i,1,n,1)parent[i]=i;
	while(m--){
		int x,y;
		scanf("%d%d",&x,&y);
		merge(x,y);
	}
	fup(i,1,n,1){
		int t=find(i);
		asum[t]+=a[i];
		bsum[t]+=b[i];
	}
	fup(i,1,n,1)if(asum[i]!=bsum[i])return !printf("No\n");
	puts("Yes");
}

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint A, B;
  cin >> A >> B;
  vector<lint> ans(A+B);
  lint sum = 0;
  if(A >= B) {
    REP(i, A) {
      ans[i] = i+1;
      sum += i+1;
    }
    FOR(i, A, A+B-1) {
      ans[i] = -(i-A+1);
      sum -= i-A+1;
    }
    ans[A+B-1] = -sum;
  } else {
    REP(i, B) {
      ans[i] = -(i+1);
      sum += i+1;
    }
    FOR(i, B, A+B-1) {
      ans[i] = i-B+1;
      sum -= i-B+1;
    }
    ans[A+B-1] = sum;
  }
  REP(i, A+B) cout << ans[i] << (i!=A+B-1 ? " " : "");
  cout << "\n";
}


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

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

const ll N=(ll)3e5;
ll inv[N];
ll fac[N];

void init(){
  fac[0]=1;

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

  for(ll i=0;i<N;i++)
  inv[i]=inv_mod(fac[i]);
}

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

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

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

    return ((x*y)%mod*z)%mod;
}
bool test_cases=0;

string simplify(string &s){
	stack<char>st;
	ll n=s.size();
	string ans;
	for(ll i=0;i<n;i++){
		 if(st.empty())
		 st.push(s[i]);
		 else if(st.top()==s[i])
		 st.pop();
		 else
		 st.push(s[i]);
	}

	while(!st.empty())
	{
		ans+=st.top();
		st.pop();
	}

	rev(ans);

	return ans;
}
void solve()
{
    string s;
    cin>>s;

    ll n=s.size();

    string ans;

    deque<char>dq;

    ll x=0;

    for(ll i=0;i<n;i++){
    	 if(s[i]=='R')
    	 x^=1;
    	 else{
    	 	if(x==1)
    	 	dq.push_front(s[i]);
    	 	else
    	 	dq.pb(s[i]);
		 }
	}

	while(!dq.empty()){
		ans+=dq.front();
		dq.pop_front();
	}

	if(x)
	rev(ans);

	ans=simplify(ans);

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

   // init();   //factorial calculations

   //Start from Here.

  ll t;
  t=1;

  if(test_cases)
  cin>>t;

  while(t--)
  solve();
//Good Bye!
    return 0;
}

#include <stdio.h>

#include <vector>

#define cm (1 << 17)
char cn[cm], *ci = cn + cm, ct;

inline char getcha() {
  if (ci - cn == cm) {
    fread(cn, 1, cm, stdin);
    ci = cn;
  }
  return *ci++;
}

inline int getint() {
  int A = 0;
  while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
  return A;
}

int main() {
  int h = getint(), w = getint(), n = getint(), m = getint();
  using std::vector;
  vector<vector<bool>> g1(h, vector<bool>(w, 0)), g2(h, vector<bool>(w, 0)),
      res(h, vector<bool>(w, 0));
  for (int i = 0; i < n; i++) {
    g1[getint() - 1][getint() - 1] = 1;
  }
  for (int i = 0; i < m; i++) {
    g2[getint() - 1][getint() - 1] = 1;
  }
  for (int i = 0; i < h; i++) {
    bool flag = 0;
    for (int j = 0; j < w; j++) {
      if (g2[i][j]) {
        flag = 0;
      } else if (g1[i][j]) {
        flag = 1;
        for (int jj = j - 1; ~jj; jj--) {
          if (g1[i][jj] || g2[i][jj]) break;
          res[i][jj] = 1;
        }
      }
      if (flag) res[i][j] = 1;
    }
  }
  for (int j = 0; j < w; j++) {
    bool flag = 0;
    for (int i = 0; i < h; i++) {
      if (g2[i][j]) {
        flag = 0;
      } else if (g1[i][j]) {
        flag = 1;
        for (int ii = i - 1; ~ii; ii--) {
          if (g1[ii][j] || g2[ii][j]) break;
          res[ii][j] = 1;
        }
      }
      if (flag) res[i][j] = 1;
    }
  }
  int ans = 0;
  for (auto&& v : res) {
    for (auto&& e : v) {
      if (e) ans++;
    }
  }
  printf("%d", ans);
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve() {
  int n;
	cin>>n;
	vi a(n);
	fo(i,n)cin>>a[i];
  ll ans=0;
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++){
		int x=upper_bound(a.begin(),a.end(),a[i])-a.begin();
		ans+=n-x;
	}
	cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;

    while(t--) {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

#pragma region
#include <bits/stdc++.h>
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define prec fixed<<setprecision(9)
#define all(x) x.begin(),x.end()
using ll = long long;
using namespace std;
int mod = 1e9+7;

string to_string(string& s) {return '"'+s+'"';}
string to_string(bool& b) {return b?"true":"false";}
string to_string(const char* s) {string t; return to_string(t=s);}
template <class A, class B> string to_string(pair<A, B>& p) {return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <class A> string to_string(A& v) {string s; for (auto &x : v) s+=(s.empty()?"":", ")+to_string(x); return "{"+s+"}";}
template<class... Ts> void _debug(Ts&... args){(..., (cerr<<" "<<to_string(args))); cerr<<endl;}
#ifdef apurv
#define debug(args...) cerr<<__LINE__<<" ["<<#args<<"]:", _debug(args)
#else
#define debug(...) 42
#endif
#pragma endregion

int main()
{
    fastIO
    int n; cin >> n;
    vector<int> arr(n); for(auto&i : arr) cin >> i;
    map<int,int> mp;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (i - mp[arr[i]]);
        mp[arr[i]]++;
    }
    cout << ans << endl;
}


/*pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-8;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

// MOD確認

long double X,Y,R;
ll x,y,r;

int main(){
   cin >> X >> Y >> R;
   x = floor(X*10000+0.5),y = floor(Y*10000+0.5), r = floor(R*10000+0.5);
   ll ans = 0;
   for(ll i = ((x-r) / 10000) * 10000;i <= ((x+r) / 10000) * 10000;i += 10000){
      ll a = r * r - (i-x) * (i-x);
      ll l = ((y - (ll)pow(a,0.5) - 150000) / 10000) * 10000,r = ((y + (ll)pow(a,0.5) + 150000) / 10000) * 10000;
      ll L = l,R = r;
      while(l < R+10000){
         if((y-l)*(y-l) > a) l += 10000;
         else break;
      }
      while(r > L-10000){
         if((y-r)*(y-r) > a) r -= 10000;
         else break;
      }
      if(l <= r) ans += (r - l + 10000) / 10000;
   }
   cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define yes() cout << "Yes" << endl
#define no() cout << "No" << endl
using ll = long long;
using ld = long double;
using P = pair<int,int>;

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a*a+b*b<c*c)yes();
    else no();

}


// Create by JJL
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <set>
#include <queue>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;

const int N=2010,mod=1e9+7;
char g[N][N];
int l[N][N],r[N][N],u[N][N],d[N][N],a[N][N];
#define int long long
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int qmi(int a,int b){
    int res=1;
    while(b){
        if(b&1) res=(LL)res*a%mod;
        b>>=1;
        a=(LL)a*a%mod;
    }
    return res;
}
signed main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;++i) cin>>g[i];
    int cnt=0;
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            if(g[i][j]=='.'){
                 l[i][j]=(j-1>=0?l[i][j-1]:0)+1;
                 cnt++;
            }
            else l[i][j]=0;
        }
        for(int j=m-1;j>=0;--j){
            if(g[i][j]=='.') r[i][j]=(j+1<m?r[i][j+1]:0)+1;
            else r[i][j]=0;
        }
    }
    for(int j=0;j<m;++j){
        for(int i=0;i<n;++i){
            if(g[i][j]=='.') u[i][j]=(i-1>=0?u[i-1][j]:0)+1;
            else u[i][j]=0;
        }
        for(int i=n-1;i>=0;--i){
            if(g[i][j]=='.') d[i][j]=(i+1<n?d[i+1][j]:0)+1;
            else d[i][j]=0;
        }
    }

    int ans=0;
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            if(g[i][j]=='.') a[i][j]=l[i][j]+r[i][j]+u[i][j]+d[i][j]-3;
           // cout<<a[i][j]<<" ";
        }
    }//cout<<"in\n";
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            ans=(LL)(ans+(LL)(qmi(2,a[i][j])-1)*qmi(2,cnt-a[i][j])%mod)%mod;
        }
    }
    cout<<ans;
    return 0;
}

#include<iostream>
#include<cstring>
#include<cctype>
using namespace std;
const int BUF = 200005;
const int MOD = 1000000007;

int add(int a, int b) {
    return (a + b) % MOD;
}

int mul(int a, int b) {
    return 1LL * a * b % MOD;
}

string N;
int K;

void read() {
    cin >> N >> K;
}

int ch2v(char ch) {
    if (isdigit(ch)) {
        return ch - '0';
    } else {
        return ch - 'A' + 10;
    }
}

int rec(int idx, int nType, bool anyDigitOK, bool addedDigit,
        int dp[BUF][16][2][2], int digit2added[16]) {
    if (nType > K) return 0;
    if (idx == N.size()) return nType == K;

    int &ret = dp[idx][nType][anyDigitOK][addedDigit];
    if (ret != -1) return ret;

    ret = 0;

    if (!anyDigitOK) {
        int v = ch2v(N[idx]);

        // Add same digit as N
        ++digit2added[v];
        ret = add(ret, rec(idx + 1, nType + (digit2added[v] == 1), false, true, dp, digit2added));
        // cout << idx << ' ' << nType << ' ' << rec(idx + 1, nType + (digit2added[v] == 1), false, true, dp, digit2added) << "  aaa" << endl;
        --digit2added[v];

        // Add digit which is less than N
        for (int i = addedDigit ? 0 : 1; i < v; ++i) {
            ++digit2added[i];
            ret = add(ret, rec(idx + 1, nType + (digit2added[i] == 1), true, true, dp, digit2added));
            --digit2added[i];
        }

        // Don't add digit
        if (!addedDigit) {
            ret = add(ret, rec(idx + 1, nType, true, false, dp, digit2added));
        }
    } else if (!addedDigit) {
        // Add digit
        for (int i = 1; i < 16; ++i) {
            ++digit2added[i];
            ret = add(ret, rec(idx + 1, nType + (digit2added[i] == 1), true, true, dp, digit2added));
            //cout << idx << ' ' << nType << ' ' << rec(idx + 1, nType + (digit2added[i] == 1), true, true, dp, digit2added) << " bbb" << endl;
            --digit2added[i];
        }

        // Don't add digit
        ret = add(ret, rec(idx + 1, nType, true, false, dp, digit2added));
    } else {
        // Add already-added digit
        ret = add(ret, mul(nType, rec(idx + 1, nType, true, true, dp, digit2added)));

        // Add not-added digit
        if (nType < 16) {
            ret = add(ret, mul(16 - nType, rec(idx + 1, nType + 1, true, true, dp, digit2added)));
        }
    }

    return ret;
}

void work() {
    static int dp[BUF][16][2][2];
    memset(dp, -1, sizeof(dp));
    int digit2added[16] = {};

    cout << rec(0, 0, 0, 0, dp, digit2added) << endl;
}

int main() {
    read();
    work();
    return 0;
}