#define MOD 1000000007
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const int N=1000001;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int l,r;
	int64_t ans{0};
	array < bool , N > prime;
	array < int , N > mob;
	vector < int > primes;
	cin>>l>>r;
	prime.fill(true);
	prime[0]=prime[1]=false;
	for(int64_t i=2; i<prime.size(); ++i){
		if(prime[i]){
			primes.push_back(i);
			mob[i]=-1;
		}
		for(int j=0; j<primes.size()&&i*primes[j]<prime.size(); ++j){
			prime[i*primes[j]]=false;
			if(i%primes[j]==0){
				mob[i*primes[j]]=0;
				break;
			}
			else{
				mob[i*primes[j]]=mob[i]*mob[primes[j]];
			}
		}
	}
	for(int i=max(l,2); i<=r; ++i){
		ans-=2*(r/i)-1;
	}
	for(int i=r; i>0; --i){
		int64_t c=r/i-(l-1)/i;
		ans-=mob[i]*c*c;
	}
	cout<<ans<<endl;
}

#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>

char s[501][501];

int main(void)
{

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

    rep(i,h)
    {
        string ss;
        cin>>ss;
        rep(j,w) s[i][j]= ss[j];

    }

    ll ans =1;
    //対称性チェック
    //1色，矛盾，なしのどれか
    for(int i=0;i<w;i++)
    {
        //cout<<i<<endl;
        bool r = false;
        bool b = false;

        for(int j=0;i-j>=0&&j<=h;j++)
        {

            if(s[j][i-j]=='B') b= true;
            if(s[j][i-j]=='R') r = true;

        }

        if(b==true&&r==true)
        {
            cout<<0<<endl;
            return 0;
        }
        else if(b==false&&r==false)
        {
            ans *=2;
            ans %=998244353;
        }
    }

    int ii=1;
    while(ii<h)
    {
        bool r = false;
        bool b = false;

        for(int j=0;ii+j<h&&w-j-1>=0;j++)
        {

            if(s[ii+j][w-1-j]=='B') b= true;
            if(s[ii+j][w-1-j]=='R') r = true;

            //cout<<w-1-j<<' '<<i+j<<endl;

        }

        if(b==true&&r==true)
        {
            cout<<0<<endl;
            return 0;
        }
        else if(b==false&&r==false)
        {
            ans *=2;
            ans %=998244353;
        }
        ii++;
    }

    cout<<ans%998244353<<endl;

}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define np next_permutation
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define vii vector<vi>
#define vb vector<bool>
#define pr pair<int,int>
#define vl vector<ll>
#define vs vector<string>
#define us unordered_map<int,int>
#define Mpq priority_queue<int>
#define mpq priority_queue<int,vi,greater<int>>
#define eb emplace_back
#define pr pair<int,int>
#define prl pair<ll,ll>
#define vp vector<pr>
#define vpl vector<prl>
#define mkp make_pair
#define ld long double
#define vii vector<vi>
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define ull unsigned long long
#define prr pair<ll,int>
using namespace std;
using vi=vector<int>;
// #include "Bigint.hpp"

const int N=1e6+11;

void solve(){
	ll n, cnt=0;
	cin >> n;
    // if(n==1){
    // 	cout << 2 << '\n';
    // 	return;
    // }
	for(ll i=1;i<(ll)2e6;i++){
		ll diff = n - i*(i-1)/2;
		if(diff<0LL) break;
		if(!diff or diff % i) continue;
		cnt++;
	}
	cout << 2*cnt << '\n';
}

int main(){
	// #ifndef ONLINE_JUDGE
	//  // for getting input from input.txt
	//  freopen("test3", "r", stdin);
	//  // for writing output to output.txt
	//  // freopen("output4.txt", "w", stdout);
	// #endif

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

	int t=1;
	while(t--)
	solve();
}

/*

n*(n+1)/2 - x = N

-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 5

1 2 3 4 5
sum(a0+(n-1)d) = n*a0 + n(n-1)/2 * d = (n/2) * (2*a0 + (n-1)d)

n*a0 + n*(n-1)d
an = a0 + (n-1)d

sn = (n/2)*(2*a0 + (n-1)*d)

*/

#include<iostream>

using namespace std;

typedef long long ll;

ll n;

int main(){

	cin >> n;

	ll l = 1,r = 1e10;
	while(l < r){
		ll mid = l + r + 1 >> 1;
		if((1 + mid) * mid / 2 > n + 1){
			r = mid - 1;
		}else if((1 + mid) * mid / 2 == n + 1){
			l = mid;
			break;
		}else{
			l = mid;
		}
	}

	cout << n - l + 1 << endl;

	return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

const double PI  = acos(-1.0);
using namespace std;
//typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 50 + 9;
ll mod=998244353 , n,k,a[N][N],vis[N],cnt,ans=1,f[N];
vector<int> adj[N];
void dfs(int u)
{
    vis[u] = 1;
    cnt++;
    for(auto v:adj[u])
    {
        if(!vis[v])dfs(v);
    }
}

 int main()
{
//freopen("calc.in","r",stdin);
//freopen("calc.out","w",stdout);
//__builtin_popcount()
input
        f[0] = 1;
        forr(i,1,50)
        {
            f[i] = ((ll)i * f[i-1]) % mod;
            //cout<<f[i]<<endl;
        }
        cin>>n>>k;

        forr(i,1,n)
        forr(j,1,n)
        cin>>a[i][j];

        forr(i,1,n)
        {
            forr(j,i+1,n)
            {
                int c=0;
                forr(u,1,n)
                {
                    if(a[u][i] + a[u][j] <= k)c++;
                }
                if(c == n)
                {
                    adj[i].push_back(j);
                    adj[j].push_back(i);
                }
            }
        }

        forr(i,1,n)
        {
            if(!vis[i])
            {
                cnt=0;
                dfs(i);
                ans *= f[cnt];
                ans %= mod;
            }
        }

        forr(i,1,n)adj[i].clear();

        forr(i,1,n)
        {
            forr(j,i+1,n)
            {
                int c=0;
                forr(u,1,n)
                {
                    if(a[i][u] + a[j][u] <= k)c++;
                }
                if(c == n)
                {
                    adj[i].push_back(j);
                    adj[j].push_back(i);
                }
            }
        }

        memset(vis,0,sizeof vis);

        forr(i,1,n)
        {
            if(!vis[i])
            {
                cnt=0;
                dfs(i);
                ans *= f[cnt];
                ans %= mod;
            }
        }

        cout<<ans<<endl;

return 0;
}

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define PRINT(a) printf("%.15Lf\n",a);
#define YESNO(a) cout << (a ? "YES" : "NO") << endl
#define YesNo(a) cout << (a ? "Yes" : "No") << endl
#define yesno(a) cout << (a ? "yes" : "no") << endl
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12
//priority_queue<int,vector<int>, greater<int> > q2;

vector<bool>F(100010, false);
int N;
VI C;
vector<VI>G;
VI ans;

void dfs(int now, int pa) {
	bool ok = 0;
	if (!F[C[now]]) {
		ans.push_back(now + 1);
		F[C[now]] = 1;
		ok = 1;
	}
	fore(to, G[now]) {
		if (to == pa)continue;
		dfs(to, now);
	}
	if (ok)F[C[now]] = 0;
	return;
}

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

	cin >> N;
	C.resize(N);
	G.resize(N);
	REP(i, N)cin >> C[i];
	REP(i, N - 1) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs(0,-1);

	SORT(ans);
	fore(i, ans)cout << i << '\n';
	return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define PB push_back
#define MP make_pair
#define F first
#define S second

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
//#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()
#define ALLR(t) (t).rbegin(),(t).rend()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }

const int dx4[4] = {0, 0, 1, -1};
const int dy4[4] = {-1, 1, 0, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

#define MOD 1000000007
///////////////////////////////////////

//////////////////////////////////////////

void test_case(){

    string s;cin>>s;
    string s1 = s;
    int n = s.length();
    reverse(ALL(s));
    if(s == s1){
        cout<<"Yes\n";
    }
    else{
        int l = 0,r= n-1;
        for (int i = 0; i < n; ++i)
        {
            if(s[i] == '0')l++;
            else break;
        }
        for (int i = n-1; i >= 0;--i)
        {
            if(s[i] == '0')r--;
            else break;
        }
        int n1 = (r+l)/2;
        while(l <= n1)
        {
            if(s[l] != s[r]){
                cout<<"No\n";
                return ;
            }
            else{
                l++;
                r--;
            }
        }
        cout<<"Yes\n";
    }

}

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

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

int main(){
  int j=0,n,a[10];
  bool zeroend=false;
  cin>>n;
  for(int i=0;n>0;i++){
    if(n%10!=0){
      zeroend=true;
    }
    if(zeroend){
      a[j]=n%10;
      j++;
    }
    n/=10;
  }

  for(int i=0;i<j/2;i++){
    if(a[i]!=a[j-1-i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=1000000007;
constexpr ll INF=1e18;

int main(){
    int n, m; cin >> n >> m;
    vector<vector<bool>> edge(n,vector<bool>(n,false));
    int a, b;
    REP(i,m){
        cin >> a >> b;
        a--, b--;
        edge[a][b]=true;
        edge[b][a]=true;
    }
    VI dp(1<<n,INF);
    REP(i,1<<n){
        VI v;
        int ii=i;
        REP(j,n){
            if(ii%2)
                v.push_back(j);
            ii=ii>>1;
        }
        int siz=v.size();
        int c=0;
        REP(j,siz)REP(k,j){
            c+=edge[v[j]][v[k]];
        }
        if(c==siz*(siz-1)/2)
            dp[i]=1;
    }
    int ans=n;
    REP(i,1<<n){
        for(int j=i;--j&=i;)
            dp[i]=min(dp[i],dp[i^j]+dp[j]);
    }
    cout << dp[(1<<n)-1] << endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;

using ll = long long;
using ull = unsigned long long;

#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

constexpr int INF = 1e9+7;
constexpr ll INFL = 9*1e18;

constexpr int dx[4] = { 1, 0, -1, 0 };
constexpr int dy[4] = { 0, 1, 0, -1 };

// constexpr int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// constexpr int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

int inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
ull inline power(ull a,ull b){ull res = 1;rep(i,b)res *= a;return res;}
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
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<typename T>inline void print(T&& x){cout<<setprecision(32)<<x<<endl;}
string to_oct(int n){string s;while(n){s = to_string(n%8) + s;n /= 8;}return s;}

int main(){
  int n;cin>>n;
  string s;cin>>s;
  string t = "";
  int ans = 0;
  rep(i,n){
    t.push_back(s[i]);
    if(t.length() >= 3 && (t.substr(t.length()-3) == "fox")){
      t = t.substr(0,t.size()-3);
      ans++;
    }
  }
  print(n - ans*3);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  cout << fixed << setprecision(10);

  int n, m, k;
  cin >> n >> m >> k;
  vector<int> is_back(n + 1);
  for (int i = 0; i < k; i++) {
    int p;
    cin >> p;
    is_back[p] = 1;
  }

  int c = 0;
  for (int i = 0; i < n; i++) {
    if (is_back[i]) {
      c++;
      if (c >= m) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      c = 0;
    }
  }

  vector<double> xs(n + 1);
  vector<double> ys(n + 1);
  int l = n;
  for (int i = n - 1; i >= 0; i--) {
    if (is_back[i]) {
      xs[i] = 1.0;
      ys[i] = 0.0;
    } else {
      if (l == n) {
        for (int j = i + 1; j <= n - 1; j++) {
          xs[i] += xs[j] / m;
          ys[i] += ys[j] / m;
        }
        ys[i] += 1.0;
      } else {
        xs[i] = xs[l];
        ys[i] = ys[l];
        for (int j = i + 1; j <= l; j++) {
          xs[i] += xs[j] / m;
          ys[i] += ys[j] / m;
        }
        for (int j = i + m + 1; j <= l + m; j++) {
          xs[i] -= xs[min(j, n)] / m;
          ys[i] -= ys[min(j, n)] / m;
        }
      }

      l = i;
    }
  }

  double a = xs[0];
  double b = ys[0];
  cout << b / (1.0 - a) << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int solve(int r1, int c1, int r2, int c2) {
  if (r1 == r2 && c1 == c2) return 0;
  if (abs(r1 - r2) + abs(c1 - c2) <= 3) return 1;
  if ((r1 + c1) == (r2 + c2)) return 1;
  if ((r1 - c1) == (r2 - c2)) return 1;
  if (abs((r1 + c1) - (r2 + c2)) <= 6) return 2;
  if (abs((r1 - c1) - (r2 - c2)) <= 6) return 2;
  if ((abs(r1+c1) - abs(r2+c2)) % 2 == 0) return 2;
  if ((abs(r1-c1) - abs(r2-c2)) % 2 == 0) return 2;
  return 3;
}

int main2() {
  ll r1 = nextLong();
  ll c1 = nextLong();
  ll r2 = nextLong();
  ll c2 = nextLong();

  cout << solve(r1, c1, r2, c2) << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int c[200005];

int main(){
  int n;
  cin >> n;
  int ans=0;
  REP(i,n){
    int p;
    cin >> p;
    c[p]++;
    while(c[ans]!=0)ans++;
    cout << ans << endl;
  }
}

#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define int ll
#define each(i, a) for (auto &&i : (a))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using P = pair<int, int>;
using vp = vector<P>;
using int128 = __int128_t;//cin coutはできない
template <class T>
using greater_queue = priority_queue<T, vector<T>, greater<T>>;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a / gcd(a, b) * b;};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template <class T>
void CVEC(const T &v) {
	int c = v.size() - 1;
	for (int i = 0; i < c; i++) cout << v[i] << ' ';
	if (c > -1) cout << v[c];
	cout << '\n';
}

#pragma endregion header

int XMAX = 10000;
int YMAX = 10000;

struct Rectangle{
	int a, b, c, d;
};

struct Point{
	int id, x, y, r;
	bool operator<( const Point& right ) const {
        return x == right.x ? y < right.y : x < right.x;
    }
};

void COUT(Rectangle	x){
	cout << x.a << " " << x.b << " " << x.c << " " << x.d << endl;
}

int n;
vector<int> area(n, 0);

signed main(){
    cin >> n;
	vector<Point> Ps;
	map<int, Rectangle> ans;
	rep(i,n){
		int x, y, r; cin >> x >> y >> r;
		Ps.push_back({i, x, y, r});
	}
	sort(ALL(Ps));
	/*
	rep(i,n){
		int a = Ps[i].x;//x
		int b = Ps[i].y;//y
		int r = Ps[i].r;
		cout << a << " " << b << " " << r << endl;
	}
	*/
	vector<vector<bool>> occupied(XMAX/100, vector<bool>(YMAX/100, 0));
	vector<bool> used(n, 0);

	for(int i = 0; i < XMAX/100; i++){
		for(int j = 0; j < YMAX/100; j++){
			for(int k = 0; k < n; k++){
				int x = Ps[k].x;
				int y = Ps[k].y;
				int id = Ps[k].id;
				if(i * 100 <= x && x < (i + 1) * 100 && j * 100 <= y && y < (j + 1) * 100){
					ans[id] = {i * 100, j * 100, (i + 1) * 100, (j + 1) * 100};
					used[id] = 1;
					occupied[i][j] = 1;
					break;
				}
			}
		}
	}
	for(int id = 0; id < n; id++){
		if(!used[id]){
			bool flag = false;
			for(int i = 0; i < 100; i++){
				for(int j = 0; j < 100; j++){
					if(!occupied[i][j]){
						ans[id] = {i * 100, j * 100, (i + 1) * 100, (j + 1) * 100};
						occupied[i][j] = 1;
						flag = true;
						break;
					}
				}
				if(flag)break;
			}
		}
	}

	rep(i,n){
		COUT(ans[i]);
	}
}


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

int n;

int main()
{
	scanf("%d", &n);
	printf("%d", 100-n%10-(n/10%10)*10);
	return 0;
}

// #include<vector>
// #include<iostream>
// #include<stdio.h>
// #include<string>
// #include<algorithm>
#include<array>
#include<bits/stdc++.h>
using namespace std;

int main() {
	double x;
	cin >> x;
	int memo = x;
	x = 1.0*x / 100;
	x = ceil(x)*100;
	if ( memo % 100 == 0) {
		cout << 100 << endl;
	} else
	cout << x - memo << endl;
}


#include <bits/stdc++.h>

using namespace std;

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

const int dy[4] = { -1, 0, 1, 0 }, dx[4] = { 0, 1, 0, -1 };

char mp[1000][1000];
vector<int> gph[2000];
bool chk[2000];

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

	int r, c;
	cin >> r >> c;
	gph[0].push_back(r);
	gph[r].push_back(0);
	gph[0].push_back(r + c - 1);
	gph[r + c - 1].push_back(0);
	gph[r - 1].push_back(r);
	gph[r].push_back(r - 1);
	gph[r - 1].push_back(r + c - 1);
	gph[r + c - 1].push_back(r - 1);
	for (int i = 0; i < r; ++i)
		for (int j = 0; j < c; ++j) {
			cin >> mp[i][j];
			if (mp[i][j] == '#') {
				gph[i].push_back(r + j);
				gph[r + j].push_back(i);
			}
		}

	int cnt0 = 0, cnt1 = 0;
	for (int i = 0; i < r + c; ++i)
		if (!chk[i]) {
			queue<int> q;
			chk[i] = true;
			q.push(i);

			bool chk0 = false, chk1 = false;
			while (!q.empty()) {
				int now = q.front();
				q.pop();

				if (now < r)
					chk0 = true;
				else
					chk1 = true;

				for (int nxt : gph[now])
					if (!chk[nxt]) {
						chk[nxt] = true;
						q.push(nxt);
					}
			}

			if (chk0)
				cnt0++;
			if (chk1)
				cnt1++;
		}

	cout << min(cnt0, cnt1) - 1;

	return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using ld = long double;

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

#define mp make_pair

const int p =  1e9 + 7;

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

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, ll deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

mt19937 rnd(time(0));

/*
const int N = 1e6 + 5;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/

struct DSU
{
    vector<int> sz;
    vector<int> parent;
    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        else
        {
            auto par = find_set(parent[v]);
            parent[v] = par;
            return par;
        }
    }

    void union_sets(int a, int b) {
        find_set(a);
        find_set(b);

        a = find_set(a);
        b = find_set(b);

        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }
    DSU (int n)
    {
        parent.resize(n);
        sz.resize(n);
        for (int i = 0; i<n; i++) make_set(i);
    }
};

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

    int H, W; cin>>H>>W;
    vector<string> a(H);
    for (int i = 0; i<H; i++) cin>>a[i];

    DSU dsu(H+W);
    for (int i = 0; i<H; i++) for (int j = 0; j<W; j++)
    {
        bool unite = true;
        if (i!=0 && i!=H-1) unite = false;
        if (j!=0 && j!=W-1) unite = false;
        if (a[i][j]=='#') unite = true;
        if (unite) dsu.union_sets(i, H+j);
    }

    int minn = 1e9;
    set<int> vert;
    for (int i = 0; i<H; i++) vert.insert(dsu.find_set(i));
    minn = min(minn, (int)vert.size() - 1);

    set<int> hor;
    for (int i = H; i<H+W; i++) hor.insert(dsu.find_set(i));
    minn = min(minn, (int)hor.size() - 1);

    cout<<minn;

}


#include <bits/stdc++.h>
#define ll long long int
#define vll vector<long long int>
using namespace std;
ll MOD = 1e9 + 7;

void solver(){
	ll n;
	cin>>n;
	vll a(n),b(n),c(n);
	map<ll,ll> mp;
	for(ll i=0;i<n;i++)cin>>a[i];

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

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

	for(ll i=0;i<n;i++){
		mp[b[c[i]-1]]++;
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ans+=mp[a[i]];
	}
	cout<<ans<<"\n";
}

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

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

typedef long long LL;
typedef pair<int,int> PI;
typedef vector<int> VI;
typedef vector<PI> VPI;

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

#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define F first
#define S second
#define SZ(x) (int)(x).size()
#define FOR(i,a,b) for(int _n(b),i(a);i<_n;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define TRAV(a,x) for (auto& a : x)

void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

const int MX = 100005;
int cnt[MX], b[MX], c[MX];
int n;

LL solve() {
    LL r = 0;
    REP(j, n) r += cnt[b[c[j+1]]];
    return r;
}

int main() {
    setIO();
    cin>>n;
    REP(i, n) {
        int x; cin >> x;
        cnt[x]++;
    }
    REP(i, n) cin >> b[i+1];
    REP(i, n) cin >> c[i+1];
    cout<<solve()<<"\n";

    return 0;
}


#line 1 "main.cpp"
#include <bits/stdc++.h>
using namespace std;

// template {{{
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

#define  range(i, l, r) for (i64 i = (i64)(l); i < (i64)(r); (i) += 1)
#define rrange(i, l, r) for (i64 i = (i64)(r) - 1; i >= (i64)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr i32 dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr i32 dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

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

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

vector< int > calc(int n, vector< int > ps) {
  vector< int > res;
  for (auto &p : ps) {
    p--;
  }

  // v : 0-indexed
  auto find_idx = [&](int v) {
    range(i, 0, n) {
      if (ps[i] == v) return i;
    }
    return -1ll;
  };

  int k = 0;

  auto swap_check = [&](int i) {
    return ((i & 1) == (k & 1));
  };

  auto swap_query = [&](int i) {
    // if ((i + k) % 2 != 0) return;
    swap(ps[i], ps[i + 1]);
    k++;
    res.emplace_back(i + 1);
  };

  rrange(v, 0, n) {
    int idx = find_idx(v);
    if (idx == v) continue;

    while (not swap_check(idx)) {
      if (idx == (k&1) + 1) idx--;
      swap_query(k & 1);
    }

    range(i, idx, v) {
      swap_query(i);
    }
  }

  if (ps[n-2] != n-2) {
    swap_query(n-2);
  }

  return res;
}

void solve() {
  int t = input();
  while (t--) {
    int n = input();
    vector< int > ps(n);
    cin >> ps;
    auto as = calc(n, ps);
    cout << as.size() << endl;
    cout << as << endl;
  }
}

signed main() {
  solve();
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
const int N=505;//点数
const int M=5e5+5;//边数
int End[M],Last[N],Next[M],Len[M],e;//链式前向星
void add_edge(int x,int y,int z)
{
	End[++e]=y;
	Next[e]=Last[x];
	Last[x]=e;
	Len[e]=z;
}
int dis[N],cnt[N];//cnt记录各个点入队次数
queue<int> q;
bool inq[N];//inq标记各个点是否在队列中
bool spfa(int s)
{
	for(int i=1;i<=n;i++) dis[i]=-1e9;//最短路，初始值为inf
	dis[s]=0;
	for(int i=1;i<=n;i++)//全部放入队列
	{
		q.push(i);
		inq[i]=true;
		cnt[i]++;
	}
	while(q.size())
	{
		int x=q.front();
		q.pop();
		inq[x]=false;
		for(int i=Last[x];i;i=Next[i])
		{
			int y=End[i];
			if(dis[y]<dis[x]+Len[i])
			{
				dis[y]=dis[x]+Len[i];
				if(!inq[y])
				{
					q.push(y);
					inq[y]=true;
					cnt[y]++;
					if(cnt[y]>n+1) return false;//返回 false，意味着无解
				}
			}
		}
	}
	return true;
}
int s[N],pd[N][N],c[N][N],y[N];
signed main()
{
	cin>>n;
		for(int i=1;i<=n;i++){
	 	for(int k=1;k<=n;k++){
	 		cin>>c[i][k];
	 		s[i]+=c[i][k];
		 }
	 }
	 for(int i=1;i<=n;i++)add_edge(0,i,0);
	 for(int i=1;i<=n;i++){
	 	for(int k=i;k<=n;k++){
	 		if(i==k)continue;
	 		//if(s[i]-s[k]<0)continue;
	 		if(pd[i][k])continue;
	 		if((s[i]-s[k])%n!=0){
	 			puts("No");
	 			return 0;
			 }
			 add_edge(i,k,-(s[i]-s[k])/n);
			 add_edge(k,i,-(s[k]-s[i])/n);
			 pd[i][k]=pd[k][i]=1;
		 }
	 }
/*	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		add_edge(y,x,z);
	}*/
	if(spfa(1))
	{

		int minn=1e9;
		int maxx=-1e9;
		for(int i=1;i<=n;i++){
			minn=min(minn,dis[i]);
			maxx=max(maxx,dis[i]);
		}
		for(int i=1;i<=n;i++){
			dis[i]-=minn;
		}
		for(int i=1;i<=n;i++){
			y[i]=c[1][i]-dis[1];
		}
		for(int i=1;i<=n;i++){
			for(int k=1;k<=n;k++)
				if(c[i][k]-dis[i]!=y[k]){
					puts("No");
					return 0;
				}
		}
		puts("Yes");
		for(int i=1;i<=n;i++)printf("%lld ",dis[i]);
		puts("");
		for(int i=1;i<=n;i++)printf("%lld ",y[i]);
	//	for(int i=1;i<=n;i++) printf("%d%c",dis[i],i<n?' ':'\n');
	}
	else printf("No\n");
	return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define done(x) {cout << x << endl;return;}
#define mini(x,y) x=min(x,y)
#define maxi(x,y) x=max(x,y)
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;
uniform_int_distribution<int> rng(1,1e5);
uniform_int_distribution<int> rng1(0,1);
uniform_int_distribution<int> rng2(1,5e4);

//DEBUG FUNCTIONS START
#define cerr cout
void __print(int x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
//#define deb(x...) cerr << "[" << #x << "] = "; _print(x)
#define deb(x...)  _print(x)
#else
#define deb(x...)
#endif
// DEBUG FUNCTIONS END

const int N = 2e5 + 5;

void solve(){

	int n;
	cin >> n;
	vvi c(n, vi(n));
	vi a(n), b(n);

	rep(i,0,n){
		rep(j,0,n){
			cin >> c[i][j];
		}
		a[i] = c[i][0];
	}

	rep(j,0,n){
		b[j] = c[0][j] - a[0];
	}

	rep(i,0,n){
		rep(j,0,n){
			if(c[i][j] != a[i] + b[j])
				done("No");
		}
	}

	int x = 0;
	int y = *min_element(all(a));
	if(y < 0)
		x = -y;
	y = *min_element(all(b));
	if(y < 0)
		x = y;

	cout << "Yes" << endl;
	rep(i,0,n)
		cout << a[i] + x << ' ';
	cout << endl;
	rep(i,0,n)
		cout << b[i] - x << ' ';

}

signed main() {

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

int powm(int a, int b){
    int res = 1;
    while (b) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b % mod, mod - 2) % mod;
}


#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int MOD2 = 998'244'353;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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

int main(){
    int N; std::cin >> N;
    std::vector<std::vector<long long>> ct(3);
    {
        long long a; char c;
        std::vector<int> aa(26);
        aa['R' - 'A'] = 0;
        aa['G' - 'A'] = 1;
        aa['B' - 'A'] = 2;
        for(int i{0}, i_len{2 * N}; i < i_len; ++i){
            std::cin >> a >> c;
            ct[aa[c - 'A']].push_back(a);
        }
    }
    std::vector<int> E, Z, O;
    for(int i{0}; i < 3; ++i){
        std::sort(std::begin(ct[i]), std::end(ct[i]));
        if(!(ct[i].size() % 2)) E.push_back(i);
        if(ct[i].size() % 2) O.push_back(i);
        if(!ct[i].size()) Z.push_back(i);
    }
    if(E.size() == 3){
        std::cout << 0 << std::endl;
        return 0;
    }

    long long ans{LINF};
    {
        int a{O[0]}, b{O[1]};
        for(int i{0}, i_len{int(ct[a].size())}; i < i_len; ++i){
            auto itr{std::lower_bound(std::begin(ct[b]), std::end(ct[b]), ct[a][i])};
            if(itr != ct[b].end()) chmin(ans, std::abs(*itr - ct[a][i]));
            itr = std::upper_bound(std::begin(ct[b]), std::end(ct[b]), ct[a][i]);
            if(itr != ct[b].begin()){
                --itr;
                chmin(ans, std::abs(*itr - ct[a][i]));
            }
        }
    }

    std::vector<std::vector<std::pair<long long, int>>> z(2);
    if(!Z.size()){
        int e{E[0]};
        for(int i{0}, i_len{int(ct[e].size())}; i < i_len; ++i){
            for(int j{0}; j < 2; ++j){
                int o{O[j]};
                auto itr{std::lower_bound(std::begin(ct[o]), std::end(ct[o]), ct[e][i])};
                if(itr != ct[o].end()) z[j].emplace_back(std::abs(*itr - ct[e][i]), i);
                itr = std::upper_bound(std::begin(ct[o]), std::end(ct[o]), ct[e][i]);
                if(itr != ct[o].begin()){
                    --itr;
                    z[j].emplace_back(std::abs(*itr - ct[e][i]), i);
                }
            }
        }
    }

    for(int i{0}; i < 2; ++i){
        std::sort(std::begin(z[i]), std::end(z[i]));
        z[i].erase(std::unique(std::begin(z[i]), std::end(z[i])), std::end(z[i]));
    }

    for(int i{0}, i_len{std::min(4, int(z[0].size()))}; i < i_len; ++i){
        for(int j{0}, j_len{std::min(4, int(z[1].size()))}; j < j_len; ++j){
            if(z[0][i].second != z[1][j].second){
                chmin(ans, z[0][i].first + z[1][j].first);
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

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

struct ad{
    int left, up, right, down;
};

int time_start;
int Num;
std::vector<ad> ads;
std::vector<std::pair<ad,int>> ads_start;

void in(){
    std::cin >> Num;
    ads.resize(Num);
    ads_start.resize(Num);
    rep(i,0,Num-1){
        std:: cin >> ads[i].left >> ads[i].up;
        ads[i].right = ads[i].left + 1;
        ads[i].down = ads[i].up + 1;
        ads_start[i].first = ads[i];
        std::cin >> ads_start[i].second;
    }
}

void make_randomcase(){

}

bool is_collision(int N){
    if(ads[N].left<0||ads[N].up<0||ads[N].right>10000||ads[N].down>10000) return true;
    rep(i,0,Num-1){
        if(i==N) continue;
        if( std::max(ads[i].left,ads[N].left) < std::min(ads[i].right,ads[N].right) && std::max(ads[i].up,ads[N].up) < std::min(ads[i].down,ads[N].down) ){
            return true;
        }
    }
    return false;
}

int score(){
    long double point=0;
    rep(i,0,Num-1){
        point+=1.0-pow(1-1.0*std::min(ads_start[i].second,(ads[i].right-ads[i].left)*(ads[i].down-ads[i].up))/std::max(ads_start[i].second,(ads[i].right-ads[i].left)*(ads[i].down-ads[i].up)),2);
    }
    point *= 1e9;
    point /= Num;
    return round(point);
}

//ランダムに広げる（広げて得をして、なおかつできるものだけ広げる）

void solve(){
    std::vector<std::vector<int>> delta(4,std::vector<int> (4,0));
    delta[0][0] = delta[1][1] = -1;
    delta[2][2] = delta[3][3] = 1;
    std::vector<ad> best_ads(Num);
    int bestscore = score();
    rep(_,0,44){
        rep(i,0,Num-1){
            ads[i] = ads_start[i].first;
        }
        time_start = clock();
        while(clock() - time_start < 100000){
            int select = random()%Num;
            int direction = random()%4;
            int stretch = ( 10 - (clock() - time_start) / 10000 ) * ( random()%10 + 1 );
            ads[select].left += stretch * delta[direction][0];
            ads[select].up += stretch * delta[direction][1];
            ads[select].right += stretch * delta[direction][2];
            ads[select].down += stretch * delta[direction][3];
            if(is_collision(select)||(ads[select].right-ads[select].left)*(ads[select].down-ads[select].up)>ads_start[select].second*std::min((long)10, 7 + ( clock() - time_start ) / 20000) / 10){
                ads[select].left -= stretch * delta[direction][0];
                ads[select].up -= stretch * delta[direction][1];
                ads[select].right -= stretch * delta[direction][2];
                ads[select].down -= stretch * delta[direction][3];
            }
        }
        if(bestscore < score()){
            bestscore = score();
            best_ads = ads;
        }
    }
    ads = best_ads;
}

void out(){
    rep(i,0,Num-1){
        std::cout << ads[i].left << ' ' << ads[i].up << ' ' << ads[i].right << ' ' << ads[i].down << '\n';
    }
}

int main() {
    srand((unsigned int)time(NULL));
    time_start = std::clock();
    in();
    solve();
    out();
    std::cerr << score() << std::endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

typedef long long int ll;

int main(){
	double N; cin >> N;
    double ans = 0;
    rep(i,1,N){
        ans+=(double)1/(N-i);
    }
    printf("%.10lf\n", ans*N);
    return 0;
}

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <atcoder/all> // g++ main.cpp -std=c++17 -I .
using namespace std;
// using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
using ll=long long;

const int inf = INT_MAX / 2; const ll INF = 1LL << 60;
// const int MOD = 1000000007;
const int MOD = 998244353;

// cout << fixed << setprecision(15) << ans << endl;
// using mint = modint1000000007;

////////////////////////////////////////////////////////////////////////////////////////////

template <typename T>
struct BIT {

  int n;          // 配列の要素数(数列の要素数+1)
  vector<T> bit;  // データの格納先
  BIT(int n_) : n(n_ + 1), bit(n, 0) {}

  void add(int i, T x) {
    for (int idx = i; idx < n; idx += (idx & -idx)) {
      bit[idx] += x;
    }
  }

  T sum(int i) {
    T s(0);
    for (int idx = i; idx > 0; idx -= (idx & -idx)) {
        s += bit[idx];
    }
    return s;
  }

  // [l,r) の区間和を取得
  T query(int l, int r) { return sum(r - 1) - sum(l - 1); }

  int lower_bound(T w) { // a_1 + a_2 + ... + a_x >= w となるような最小の x を求める(ただし a_i >= 0)
    if (w <= 0) {
      return 0;
    } else {
      int x = 0, r = 1;
      while (r < n) r = r << 1;
      for (int len = r; len > 0; len = len >> 1) { // 長さlenは1段下るごとに半分に
        if (x + len < n && bit[x + len] < w) { // 採用するとき
          w -= bit[x + len];
          x += len;
        }
      }
      return x + 1;
    }
  }
};

int main() {
  int n;cin>>n;
  vector<ll> a(n), b(n);
  rep(i, n) {
    cin>>a[i]; a[i]+=i;
  }
  rep(i, n) {
    cin>>b[i]; b[i]+=i;
  }
  map<int, queue<int>> m;
  rep(i, n) {
    m[a[i]].push(i);
  }
  BIT<ll> bit(n);
  ll ans = 0;
  rep(i, n) {
    if(m[b[i]].empty()) {
      cout << -1 << endl;
      return 0;
    }
    int p = m[b[i]].front();
    m[b[i]].pop();
    bit.add(p+1, 1);
    ans += i+1 - bit.sum(p+1);
  }
  cout << ans << endl;

  return 0;
}


/**
      11  11   000000   111111
      11 11       00    111111
      1111       00       11
      11 11     00        11
      11  11   000000     11     **/

#include<bits/stdc++.h>

using namespace std;

#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define bugarr(a, i, j) cout << #a << "{" << i << "..." << j << "}:"; fto(k, i, j-1) cout << a[k] << ", "; cout << a[j] << endl;
#define ll long long
#define db double
#define ldb long double
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define vvi vector<vi>
#define vdb vector<db>
#define vldb vector<ldb>
#define all(x) (x).begin(), (x).end()
#define sz(a) (int)a.size()
#define fast ios::sync_with_stdio(false); cin.tie(0)

bool ckmin(int &a, int b) {return (b < a)? a = b, true : false;}
bool ckmax(int &a, int b) {return (b > a)? a = b, true : false;}

int main() {
    //freopen("b.inp", "r", stdin);
    //freopen("b.out", "w", stdout);

    fast;
    int n;
    cin >> n;
    vi dd(100000);
    fto(i, 1, n) {
        int x;
        cin >> x;
        ++dd[x];
    }
    fto(i, 1, n) {
        if (dd[i] == 0 || dd[i] > 1) {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    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<int, pi>
#define fir first
#define sec second
#define MAXN 100001
#define mod 1000000007

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++)
  {
    int k;
    cin >> k;
    s.insert(k);
  }
  bool can = true;
  if (s.size() != n)
    can = false;
  int curr = 1;
  for (auto const &i : s)
  {
    if (i != curr)
      can = false;
    curr++;
  }
  (can) ? cout << "Yes\n" : cout << "No\n";
  return 0;
}


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

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

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

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define deb(x) cout << #x << " " << x << endl;
#define mod 1000000007
#define fast std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define endl "\n"

const ll INF = 1e18;
const ll NEGINF = -1 * INF;

/*NOTES: Take care of ll vs int
         Never use an iterator after erasing it
*/

void solve()
{
    vector<int> a(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    if (a[1] - a[0] == a[2] - a[1])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

int main()
{
    fast;
#ifndef ONLINE_JUDGE
    freopen("/home/kalit/Desktop/Data Structures-Algo-Competitive/src/codeforces/input.txt", "r", stdin);
    freopen("/home/kalit/Desktop/Data Structures-Algo-Competitive/src/codeforces/output.txt", "w", stdout);
#endif
    int T = 1;
    while (T--)
    {
        solve();
    }
    //cout<< "Done in " << clock() / CLOCKS_PER_SEC <<"sec"<< endl;
    return 0;
}


#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>
#include <string.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

bool overflow_checker(long long int input_number1,long long int input_number2){
    if(5000000000000000000/input_number1<input_number2){
        return true;
    }else{
        return false;
    }
}

const long long int mod = 1000000007;
const long long int INF = 2e18;
const long double PI=3.14159265358979323;
const long long int pl=1100;
const long double eps =0.00001;

long long int N,M,K,res=0;
long long int A[202002],B[200200];
string S[200200],T;

int main(){

    cout << fixed << setprecision(18);

    cin>>T;
    for (long long int i = 0; i < T.size()-3; i++)
    {
        if(T.substr(i,4)=="ZONe"){
            res++;
        }
    }
    cout<<res<<endl;

}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string N;
  cin >> N;
  int ans=0;
  rep(i,9){
    if(  (N[i] == 'Z') && (N[i+1] == 'O') && (N[i+2] == 'N') && (N[i+3] == 'e') )ans++;
  }
  cout << ans << endl;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
vector<vector<PII>>adj(1000);
int main()
{
	ll a,b,x,y;
	cin>>a>>b>>x>>y;
	for(int i=1;i<=100;i++){
		adj[i].pb({100+i,x});
		adj[100+i].pb({i,x});
		if(i!=1){
			adj[i].pb({100+i-1,x});
			adj[100+i-1].pb({i,x});
		}
	}
	for(int i=1;i<100;i++){
		adj[i].pb({i+1,y});
		adj[i+1].pb({i,y});
		adj[100+i].pb({100+i+1,y});
		adj[100+i+1].pb({100+i,y});
	}
	vector<ll>dist(1000,INF);
	dist[a] = 0;
	priority_queue<PII,vector<PII>,greater<PII>>pq;
	pq.push({0,a});
	while(!pq.empty()){
		int v = pq.top().se;
		int d = pq.top().fi;
		pq.pop();
		if(dist[v] != d)continue;
		for(auto z:adj[v]){
			if(dist[z.fi] >dist[v]+z.se){
				dist[z.fi] = dist[v]+z.se;
				pq.push({dist[z.fi],z.fi});
			}
		}

	}
	cout<<dist[b+100];
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
//#define int long long
using namespace std;
typedef long long ll;
const int maxn=1007;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int HASH=131;

signed main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int palou=min(d,2*c);
    if(a<b)
    {
        cout<<(b-a)*palou+c<<endl;
    }
    else if(a==b) cout<<c<<endl;
    else if(a>b)
    {
        cout<<(a-b-1)*palou+c<<endl;
    }
    return 0;
}


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

#define pb push_back
#define eb emplace_back
#define unused [[maybe_unused]]
#define tempT template<class T>
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl
#define ans_exit(x) { cout << x << endl; exit(0); }
#define ans_return(x) { cout << x << endl; return; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define r_rep(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define reps(i, n, m) for (ll i = (ll)(n); i < (ll)(m); i++)
#define r_reps(i, n, m) for (ll i = (ll)(m) - 1; i >= (ll)(n); i--)
#define _prarr(a) {for(auto _e:a){cerr << _e << " ";} cerr << endl;}
#define debugarr(a) {cerr << #a << ": "; _prarr(a);}

using ll   unused = long long;
using ld   unused = long double;
using vl   unused = vector<ll>;
using vvl  unused = vector<vl>;
using vvvl unused = vector<vvl>;
using lp   unused = pair<ll, ll>;
using lmap unused = map<int, int>;

unused constexpr ll MOD = 1e9 + 7;
unused constexpr ll INF = 1 << 29;
unused constexpr ll LINF = 1LL << 61;
unused constexpr int DX[8] = {0, 1, 0,-1, 1, 1,-1,-1};
unused constexpr int DY[8] = {1, 0,-1, 0, 1,-1, 1,-1};
unused inline bool bit(ll b, ll i) { return b & (1LL << i); }
unused inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
unused inline ll mod(ll a, ll m = MOD) { return (a % m + m) % m; }
unused inline void modadd(ll &a, ll b, ll m = MOD) { a = mod(a + b, m); }
unused inline ll floordiv(ll a, ll b) { return a / b - (a < 0 && a % b); }
unused inline ll ceildiv(ll a, ll b) { return floordiv(a + b - 1, b); }
tempT unused bool chmin(T &a, T b) { if(a > b) {a = b; return 1;} return 0; }
tempT unused bool chmax(T &a, T b) { if(a < b) {a = b; return 1;} return 0; }

ll t;

ll f(ll x) {
    return (100 + t) * x / 100;
}

int main(){
    ll n; cin >> t >> n;
    ll losts = f(100) - 100;
    ll x = n / losts - !(n % losts);
    ll y = n - x * losts;

    vl a;
    reps(i, 100 * x, 100 * (x + 2)) {
        a.pb(f(i));
    }

    rep(i, 102) {
        if(a[i + 1] - a[i] == 1) continue;
        y--;
        if(!y) {
            cout << a[i] + 1 << endl;
        }
    }
}

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pip;
const int MAXN = 505;
const int INF = 1000000007;
int A[MAXN][MAXN], B[MAXN][MAXN], min_dist[MAXN][MAXN];
set <pip> dijk;
void update_dijk(int nr, int nc, int nwt)
{
	if (nwt < min_dist[nr][nc])
	{
		dijk.erase(pip(min_dist[nr][nc], pii(nr, nc)));
		min_dist[nr][nc] = nwt;
		dijk.insert(pip(min_dist[nr][nc], pii(nr, nc)));
	}
}
int main(int argc, char const *argv[])
{
	int r, c;
	cin>>r>>c;
	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c - 1; ++j)
		{
			cin>>A[i][j];
		}
	}
	for (int i = 0; i < r - 1; ++i)
	{
		for (int j = 0; j < c; ++j)
		{
			cin>>B[i][j];
		}
	}
	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c; ++j)
		{
			min_dist[i][j] = INF;
		}
	}

	min_dist[0][0] = 0;
	dijk.insert(pip(min_dist[0][0], pii(0,0)));

	while (!dijk.empty())
	{
		pip top = *dijk.begin();
		dijk.erase(dijk.begin());

		int cwt = top.first, cr = top.second.first, cc = top.second.second;
		int nr, nc, nwt;

		nr = cr;
		nc = cc + 1;
		if (nc < c)
		{
			nwt = cwt + A[cr][cc];
			update_dijk(nr, nc, nwt);
		}

		nr = cr;
		nc = cc - 1;
		if (nc >= 0)
		{
			nwt = cwt + A[cr][cc - 1];
			update_dijk(nr, nc, nwt);
		}

		nr = cr + 1;
		nc = cc;
		if (nr < r)
		{
			nwt = cwt + B[cr][cc];
			update_dijk(nr, nc, nwt);
		}

		for (int i = 1; i <= cr; ++i)
		{
			nr = cr - i;
			nc = cc;
			nwt = cwt + (i + 1);
			update_dijk(nr, nc, nwt);
		}
	}
	// for (int i = 0; i < r; ++i)
	// {
	// 	for (int j = 0; j < c; ++j)
	// 	{
	// 		cout<<min_dist[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	cout<<min_dist[r - 1][c - 1]<<"\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,dp[100][100];
double cnt,ans;
string s[100],t;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
        for(int j=0;j<n;j++){
            if(i==j)dp[i][j]=0;
            else if(s[i][j]=='0')dp[i][j]=1e9;
            else dp[i][j]=1;
        }
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i==j)continue;
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }
    for(int i=0;i<n;i++){
        cnt=1.0;
        for(int j=0;j<n;j++){
            if(dp[j][i]!=0&&dp[j][i]!=1e9)cnt+=1.0;
        }
        ans+=1/cnt;
    }
    cout<<setprecision(15)<<ans<<endl;
}

#include<bits/stdc++.h>

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double lf;
typedef long double Lf;
typedef pair<int, int> pii;

const int maxn = 105;

int n;
Lf ans;
int reach[maxn][maxn];
char s[maxn];

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

	FOR(i, 0, n){
		char buf[maxn]; scanf("%s", buf);
		FOR(j, 0, n)
			reach[i][j] = buf[j] - '0';
		reach[i][i] = 1;
	}

	FOR(k, 0, n) FOR(i, 0, n) FOR(j, 0, n)
		reach[i][j] |= (reach[i][k] & reach[k][j]);

	FOR(i, 0, n){
		int cnt = 0;
		FOR(j, 0, n)
			cnt += reach[j][i];
		ans += (Lf)1.0 / cnt;
	}

	printf("%.15Lf\n", ans);
	return 0;
}


#include <cstdio>
#include <vector>

constexpr int maxn = 2e5+10;

std::vector<int> g[maxn];

int dist[maxn], color[maxn], t = 1, l, r;
bool has[maxn];

void dfs(int u, int p = 0) {
	for(int v : g[u]) {
		if(v == p) continue;
		dist[v] = dist[u] + 1;
		dfs(v, u);
	}
}

void pre(int u, int p = 0) {
	has[u] = u == r;
	for(int& v : g[u]) {
		if(v != p) {
			pre(v, u);
			has[u] |= has[v];
			if(has[v]) std::swap(v, g[u][0]);
		}
	}
	if(g[u].size() && has[u]) std::swap(g[u][0], g[u].back());
}

void get(int u, int p = 0) {
	color[u] = t++;
	for(int v : g[u])
		if(v != p) get(v, u), t++;
}

int main() {
	int n; scanf("%d", &n);
	for(int i = 1, a, b; i < n; i++)
		scanf("%d %d", &a, &b), g[a].push_back(b), g[b].push_back(a);
	dfs(1);
	l = 1, r = 1;
	for(int i = 1; i <= n; i++)
		if(dist[i] > dist[l]) l = i;
	dist[l] = 0;
	dfs(l);
	for(int i = 1; i <= n; i++)
		if(dist[i] > dist[r]) r = i;
	pre(l);
	get(l);
	for(int i = 1; i <= n; i++)
		printf("%d%c", color[i], " \n"[i==n]);
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
struct point {
    int x, y, ind;
};
bool comp(point a, point b) {
    return a.x < b.x;
}
void solve() {
    int n; cin >> n;
    vector<point> a(n), b(n);
    for (int i = 0 ; i < n; ++i) {
        cin >> a[i].x >> a[i].y;
        b[i].x = a[i].y; b[i].y = a[i].x;
        a[i].ind = i;
        b[i].ind = i;
    }
    sort(a.begin(), a.end(), comp);
    sort(b.begin(), b.end(), comp);
    vector<pair<int, pair<int, int> > > dist;
    for (int i = 0; i < 2; ++i) {
        for (int j = n - 1; j >= n - 2; --j) {
            int d1 = abs(a[i].x - a[j].x), d2 = abs(b[i].x - b[j].x);
            int ind1 =  a[i].ind, ind2 = a[j].ind, ind3 = b[i].ind, ind4 = b[j].ind;
            if (ind1 > ind2) swap(ind1, ind2);
            if (ind3 > ind4) swap(ind3, ind4);
            dist.push_back({d1, {ind1, ind2}});
            dist.push_back({d2, {ind3, ind4}});
        }
    }
    sort(dist.begin(), dist.end());
    int m = dist.size();
    if (dist[m - 1].second.first == dist[m - 2].second.first && dist[m - 1].second.second == dist[m - 2].second.second ) {
        cout << dist[m - 3].first << endl;
    }
    else cout << dist[m - 2].first << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i)
    {
        solve();
    }
}


#include <bits/stdc++.h>

using namespace std;

#define flush cout.flush

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pl = pair<ll, ll>;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
const ld eps = 1e-9;
const ld PI = acos(-1);

ll cur = -1;

ll calc(vector<ll> &a, vector<ll> &b) {
    ll res = INF * INF;
    vector<pl> z;
    for (ll i = 0; i < a.size(); ++i) {
        if (a[i] == cur) {
            cur = -1;
            continue;
        }
        z.push_back({a[i], 0});
    }
    for (ll i = 0; i < b.size(); ++i) {
        z.push_back({b[i], 1});
    }
    ll last0 = -1, last1 = -1;
    sort(z.begin(), z.end());
    for (ll i = 0; i < z.size(); ++i) {
        if (z[i].second == 0) {
            if (last1 != -1 && abs(z[i].first - last1) < res) {
                res = min(res, abs(z[i].first - last1));
            }
            last0 = z[i].first;
        } else {
            if (last0 != -1) {
                res = min(res, abs(z[i].first - last0));
            }
            last1 = z[i].first;
        }
    }
    cur = last0;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<ll> r, g, b;

    for (ll i = 0; i < 2 * n; ++i) {
        ll a;
        cin >> a;
        char c;
        cin >> c;
        if (c == 'R')r.push_back(a);
        if (c == 'B')b.push_back(a);
        if (c == 'G')g.push_back(a);
    }
    if (r.size() % 2 == 0 && b.size() % 2 == 0) {
        cout << "0\n";
        return 0;
    }
    ll res;
    if (r.size() % 2 == 0) {
        res = calc(g, b);
        ll tmp = calc(r, g);
        res = min(res, tmp + calc(r, b));
        cur = -1;
        tmp = calc(r, b);
        res = min(res, tmp + calc(r, g));
        cur = -1;
    } else if (b.size() % 2 == 0) {
        res = calc(r, g);
        ll tmp = calc(b, g);
        res = min(res, tmp + calc(b, r));
        cur = -1;
        tmp = calc(b, r);
        res = min(res, tmp + calc(b, g));
        cur = -1;
    } else {
        res = calc(r, b);
        ll tmp = calc(g, r);
        res = min(res, tmp + calc(g, b));
        cur = -1;
        tmp = calc(g, b);
        res = min(res, tmp + calc(g, r));
        cur = -1;
    }
    cout << res << "\n";
    return 0;
}


#include <bits/stdc++.h>
#define lc (o<<1)
#define rc ((o<<1)|1)
using namespace std;
#define DebugP(x) cout << "Line" << __LINE__ << " " << #x << "=" << x << endl

typedef long long LL;
typedef complex<double> Comp;

const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const int modu = 998244353;

template<class T>
inline void read(T &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch<'0'||ch>'9')  {f|=(ch=='-');ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    x=f?-x:x;
    return;
}

template<class T, class ...U> void read(T &x, U& ... u) { read(x); read(u...); }

int main() {
	// freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);
	LL r, x, y;
	cin >> r >> x >> y;
	LL dis = x*x + y*y, R = r*r;
	if (R == 1) cout << (int)ceil(sqrt(dis)) << "\n";
	else
	if (dis < R) cout << "2\n";
	else if (dis == R) cout << "1\n";
	else {
		if (dis % R) cout << (int)floor(sqrt(dis)/r) + 1 << "\n";
		else cout << (int)floor(sqrt(dis)/r) << "\n";
	}
	return 0;
}

#include <iostream>
#include <iomanip>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <chrono>

using namespace std;

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

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

    int N; cin >> N;
    string S, X; cin >> S >> X;

    vector<set<int>> dp(N + 1);
    dp[N].insert(0);

    for (int i = N - 1; i >= 0; i--) {
        if (X[i] == 'A') {
            for (int r = 0; r < 7; r++) {
                if (dp[i + 1].count(10 * r % 7) && dp[i + 1].count((10 * r + S[i] - '0') % 7)) dp[i].insert(r);
            }
        } else {
            for (int r = 0; r < 7; r++) {
                if (dp[i + 1].count(10 * r % 7) || dp[i + 1].count((10 * r + S[i] - '0') % 7)) dp[i].insert(r);
            }
        }
    }

    cout << (dp[0].count(0) ? "Takahashi" : "Aoki") << endl;

    return 0;

}


#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <string.h>
using namespace std;
#define ll long long
#define INF 1000007
#define MAX 500007
#define EPS 1e-9
#define PI acos(-1.0)
#define nl "\n"
#define F first
#define S second
typedef vector<ll> vi;
typedef priority_queue<ll , vector<ll> , greater<ll> > pqmx;
typedef priority_queue<ll> pqmn;
typedef pair<ll , ll> pi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector< pair<int , int> > vpi;
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define yeS(GOOD)      GOOD ? cout<<"YES\n" : cout<<"NO\n"
#define all(a) a.begin() , a.end()
#define pb push_back
#define ar array
ll mod = LLONG_MAX;
ll binpow(ll a, ll b){ll res=1;a%=mod;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
ll binmul(ll a, ll b){ll res=0;a%=mod;while(b>0){if(b&1)res=(res + a)%mod;a=(a + a)%mod;b>>=1;}return res;}
ll area(pi a, pi b,pi c){return abs(a.F * b.S + b.F * c.S + c.F*a.S - a.S * b.F - b.S * c.F - c.S * a.F);}
ll gcd (ll a,ll b){if(b==0)return a;else return gcd (b, a % b);}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll min(ll a,ll b){if(a < b){return a;}return b;}
ll max(ll a,ll b){if(a > b){return a;}return b;}
double intlog(ll n ,ll base){return (double)log(n)/log(base);}
double DEG_to_RAD(double d) { return d * PI / 180.0; }
double RAD_to_DEG(double r) { return r * 180.0 / PI; }

ll n , t , m , temp , temp2, root , p ,q , k , i , j , r , u , v , w;

int dp[1005][1005];

int solve(int i,int j,vi & a,vi & b){
    if(i == n && j == m)return 0;
    if(i == n)return solve(i,j+1,a,b) + 1;
    if(j == m)return solve(i+1,j,a,b) + 1;
    if(dp[i][j] != -1)return dp[i][j];
    int res = INT_MAX;
    if(a[i] == b[j]){
        res = min(solve(i+1,j+1,a,b),res);
    }
    res = min(res, solve(i+1,j,a,b)+1);
    res = min(res, solve(i,j+1,a,b)+1);
    res = min(res, solve(i+1,j+1,a,b)+1);
    return dp[i][j] = res;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" ,stdin);
    freopen("output.txt" , "w" , stdout);
#endif
    cin>>n>>m>>p>>q;
    int dp[n][m];
    memset(dp,-1,sizeof(dp));
    vpi a;
    fr(i , p){
        cin>>u>>v;
        a.pb({u-1,v-1});
    }
    fr(i , q){
        cin>>u>>v;
        dp[u-1][v-1] = 4;
    }
    int res = 0;
    fr(i , a.size()){
        int x = a[i].F;
        int y = a[i].S;
        if(dp[x][y] != 1 && dp[x][y] != 3){
            p = x;
            q = y;
            while(p < n && dp[p][q] != 4){
                if(dp[p][q] == 2)dp[p][q] = 3;
                else dp[p][q] = 1;
                p++;
            }
            p = x;
            q = y;
            while(p >= 0 && dp[p][q] != 4){
                if(dp[p][q] == 2)dp[p][q] = 3;
                else dp[p][q] = 1;
                p--;
            }
        }
        if(dp[x][y] != 2 && dp[x][y] != 3){
            p = x;
            q = y;
            while(q < m && dp[p][q] != 4){
                if(dp[p][q] == 1)dp[p][q] = 3;
                else dp[p][q] = 2;
                q++;
            }
            p = x;
            q = y;
            while(q >= 0 && dp[p][q] != 4){
                if(dp[p][q] == 1)dp[p][q] = 3;
                else dp[p][q] = 2;
                q--;
            }
        }
    }
    fr(i , n){
        fr(j , m){
            if(dp[i][j] == 1 || dp[i][j] == 2 || dp[i][j] == 3){
                res++;
            }
              //  cout<<dp[i][j]<<" ";
        }
        //cout<<nl;
    }
    cout<<res<<nl;
#ifndef ONLINE_JUDGE
    cout << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s .\n";
#endif
}

#include<bits/stdc++.h>
#define pb push_back
using namespace std;
#define G getchar()
int read()
{
	int x=0; bool flg=false; char ch=G;
	for (;!isdigit(ch);ch=G) if (ch=='-') flg=true;
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return flg?-x:x;
}
#undef G
#define fi first
#define se second
typedef long long ll;
const int mod=998244353;
inline int upd(const int &x){return x+(x>>31&mod);}
inline void add(int &x,int y){x=upd(x+y-mod);}
inline void iadd(int &x,int y){x=upd(x-y);}
int qpow(int x,int y){
	int res=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1) res=1LL*res*x%mod;
	return res;
}
#define rep(i,l,r) for (int i(l);i<=r;i++)
#define per(i,l,r) for (int i(r);i>=l;i--)

int n,m,a[10010],b[10010],c[110];
bool vis[110];
int dir[110][110];
vector<int> e[110];
void dfs(int x){
	vis[x]=1;
	for (int y: e[x]){
		if (c[y]^c[x]) continue;
		if (!vis[y]) dir[x][y]=1,dir[y][x]=-1,dfs(y);
		else dir[x][y]=-1,dir[y][x]=1;
	}
}
void solve(){
	n=read(),m=read();
	rep(i,1,m) a[i]=read(),b[i]=read(),e[a[i]].pb(b[i]),e[b[i]].pb(a[i]);
	rep(i,1,n) c[i]=read();
	rep(i,1,n) if (!vis[i]) dfs(i);
	rep(i,1,m){
		if (c[a[i]]<c[b[i]]) puts("<-");
		else if (c[a[i]]>c[b[i]]) puts("->");
		else if (dir[a[i]][b[i]]==1) puts("->");
		else puts("<-");
	}
}
int main()
{
	for (int T=1;T--;) solve();
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

const int maxn = 112;

int h, w;
int a[maxn][maxn];

int main() {
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cin >> h >> w;
  FOR(i, 1, h) FOR(j, 1, w) cin >> a[i][j];
  int mn = a[1][1];
  FOR(i, 1, h) FOR(j, 1, w) chkmin(mn, a[i][j]);
  int ans = 0;
  FOR(i, 1, h) FOR(j, 1, w) ans += a[i][j] - mn;
  cout << ans;
}

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

int main()
{
    ll N, M; cin >> N >> M;
    vector<ll> h(N), w(M);
    vector<ll> ida(N - 1);
    for(ll i = 0; i < N; i++)cin >> h[i];
    for(ll i = 0; i < M; i++)cin >> w[i];
    sort(h.begin(), h.end());
    for(ll i = 0; i < N - 1; i++)ida[i] = h[i + 1] - h[i];

    vector<ll> est(N), ost(N);
    for(ll i = 0; i < N - 1; i++) {
        if(i % 2 == 0) est[i] = ida[i];
        else ost[i] = ida[i];
    }

    for(ll i = 1; i < N - 1; i++) {
        est[i] += est[i - 1], ost[i] += ost[i - 1];
    }
    est.insert(est.begin(), 0);
    ost.insert(ost.begin(), 0);

    ll nin = 2e9;
    for(auto t : w) {
        ll idx = lower_bound(h.begin(), h.end(), t) - h.begin();
        ll cost = 0;
        if(idx % 2 == 0) {
            cost += h[idx] - t;
            cost += est[idx];
            cost += ost[N-1] - ost[idx];

        } else {
            cost += t - h[idx - 1];
            cost += est[idx - 1];
            cost += ost[N-1] - ost[idx - 1];
        }
        nin = min(nin, cost);
    }
    cout << nin << endl;

}


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

int main() {
  int i,j,l;
  long long res=1;
  cin  >> l;

  for (int i = 1; i < 12; i++) {
    res = (res * (l-i))/i;
  }

  cout << res << endl;
  return 0;
}

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

#define   pf printf
#define   sc scanf
#define   nline cout << '\n'
#define   dbg(x) \
          cout << "debug " << #x << ": " << x << '\n';
#define   inp(t) cin >> (t)
#define   out(t) cout << (t)
#define   FOR(n,x) for(ll i = n; i < x; i++)
#define   FOR2(N,X) for(ll j = N; j < X; j++)
#define   wh(n) while(n--)
ll        fib[52] = {};
bool      isPrime[50];

void OJ(){
    // file I/O
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

ll LCM(ll x, ll y){ return x * (y/__gcd(x,y)); }

// returns nCr
ll nCr(int n, int r) {
    if(r > n - r) r = n - r;
    ll ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

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

    // Start
    int n; inp(n);

    out(nCr(n-1,11));
    nline;
}


//
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;

int main ()
{
    ios_base::sync_with_stdio (0); cin.tie (0); cout.tie (0);
    int x;
    cin >> x;
    int n = 100 - x % 100;
    cout << n;
}

#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)(x).size()
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;

#ifdef LOCAL//ONLINE_JUDGE
#include "D:\c_c++\template.h"
#else
#define debug(...) 42
#endif

ll powmod(ll a,ll b,ll mod) {
    ll res=1;a%=mod;
    for(;b;b>>=1){
        if(b&1)res=res*a%mod;
			a=a*a%mod;
    }
    return res;
}

void solve(){
	int n;
	cin>>n;
	if(n==1){
		cout<<0<<'\n';
	}else{
		cout<<n-1<<'\n';
	}
}

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


#include <bits/stdc++.h>
using namespace std;
#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define int long long
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define endl '\n'
#define pi 3.141592653589793238
#define mp make_pair
#define pb push_back
#define precise cout << fixed << setprecision(20)
#define ff first
#define ss second
#define uniq(v) v.resize(distance(v.begin(), unique(all(v))))
#define lb lower_bound
#define ub upper_bound
#define pii pair<int, int>
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vvi vector<vector<int>>
#define deb(x) cerr << #x << ' ' << '=' << ' ' << x << '\n'
const int mod = 1e9 + 7;
const int INF = 1e9;
const int MAXN = 300005;
template <typename T>
istream &operator>>(istream &in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> &v)
{
    for (T &x : v)
        out << x << " ";
    return out;
}
int min(int a, int b)
{
    if (a < b)
        return a;
    else
        return b;
}
int max(int a, int b)
{
    if (a > b)
        return a;
    else
        return b;
}
int power(int a, int b)
{
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int gcd(int p, int q)
{
    if (p % q == 0)
        return q;
    else
    {
        return gcd(q, p % q);
    }
}
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }
int sub(int a, int b) { return (((a - b) % mod) + mod) % mod; }
void primefactorisation(int n)
{
    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            int c = 0;
            while (n % i == 0)
            {
                c++;
                n = n / i;
            }
            cout << i << " " << c << endl;
        }
    }
    if (n > 1)
        cout << n << " " << 1 << endl;
}
signed main()
{
    fastio;
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        string s1, s2, s3;
        cin >> s1 >> s2 >> s3;
        for (int i = 1; i <= n; i++)
            cout << 1;
        for (int i = 1; i <= n; i++)
            cout << 0;
        cout << 1;
        cout << endl;
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MX = 200000;

char s[3][MX + 1], t[MX + 2];

bool check(int n) {
	for (int i = 0; i < 3; i++) {
		int k = 0;
		for (int it = 0; it < 2; it++) {
			for (int j = 0; j < 2 * n; j++) {
				if (s[i][j] == t[k]) k++;
			}
		}

		if (k < 2 * n + 1) return false;
	}

	return true;
}

int main() {
	int T;
	ignore = scanf("%d", &T);
	while (T--) {
		int n;
		ignore = scanf("%d %s %s %s", &n, s[0], s[1], s[2]);

		int len = max((2 * n + 1 - 9) / 2, 0);
		vector<int> lens = {1, 1, 1, len, 1, 1, 1, len, 1, 1, 1};
		for (int mask = 0; mask < (1 << lens.size()); mask++) {
			int i = 0;
			for (size_t j = 0; j < lens.size(); j++) {
				for (int k = 0; k < lens[j]; k++) {
					t[i++] = '0' + ((mask >> j) & 1);
				}
			}

			if (check(n)) break;
		}

		t[2 * n + 1] = 0;
		printf("%s\n", t);
	}

	return 0;
}


    #include <bits/stdc++.h>

    // #include <ext/pb_ds/assoc_container.hpp>
    // #include <ext/rope>
    // #include <ext/pb_ds/tree_policy.hpp>
    // #include <ext/pb_ds/trie_policy.hpp>
    // using namespace __gnu_pbds;
    // using namespace __gnu_cxx;
    // typedef tree<long long, null_type, std::less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
    // typedef trie<std::string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>Trie;

    using namespace std;
    #define rep(i,a,n) for (int i=a;i<n;i++)
    #define per(i,a,n) for (int i=n-1;i>=a;i--)
    #define pb push_back
    #define mp make_pair
    #define all(x) (x).begin(),(x).end()
    #define fi first
    #define se second
    #define sz(x) ((int)(x).size())
    #define rdv(x) long long x; cin>>x;
    #define deb(x) cout<<#x<<"="<<x<<endl;
    #define inf 1e18
    #define endl "\n"

    typedef vector<long long> vll;
    typedef long long ll;
    typedef pair<long long,long long> pii;
    typedef long double ld;
    mt19937 mrand(random_device{}());
    const ll mod=100000000000007;
    int rnd(int x) { return mrand() % x;}
    ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
    ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
    bool prime[200001];
    void SieveOfEratosthenes()
    {
        memset(prime, true, sizeof(prime));
        prime[1]=false;
        for (int p=2; p*p<=200000; p++)
        {
            if (prime[p] == true)
            {
                for (int i=p*p; i<=200000; i += p)
                    prime[i] = false;
            }
        }
        return;
    }

    ll ceil(ll x,ll y)
    {
        ll ans=x/y;
        if(x%y)
            ans++;

        return ans;
    }

    void file_i_o(){
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }

    void YN(bool flag)
    {
        if(flag)
            cout<<"YES";
        else
            cout<<"NO";
    }
    #define pi 3.1415926535
    // head

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

        map<ll,vll>mp;

        rep(i,0,n)
        {
            ll x,c;
            cin>>x>>c;

            mp[c].pb(x);
        }

        ll l=0,r=0,left=0,right=0;

        for(auto it:mp)
        {
            ll nl=inf,nr=-inf;

            for(auto i:it.se)
            {
                nl=min(nl,i);
                nr=max(nr,i);
            }

            ll ldi=inf,rdi=inf;

            //L->L2->R2
            rdi=min(rdi,abs(l-nl)+abs(nr-nl)+left);
            ldi=min(ldi,abs(l-nr)+abs(nr-nl)+left);
            ldi=min(ldi,abs(r-nr)+abs(nr-nl)+right);
            rdi=min(rdi,abs(r-nl)+abs(nr-nl)+right);

            l=nl;
            r=nr;
            left=ldi;
            right=rdi;
        }

        cout<<min(left+abs(l),right+abs(r));
        cout<<"\n";
    }
    int main()
    {
        ios_base::sync_with_stdio(false); 			//Used to reduce the time
        cin.tie(NULL);
        cout.tie(NULL);

        file_i_o();

        ll T=1;
        //cin>>T;
        //ll temp=T;
        while(T--)
        {
            //cout<<"Case #"<<temp-T<<": ";
            solve();
        }
        cerr<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<" ms\n";
    }

#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int INF = 1e9 + 1, MOD = 1e9 + 7; /// think
const ll LINF = 2e18;

const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

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

inline void solve() {
    int l, r;
    cin >> l >> r;
    ll ans = 0;
    int f = max(0, r - l - l + 1);
    ans = f * (f + 1ll) / 2ll;
    cout << ans << '\n';
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}


#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

template <class T>
class bit {
    public:
    bit(int n);
    bit(T* array, int n);
    ~bit();
    void add(int x, T value);
    T get(int x) const; // [0, x]
    T get(int x, int y) const; // [x, y]
    int lower_bound(T value) const;
    int upper_bound(T value) const;
    int rlower_bound(T value) const;
    int rupper_bound(T value) const;

    private:
    int size;
    int high;
    T* data;
};

template <class T> bit<T>::bit(int n) : size(n + 1), high(1 << (31 - __builtin_clz(n))) {
    data = (T *)calloc(size, sizeof(T));
}

template <class T> bit<T>::bit(T* array, int n) : bit(n) {
    for (int i = 0; i < n; i++) data[i + 1] = array[i];
    for (int i = 1; i < n; i++) {
        if (i + (i & -i) < size) data[i + (i & -i)] += data[i];
    }
}

template <class T> bit<T>::~bit() {
    free(data);
}

template <class T> void bit<T>::add(int x, T value) {
    for (x++; x < size; x += x & -x) data[x] += value;
}

template <class T> T bit<T>::get(int x) const {
    T value = 0;
    for (x++; x > 0; x -= x & -x) value += data[x];
    return value;
}

template <class T> T bit<T>::get(int x, int y) const {
    return get(y) - get(x - 1);
}

template <class T> int bit<T>::lower_bound(T value) const {
    int x = 0;
    for (int i = high; i > 0; i >>= 1) {
        if (x + i < size && data[x + i] < value) value -= data[x += i];
    }
    return x;
}

template <class T> int bit<T>::upper_bound(T value) const {
    return lower_bound(value + 1);
}

template <class T> int bit<T>::rlower_bound(T value) const {
    int x = 0;
    for (int i = high; i > 0; i >>= 1) {
        if (x + i < size && data[x + i] <= value) value -= data[x += i];
    }
    return x - 1;
}

template <class T> int bit<T>::rupper_bound(T value) const {
    return rlower_bound(value - 1);
}

int x[200000];
int y[200000];
int xm[200001];
int ym[200001];

int main() {
    int h, w, m, i, j;
    long long ans = 0;
    vector<pair<int, int>> v;

    scanf("%d %d %d", &h, &w, &m);

    for (i = 0; i < m; i++) scanf("%d %d", &x[i], &y[i]);

    for (i = 1; i <= w; i++) xm[i] = h;
    for (i = 1; i <= h; i++) ym[i] = w;

    for (i = 0; i < m; i++) {
        xm[y[i]] = min(xm[y[i]], x[i] - 1);
        ym[x[i]] = min(ym[x[i]], y[i] - 1);
    }

    for (i = 2; i <= ym[1]; i++) v.push_back(make_pair(xm[i], i));

    sort(v.begin(), v.end());

    bit<long long> b(w + 2);

    for (i = 1, j = 0; i <= h; i++) {
        if (i <= xm[1]) {
            ans += ym[i];

            b.add(ym[i] + 1, 1);
        } else {
            b.add(0, 1);
        }

        while (j < v.size() && v[j].first <= i) {
            int x = v[j].first;
            int y = v[j].second;

            ans += b.get(y);

            j++;
        }
    }

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

    return 0;
}

# include <bits/stdc++.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
# define rrep(i,r,l) for(int i=(r); i>=l; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
typedef long long lint;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define INF ((1LL<<62)-(1LL<<31)) /*オーバーフローしない程度に大きい数*/
#define MOD 1000000007
lint gcd(lint a,lint b){
    if(!b)return a;
    return gcd(b,a%b);
}

lint lcm(lint a,lint b){
    return a*b/gcd(a,b);
}

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

void solve() {
    int h,w,n;
    cin >> h >>w >> n;
    vector<int> a(w,h),b(h,w);

    rep(i,0,n){
        int x,y;
        cin >> x >> y;x--,y--;
        chmin(a[y],x);
        chmin(b[x],y);
    }
    lint ans=0;
    rep(y,0,b[0]) ans+=a[y];
    rep(x,0,a[0]) ans+=b[x];

    BinaryIndexedTree<int> t(w);
    rep(i,0,b[0]) t.add(i, 1);

    vector<vector<int>> ends(h+1);
    rep(y,0,b[0]) ends[a[y]].push_back(y);

    rep(x,0,a[0]){
        for(int y:ends[x]) t.add(y,-1);
        ans-=t.sum(b[x]-1);
    }
    cout << ans << endl;

}

signed main() {

    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define p pair<long long,long long>
#define endl '\n'
#define iof  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pi acos(-1)
int fx[]={0,0,1,-1,1,1,-1,-1};
int fy[]={1,-1,0,0,-1,1,-1,1};
const int mxn=1e9+7;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
    int n;
    cin>>n;
    int m;
    cin>>m;
    vector
vp(m);
    for(auto &i:vp)
    {
        cin>>i.first>>i.second;
    }
    int k;
    cin>>k;
    vector
vk(k);
    for(auto &i:vk)
    {
        cin>>i.first>>i.second;
    }
    int mx=0;
    for(int mask=0;mask<(1<<k);mask++)
    {
        map<int,int>mp;
        for(int i=0;i<k;i++)
        {
            if((1<<i)&mask)mp[vk[i].first]++;
            else mp[vk[i].second]++;
        }
        int ans=0;
        for(auto i:vp)
        {
            if(mp[i.first]&&mp[i.second])ans++;
        }
        mx=max(mx,ans);
    }
    cout<<mx<<endl;
}

#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define RSort(a) sort(a.rbegin(), a.rend())
#define Output(a) cout << a << endl

typedef long long int ll;
typedef vector<int> vi;
typedef vector<long long> vll;

const int INF = 1<<30;
const ll MOD = 1000000007;

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

string to2(int bina, int k){
    int ans = 0;
    for(int i = 0; bina > 0; i++){
        ans = ans + (bina % 2) * pow(10, i);
        bina /= 2;
    }
    string result = to_string(ans);
    while(result.size() < k){
        result = "0" + result;
    }
    return result;
}

int main(){
    ll n, m; cin >> n >> m;
    vll a(m), b(m);
    rep(i, m) cin >> a[i] >> b[i];
    ll k; cin >> k;
    vll c(k), d(k);
    rep(i, k) cin >> c[i] >> d[i];
    ll ans = 0;

    rep(bit, (1<<k)){
        vll s;

        rep(i, k){
            if(bit & 1 << i){
                s.push_back(1);
            }else{
                s.push_back(0);
            }
        }

        vll t(n);
        rep(i, (int)s.size()){
            if(s[i]){
                t[c[i]-1] = 1;
            }else{
                t[d[i]-1] = 1;
            }
        }

        ll com = 0;
        rep(i, m){
            if(t[a[i]-1] == 1 and t[b[i]-1] == 1) com++;
        }
        ans = max(com, ans);
    }
    cout << ans << endl;
    return 0;
}


#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll M = 1; M <= 10000000; M++){
        if(2*N - M*M + M > 0 && (2*N - M*M + M)%(2*M) == 0){
            ans++;
        }
    }
    cout << ans*2;
}

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

int main(){
    string S[3];
    unordered_map<char,int> lab; int k = 0;
    rep(i,3){
        cin >> S[i];
        rep(j,S[i].size()){
            char c = S[i][j];
            if(!lab.count(c)){
                lab[c] = k; k++;
            }
        }
    }
    if(lab.size()>10){
        cout << "UNSOLVABLE" << endl; return 0;
    }
    int a = lab.size(); vector<ll> per;
    rep(i,10){
        per.push_back((ll)i);
    }
    do{
        ll s[3];
        rep(i,3){
            s[i] = 0; ll base = 1; int l = S[i].size();
            //if(i==2) cout << s[2] << endl;
            rep(j,l){
                s[i] += base*(per[lab[S[i][l-1-j]]]); base *= 10;
                //if(i==2) cout << lab[S[i][l-1-j]] << endl;
            }
        }
        //cout << s[2] << endl;
        /*if(per[0]==9&&per[1]==5&&per[2]==6&&per[3]==7&&
        per[4]==1&&per[5]==0&&per[6]==8&&per[7]==2){
            cout << s[0] << endl;
            cout << s[1] << endl;
            cout << s[2] << endl;
        }*/
        if(s[0]+s[1]==s[2]){
            bool ch = true;
            rep(i,3){
                if(per[lab[S[i][0]]]==0) ch = false;
            }
            if(ch){
                rep(i,3){
                    cout << s[i] << endl;
                }
                return 0;
            }
        }
    }while(next_permutation(per.begin(),per.end()));
    cout << "UNSOLVABLE" << endl;
}


#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define read read1<ll>()
# define Type template<typename T>
Type T read1(){
	T t=0;
	char k;
	bool vis=0;
	do (k=getchar())=='-'&&(vis=1);while('0'>k||k>'9');
	while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar();
	return vis?-t:t;
}
# define fre(k) freopen(k".in","r",stdin);freopen(k".out","w",stdout)
int main(){
	int x=read,y=read,z=read;
	if(x==y||y==z||x==z)printf("%d",x^y^z);
	else puts("0");
	return 0;
}

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

#define ll long long
#define rep(i,a,n) for(int i=a;i<n;i++)
#define fastin  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define mk make_pair

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


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

#define int long long
#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;

const int MOD = 1e9 + 7;
const ll  INF = 1e16;
inline int mod(ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit(ll b, ll i) { return b & (1 << i); }
inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
template<class T>
bool chmin(T &a, T b){ if(a > b){ a = b; return 1; } return 0; }
template<class T>
bool chmax(T &a, T b){ if(a < b){ a = b; return 1; } return 0; }
// struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

inline int f(int a, int b, int c, int p, int q, int r) {
    return abs(p - a) + abs(q - b) + max(0LL, r - c);
}

vi x(17), y(17), z(17);
inline int f(int from, int to) {
    return f(x[from], y[from], z[from], x[to], y[to], z[to]);
}

signed main() {
    int n;
    cin >> n;
    rep(i,n) cin >> x[i] >> y[i] >> z[i];

    vector<vvi> dp(1 << n, vvi(n, vi(n, INF)));

    rep(i,n-1){
        dp[1 << i][i][i] = f(0, i+1) + f(i+1, 0);
    }

    rep(S, 1 << (n-1)) {
        rep(i, n-1) {
            if(not bit(S, i)) {
                rep(st, n-1){
                    if(not bit(S, st)) continue;
                    rep(gl, n-1) {
                        if(not bit(S, gl)) continue;
                        chmin(dp[S | 1 << i][st][i],
                            dp[S][st][gl] + f(gl+1, i+1) - f(gl+1, 0) + f(i+1, 0));
                        chmin(dp[S | 1 << i][i][gl],
                            dp[S][st][gl] + f(i+1, st+1) - f(0, st+1) + f(0, i+1));
                    }
                }
            }
        }
    }

    int ans = INF;
    for(auto S : dp[(1 << (n-1)) - 1]) {
        for(auto i : S) {
            chmin(ans, i);
        }
    }

    cout << ans << endl;
}

#include <bits/stdc++.h>

using namespace std;

int main(){
  string s;
  cin >> s;
  for(int i = 0;i < 10; ++i){
    bool check = true;
    for(int j = 0;j < s.length()/2; ++j){
      if(s[j] != s[s.length() - j -1]){
        check = false;
        break;
      }
    }
    if(check){
      cout << "Yes" << endl;
      return 0;
    }
    s = "0" + s;
  }

  cout << "No" << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i <= r; ++i)
const int N = 2e6 + 5;
const int Mod = 1e9 + 7;
int n, m, k, fac[N], inv[N];

int Inc (int a, int b) { return (a += b) >= Mod ? a - Mod : a; }
int Dec (int a, int b) { return (a -= b) < 0 ? a + Mod : a; }
int Mul (int a, int b) { return 1ll * a * b % Mod; }
int fpow (int a, int b) { int ans = 1; for (; b; a = Mul(a, a), b >>= 1) if(b & 1) ans = Mul(ans, a); return ans; }
int C (int n, int m) { return n < m ? 0 : Mul(fac[n], Mul(inv[m], inv[n - m])); }

int main () {
	cin >> n >> m >> k;
	fac[0] = inv[0] = 1;
	rep(i, 1, n + m) fac[i] = Mul(fac[i - 1], i), inv[i] = fpow(fac[i], Mod - 2);
	if(k >= n) printf("%d", C(n + m, n));
	else if(m + k < n) puts("0");
	else printf("%d", Dec(C(n + m, n), C(n + m, n - k - 1)));
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n';
#define faster ios_base::sync_with_stdio(0);

int main()

{
    faster
    int a,b,c;
    cin>>a>>b>>c;
    if(a*a+b*b<c*c)
        cout<<"Yes"<<endl;
    if(a*a+b*b>=c*c)
        cout<<"No"<<endl;
    return 0;

}