#include <bits/stdc++.h>
using namespace std;
#define clear(a) memset(a, 0, sizeof(a))
#define full(a) memset(a, 0x3f, sizeof(a))
#define fornext(x, i) for(int i = head[x], y = ver[i]; i; i = nxt[i], y = ver[i])
#define mset(a, b) memset(a, b, sizeof(a))
#define Rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define dRep(i, a, b) for(int i = (a); i >= (b); --i)
#define IOset(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout);
#define int ll
#define un unsigned
#define ll long long
#define db double
#define dbg cout<<"c "

template<typename _T>
inline void rd(_T &dig) {
	int flg; char c;
	flg = dig = 0;
	while (c = getchar(), !isdigit(c)) if (c == '-') flg = 1;
	while (isdigit(c)) dig = dig * 10 + c - '0', c = getchar();
	if (flg) dig = -dig;
}

template <typename _T, typename ...Args>
inline void rd(_T &dig, Args &...args) {
	rd(dig);
	rd(args...);
}

const int N = 505;
int f[N][N], g[N], a[N], b[N], ty[N], n, ex[N], id[N];	//-1~1 / 0

void no() {
	puts("No");
	exit(0);
}

signed main() {
	rd(n);
	Rep(i, 1, n) {
		rd(a[i], b[i]);
		if (a[i] != -1 && b[i] != -1 && a[i] >= b[i]) no();
		if (a[i] != -1) {
			if (ex[a[i]]) no();
			ex[a[i]] = 1;
			ty[a[i]] = -1;
			id[a[i]] = i;
		}
		if (b[i] != -1) {
			if (ex[b[i]]) no();
			ex[b[i]] = 1;
			ty[b[i]] = 1;
			id[b[i]] = i;
		}
	}
	n *= 2;
	/*
	Rep(i, 2, (n + 2) / 2) {
		Rep(j, 1, n + 3 - 2 * i) {
			Rep(k, j, j + i - 2) {
				if (id[k]) {
					if (ty[k] == 1 || (b[id[k]] != -1 && b[id[k]] != k + i - 1)) {
						f[j][i] = -1;
						break;
					}
				}
				if (id[k + i - 1]) {
					if (ty[k + i - 1] == -1 || (a[id[k + i - 1]] != -1 && a[id[k + i - 1]] != k)) {
						f[j][i] = -1;
						break;
					}
				}
			}
		}
	}*/
	int l, r;
	Rep(i, 1, n) Rep(j, 1, i) f[i][j] = -1;
	Rep(i, 1, n) Rep(j, i + 1, n) {
		if (j - i + 1 % 2 == 1) {
			f[i][j] = -1;
			continue;
		}
		l = (j-i + 3) / 2;
		Rep(k, i, i + l - 2) {/*
			if (id[k]) {
				if (ty[k] == -1 && ((b[id[k]] == -1 && !id[k + l - 1]) || b[id[l]] == k + l - 1));
				else f[i][j] = -1;
			}
			if (id[r]) {
				if (ty[r] == 1 && ((a[id[r]] == -1 && !id[k]) || a[id[r]] == k));
				else f[i][j] = -1;
			}*/
			r = k + l - 1;
			if(id[k] && id[r] && id[k]!=id[r]) f[i][j]=-1;
			if(id[k] && !id[r]&&(ty[k]!=-1||b[id[k]]!=-1)) f[i][j]=-1;
			if(id[r] && !id[k]&&(ty[r]!=1||a[id[r]]!=-1)) f[i][j]=-1;
		}
	}
	g[0] = 1;
	Rep(i, 1, n) {
		Rep(j, 0, i - 2) if (g[j] && (f[j + 1][i] != -1)) g[i] = 1;
	}
	if (g[n]) puts("Yes");
	else puts("No");
	return 0;
}

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int n;

int p[201];

vector<pair<int,int> > v;
map<pair<int, int>, int > mp;

bool solve(int le, int ri){
    if(mp[{le, ri}] == 1) return true;
    else if(mp[{le, ri}] == -1) return false;
    bool ret = false;
    for(int i=le + 1; i <= ri - 2;i += 2){
        if(solve(le, i) && solve(i+1, ri)) ret = true;
    }
    if(ret){
        mp[{le, ri}] = 1;
        return true;
    }

    int m = ri - le + 1;
    m /= 2;

    ret = true;
    for(int i = le ; i < le + m ;i++){
        if(p[i] == -1){
            if(p[i+m] == -1){
                continue;
            }
            else{
                if(v[p[i+m]].first != -1 && v[p[i+m]].first != i) ret = false;
                if(v[p[i+m]].second != -1 && v[p[i+m]].second != i+m) ret = false;
            }
        }else{
            if(p[i+m] == -1){
                if(v[p[i]].first != -1 && v[p[i]].first != i) ret = false;
                if(v[p[i]].second != -1 && v[p[i]].second != i+m) ret = false;
            }
            else{
                if(p[i] != p[i+m]) ret = false;
                if(v[p[i]].first != -1 && v[p[i]].first != i) ret = false;
                if(v[p[i]].second != -1 && v[p[i]].second != i+m) ret = false;
            }
        }
    }
    if(ret){
        mp[{le, ri}] = 1;
        return true;
    }else{
        mp[{le, ri}] = -1;
        return false;
    }
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int a, b;

    bool ok = true;
    memset(p, -1, sizeof(p));
    for(int i=0;i<n;i++){
        cin >> a >> b;
        if(a != -1){
            if(p[a] != -1){
                ok = false;
            }
            p[a] = i;
        }
        if(b != -1){
            if(p[b] != -1 || b < a){
                ok = false;
            }
            p[b] = i;
        }

        v.push_back({a, b});
    }
    if(!ok){
        cout << "No" << endl;
        return 0;
    }
    if(solve(1, n*2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long maxn=330;
long long n,f[maxn][maxn]={};
int main(){
	scanf("%lld",&n);
	f[0][0]=1;for(long long i=1;i<=n;i++){f[i][0]=1;for(long long j=1;j<=i;j++)f[i][j]=f[i-1][j-1]+f[i-1][j];}
	printf("%lld",f[n-1][11]);
	return 0;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; cin >> N;
  vector<LL> fact(N + 1);
  set<LL> s;
  for (int i = 2; i <= 11; ++i) s.insert(i);

  for (LL i = 0; i <= N-12; ++i) fact[i] = 1;
  for (LL i = N-11; i < N; ++i) {
    LL k = i;
    for (LL x : s) {
      if (k % x == 0) {
        k /= x;
        s.erase(x);
      }
    }
    fact[i] = k * fact[i-1];
  }
  for (auto x : s) {
    fact[N-1] /= x;
  }
  cout << fact[N-1] << endl;
}


#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using uint=unsigned int;
using ull=unsigned long long;
const ll LL_MAX=LLONG_MAX;

class union_find{
private:
  vector<ll> par;
  vector<ll> siz;

public:
  union_find(ll n) : par(n),siz(n,1LL){
    for (ll i=0;i<n;i++) par[i]=i;
  }

  ll root(ll x){
    ll i=x;
    queue<ll> line;
    while(i!=par[i]){
      line.push(i);
      i=par[i];
    }
    ll l=line.size();
    for (ll j=0;j<l;j++){
      par[line.front()]=i;
      line.pop();
    }
    return i;
  }

  ll size(ll x){
    return siz[root(x)];
  }

  bool unite(ll x,ll y){
    x=root(x);
    y=root(y);
    if (x==y) return false;
    if (size(x)<size(y)){
      par[x]=y;
      siz[y]+=siz[x];
    }
    else{
      par[y]=x;
      siz[x]+=siz[y];
    }
    return true;
  }

  bool same(ll x,ll y){
    if (root(x)==root(y)) return true;
    else return false;
  }
};

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
void outl(T x){
  cout << x << endl;
}
template < >
void outl<int>(int x){
  printf("%d\n",x);
}
template < >
void outl<double>(double x){
  printf("%.16lf\n",x);
}
template < >
void outl<char>(char x){
  printf("%c\n",x);
}
template < >
void outl<string>(string x){
  printf("%s\n",x.c_str());
}
template < >
void outl<uint>(uint x){
  printf("%u\n",x);
}
template < >
void outl<ll>(ll x){
  printf("%lld\n",x);
}
template < >
void outl<ull>(ull x){
  printf("%llu\n",x);
}
void outl(){
  printf("\n");
}

template <typename T>
void out(T x){
  cout << x << flush;
}
template < >
void out<int>(int x){
  printf("%d",x);
}
template < >
void out<char>(char x){
  printf("%c",x);
}
template < >
void out<double>(double x){
  printf("%.16lf",x);
}
template < >
void out<string>(string x){
  printf("%s",x.c_str());
}
template < >
void out<uint>(uint x){
  printf("%u",x);
}
template < >
void out<ll>(ll x){
  printf("%lld",x);
}
template < >
void out<ull>(ull x){
  printf("%llu",x);
}

void outyes(){
  printf("Yes\n");
}
void outno(){
  printf("No\n");
}

void outyn(bool x){
  if (x) printf("Yes\n");
  else printf("No\n");
}

void outsp(){
  printf(" ");
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

template <typename T>
T npr(T x,T y){
  T loop=max(x-y,y),ans=1;
  for (T i=loop;i<=x;i++){
    ans*=i;
  }
  return ans;
}//xPy

template <typename T>
T ncr(T x,T y){
  T loop=min(x,x-y),ans=npr(x,y);
  for (T i=1;i<=loop;i++){
    ans/=i;
  }
  return ans;
}//xCy

template <typename T>
T fac(T x){
    if (x==1) return 1;
    return x*fac(x-1);
}

void div1(ll &x) {
    x%=1000000007;
}

ll mypow(ll x,ll n){
    ll ans=1;
    for (ll i=1;i<=n;i = i<<1){
        if ((n & i)== i){//ループj回目で2進表記のときにj桁目が1かどうか判定
            ans*=x;
        }
        x*=x;
    }
    return ans;
}

ll divpow(ll x,ll n){
    ll ans=1;
    div1(x);
    for (ll i=1;i<=n;i = i<<1){
        if ((n & i)== i){//ループj回目で2進表記のときにj桁目が1かどうか判定
            ans*=x;
            div1(ans);
        }
        x*=x;
        div1(x);
    }
    return ans;
}

int main(){
    ll n=in,k=in;
    for (int i=0;i<k;i++){
        if (n%200==0) n/=200;
        else n=n*1000+200;
    }
    outl(n);
}

///In the name of GOD
//#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 3e5 + 10;
ll n, cnt;
string s, t;
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    /*
    cin >> n >> s >> t;
    for(int i = 0; i < n; i ++){
        cnt += (s[i] == '0');
        cnt -= (t[i] == '0');
    }
    if(cnt != 0){
        return cout << -1, 0;
    }
    */
    cin >> n;
    ll ans = n;
    for(int i = 0; (1LL << i) <= n; i ++){
        ll b = i, val = (1LL << i);
        ll a = n / val, c = n - a * val;
        ans = min(ans, a + b + c);
    }
    cout << ans << '\n';
    return 0;
}
/*!
    HE'S AN INSTIGATOR,
    ENEMY ELIMINATOR,
    AND WHEN HE KNOCKS YOU BETTER
    YOU BETTER LET HIM IN.
*/
//! N.N


#include<bits/stdc++.h>
template <typename _Tp>void read(_Tp &x){
	char ch(getchar());bool f(false);while(!isdigit(ch))f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch))x=x*10+(ch&15),ch=getchar();
	if(f)x=-x;
}
template <typename _Tp,typename... Args>void read(_Tp &t,Args &...args){read(t);read(args...);}
const int N=200005;
typedef long long ll;
int a[N];
int main(){
	int n;read(n);
	int mx=0;
	ll s=0,S=0;
	for(int i=1;i<=n;++i){
		read(a[i]),mx=std::max(a[i],mx);
		s+=a[i],S+=s;
		printf("%lld\n",S+1LL*i*mx);
	}
	return 0;
}

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

ll ll_pow(ll a, ll n) {
  ll ans = 1;
  for(ll i = 0; i < n; i++) ans *= a;
  return ans;
}

vector<vector<int>> G;
bool temp[100001];

void dfs(int v){
  	if(temp[v]) return;
  	temp[v] = true;
  	for(auto vv:G[v]) dfs(vv);
}

int main() {
  double n;
   cin >> n;
  if(n*1.08 >= 206 && n*1.08 < 207) cout << "so-so" <<endl;
  else if(n*1.08 < 206) cout << "Yay!" <<endl;
  else cout <<":(" <<endl;
  return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define pll pair<ll,ll>
#define vpll vector< pll >
#define mpll map<ll,ll>
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define s(v) v.size()
#define test ll t;cin>>t;while(t--)
#define vec vector<ll>
#define read0(v,n) for(int i=0;i<n;i++)cin>>v[i];
#define read1(v,n) for(int i=1;i<=n;i++)cin>>v[i];
#define trav(a,x) for (auto& a: x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cut(x) {cout<<x;return 0;}
#define print(x) {cout<<x<<nl;continue;}
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORB(i,a,b) for(int i=a;i>=b;i--)
#define err1(a) {cout<<#a<<' '<<a<<nl;}
#define err2(a,b) {cout<<#a<<' '<<a<<' '<<#b<<' '<<b<<nl;}
#define mem(a,b) memset(a,b,sizeof(a))

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define nl '\n'
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define oset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
ll gcd(ll a, ll b)
{
	if (b==0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
ll bpow(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

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

	fast
	ll k,n,m;
	cin>>k>>n>>m;
	vec a(k),b(k);
	read0(a,k);
	FOR(i,0,k-1)a[i]*=m;
	ll tot=0;
	set<pll> diff;
	FOR(i,0,k-1)
	{
	    b[i]=a[i]/n;
	    tot+=b[i];
	    diff.insert({a[i]-b[i]*n,i});
	}
	tot=m-tot;
	while(tot--)
    {
        pll p=*diff.rbegin();
        diff.erase(prev(diff.end()));
        b[p.sc]++;
    }
    trav(it,b)cout<<it<<' ';cout<<nl;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int K, N, M;
int A[101010];

i64 rceil(i64 a, i64 b) {
	if (a < 0) return 0;
	return (a - 1) / b + 1;
}

vector<i64> solve(i64 df) {
	vector<i64> low, high;
	for (int i = 0; i < K; ++i) {
		// -df <= N * x - M * A[i] <= df

		low.push_back(rceil((i64)M * A[i] - df, N));
		high.push_back(((i64)M * A[i] + df) / N);
	}

	i64 ls = 0, hs = 0;
	for (int i = 0; i < K; ++i) {
		if (low[i] > high[i]) return {};
		ls += low[i];
		hs += high[i];
	}
	if (!(ls <= M && M <= hs)) return {};

	i64 ext = M - ls;
	vector<i64> ret;
	for (int i = 0; i < K; ++i) {
		i64 v = low[i] + min(high[i] - low[i], ext);
		ext -= v - low[i];
		ret.push_back(v);
	}
	return ret;
}

int main()
{
	scanf("%d%d%d", &K, &N, &M);
	for (int i = 0; i < K; ++i) scanf("%d", A + i);

	i64 lf = 0, rg = 1LL << 60LL;
	while (lf < rg) {
		i64 mid = (lf + rg) / 2;
		if (solve(mid).size() > 0) {
			rg = mid;
		} else {
			lf = mid + 1;
		}
	}
	auto ans = solve(lf);
	for (int i = 0; i < K; ++i) printf("%lld%c", ans[i], i == K - 1 ? '\n' : ' ');
	return 0;
}


#include "bits/stdc++.h"
#include <chrono>
#include <random>
#define lli long long int
using namespace std;
#define mod 1000000007
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 1000000000
#define common cout << "Case #" << w+1 << ": "
#define maxn 10010

void setIO(string name) {
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

template< typename T>
void PVecPrint(vector<T>&v)
{
    for(int i=0;i<(int)v.size();i++)
        cout << v[i].first << "," << v[i].second << ' ';
    cout << '\n';
}
template<class T>
void VecPrint(vector<T>&v)
{
    for(int i=0;i<v.size();i++)
        cout << v[i] << ' ';
    cout << '\n';
}
/*-------------------------------------------------------------------Code-----------------------------------------------------------------*/

int main()
{
    int n;
    cin >> n;
    n-=3;
    vector<int>v{6,10,15};
    int t=12;
    set<int>s;
    while (t<10000 and n>0)
    {
        v.push_back(t);
        s.insert(t);
        n-=1;
        t+=6;
    }
    // cout << n << ' ' << s.size() << ' ' << v.size() << '\n';
    t=20;
    while (t<10000 and n>0)
    {
        if(s.find(t)==s.end())
        {
            v.push_back(t);
            s.insert(t);
            n-=1;
        }
        t+=10;
    }
    // cout << n << ' ' << s.size() << ' ' << v.size() << '\n';
    t=30;
    while (t<10000 and n>0)
    {
        if(s.find(t)==s.end())
        {
            v.push_back(t);
            s.insert(t);
            n-=1;
        }
        t+=15;
    }
    // cout << s.size() << ' ' << v.size() << '\n';
    // cout << n << '\n';
    VecPrint<int>(v);
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define all(v) v.begin(),v.end()

const int mod = 1e9 + 7;

int main (){
    fast_io;
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        a[i] = 1;
    a[0] = 3 * 5;
    a[n - 1] = 2 * 5;
    map<int, int> freq;
    for (int i = 0; i < n; i++) {
        freq[a[i]]++;
    }
    for (int i = 0; i < n - 1; i++) {
        if (freq[a[i]] > 1 || a[i] == 1) {
            for (int j = 2; j <= 10000; j++) {
                if (j % 10 && j % 6 && j % 15)
                    continue;
                if (freq.count(j) == 0) {
                    freq[j]++;
                    freq[a[i]]--;
                    a[i] = j;
                    break;
                }
            }
        }
    }
    for (auto it: freq) {
        assert(it.second < 2);
    }
    for (int i = 0; i < n; i++)
        cout << a[i] << ' ';
    cout << endl;
}


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

signed main() {
    ll N, K;
    cin >> N >> K;
    rep(i,K)
    {
        if(N % 200 == 0)
        {
            N /= 200;
        }
        else
        {
            string s = to_string(N) + "200";
            N = stoll(s);
        }
    }
    cout << N << endl;
}

#include <iostream>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cassert>
#include <functional>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int gcd(ll x, ll y) {
    if(x % y == 0) {
        return y;
    } else {
        return gcd(y, x % y);
    }
}

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

      string s;

      for(int i = 0; i< k; i++){
          if(n%200 == 0) n/=200;
          else {
              s = to_string(n);
              s +=  "200";

              n = stoll(s);
          }
      }

      cout << n << endl;
      return 0;
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<string> S(N);
    for (string& s : S) {
        cin >> s;
    }

    vector<int64_t> reached_num(N, 0);
    for (int64_t i = 0; i < N; i++) {
        //iからスタートして到達できるところに到達回数+1をしていく
        vector<bool> curr_reach(N, false);
        stack<int64_t> st;
        st.push(i);
        while (!st.empty()) {
            int64_t top = st.top();
            st.pop();
            if (curr_reach[top]) {
                continue;
            }
            curr_reach[top] = true;

            for (int64_t j = 0; j < N; j++) {
                if (S[top][j] == '1' && !curr_reach[j]) {
                    st.push(j);
                }
            }
        }

        for (int64_t j = 0; j < N; j++) {
            if (curr_reach[j]) {
                reached_num[j]++;
            }
        }
    }

    double ans = 0;
    for (int64_t i = 0; i < N; i++) {
        ans += 1.0 / reached_num[i];
    }
    cout << setprecision(10) << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

void chemthan() {
    int n; cin >> n;
    vector<string> s(n);
    FOR(i, 0, n) cin >> s[i];
    vector<vi> g(n, vi(n));
    FOR(i, 0, n) g[i][i] = 1;
    FOR(i, 0, n) FOR(j, 0, n) if (i != j) {
        g[i][j] = s[i][j] == '1';
    }
    FOR(k, 0, n) FOR(i, 0, n) FOR(j, 0, n) {
        g[i][j] |= g[i][k] & g[k][j];
    }
    double res = 0;
    FOR(i, 0, n) {
        int num = 0;
        FOR(j, 0, n) if (i ^ j) {
            if (g[j][i]) {
                num++;
            }
        }
        res += 1.0 / (num + 1);
    }
    cout << prec(9) << res << "\n";
}

int32_t main(int32_t argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define reps(i,s,n) for(int i=s; i<n; i++)
#define per(i,n) for(int i=n-1; i>=0; i--)
#define pers(i,n,s) for(int i=n-1; i>=s; i--)
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define lb(v,n) lower_bound(all(v),n)
#define lbi(v,n) int(lower_bound(all(v),n) - v.begin())
#define ub(v,n) upper_bound(all(v),n)
#define ubi(v,n) int(upper_bound(all(v),n) - v.begin())

#define mod 1000000007
#define infi 1010000000
#define infl 1100000000000000000

#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define IN(n,m,v) rep(i,n) rep(j,m){cin >> v[i][j];}
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define cYES cout << "YES" << endl
#define cNO cout << "NO" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

void solve(){

    int N,M;
    cin >> N >> M;
    ve<pair<int,string>> A(M);
    rep(i,M){
        string s;
        cin >> s;
        A[i].fi = si(s);
        A[i].se = s;
    }
    sort(all(A));
    //rep(i,M) cout << A[i].se << endl;

    ve<ve<char>> G(N,ve<char>(N,'A'));

    int t = 0;
    int id = 0;
    string s = "";
    rep(i,N){
        t = 0;
        while (t < N) {
            id = -1;
            int ns = 0;
            while (si(s) > 0) {
                ns = si(s);
                rep(j,M) if(A[j].fi > 0 && ns <= A[j].fi && A[j].fi-ns <= N-t){
                    if(s == A[j].se.substr(0,ns)){
                        id = j;
                        break;
                    }
                }
                if(id >= 0) break;
                if(si(s) == 1){
                    s = "";
                    break;
                }
                s = s.substr(1,si(s)-1);
            }
            ns = si(s);
            if(id == -1){
                rep(j,M) if(A[j].fi > 0 && A[j].fi-ns <= N-t){
                    id = j;
                    break;
                }
            }

            s = "";

            if(N-t >= A[id].fi-ns){
                reps(j,ns,A[id].fi) G[i][t] = A[id].se[j], t++, s += A[id].se[j];
                A[id].fi = -1;
                id = -1;
            }else{
                t = 0;
                break;
            }

            if(si(s) == 0) t++;
        }
    }

    rep(i,N) {
        rep(j,N) cout << G[i][j];
        cout << endl;
    }

    //id = 0;
    //rep(j,M) if(A[j].fi < 0) id++;
    //cout << id csp M << endl;

}

int main(){

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

    //int ti = clock();

    solve();

    //cout << "Execution Time:" <<  1.0 * (clock() - ti) / CLOCKS_PER_SEC << "sec" << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    srand(time(NULL));
    ll n,m;
    cin >> n >> m;
    vector<string>che(m);
    string ra ="ABCDEFGH";
    for(int i=0;i<m;i++){
        cin>>che.at(i);
    }
    sort(che.begin(),che.end());
    ll check =0;
    for(int i=0;i<n;i++){
        string d;
        while(d.size()<n){
            if(d.size()+che.at(check).size()>n){
                while(d.size()<n){
                d+='.';
                }
                break;
            }
            d+=che.at(check);
            check++;
        }
        if(d.size()>n){
            string g;
            for(int j=0;j<n;j++){
            g+=d.at(j);
            }
            d=g;
        }
        cout<<d<<endl;
    }
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  pair<int, int> l, r;
  for (int i = 0; i < (1 << (n - 1)); ++i) {
    int a;
    cin >> a;
    l = max(l, make_pair(a, i));
  }
  for (int i = 0; i < (1 << (n - 1)); ++i) {
    int a;
    cin >> a;
    r = max(r, make_pair(a, (1 << (n - 1)) + i));
  }
  if (l.first > r.first) {
    cout << r.second + 1 << "\n";
  } else {
    cout << l.second + 1 << "\n";
  }
  return 0;
}

#include<bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif
using namespace std;
//using namespace atcoder;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    int n;
    cin >> n;
    pair<ll, int> a{0, -1};
    pair<ll, int> b{0, -1};
    rep(i, pow(2, n-1)){
        ll v;
        cin >> v;
        if(a.first < v){
            a.first = v;
            a.second = i+1;
        }
    }
    rep(i, pow(2, n-1)){
        ll v;
        cin >> v;
        if(b.first < v){
            b.first = v;
            b.second = i+1+pow(2, n-1);
        }
    }
    cout << min(a, b).second << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
using namespace __gnu_pbds;
ll int mod=1e9+7;
typedef tree<ll int, null_type, less<ll int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll int mul(ll int x, ll int y)
{
    return (x * 1ll * y) % mod;
}

ll int add(ll int x,ll int y)
{
    x += y;
    while(x >= mod) x -= mod;
    while(x < 0) x += mod;
    return x;
}

long long power(long long a, long long b,ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res*a)%m;
        a =(a*a)%m;
        b >>= 1;
    }
    return res%m;
}

void query(ll int t,ll int i,ll int j,ll int x)
{
    cout<<"? "<<t<<" "<<i<<" "<<j<<" "<<x<<endl;
    cout.flush();
}

vector<ll int> pr;
bool prime[10000000];
void Sieve(ll int n)
{
    memset(prime, true, sizeof(prime));
    prime[1]=false;

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

int main() {
    IOS;
    ll int n;
    cin>>n;
    cout<<6<<" "<<10<<" "<<15<<" ";
    n-=3;
    map<int,int>mp;
    for(int i=2;i*6<=10000 && n>0;i++)
    {
        if(mp.count(6*i))
        continue;
        cout<<6*i<<" ";
        mp[6*i]++;
        n--;
    }
    for(int i=2;i*10<=10000 && n>0;i++)
    {
        if(mp.count(10*i))
        continue;
        cout<<10*i<<" ";
        mp[10*i]++;
        n--;
    }
    for(int i=2;i*15<=10000 && n>0;i++)
    {
        if(mp.count(15*i))
        continue;
        cout<<15*i<<" ";
        mp[15*i]++;
        n--;
    }
    cout<<endl;
}


#include<bits/stdc++.h>
// no of bits to store no 2e5 is 19
// 2e5 ka 5 times square root lene se 2 or 3 ke pass pahunch jate hai
using namespace std;

#define int               long long
#define mod               998244353
#define MOD               998244353
#define MAX               1000000000
#define inf               2e18
#define ff                first
#define ss                second
#define mp                make_pair
#define pb                push_back
#define pii               pair<int,int>
#define mii               map<int, int>
#define all(x)            (x).begin(), (x).end()
#define fill(a,b)         memset(a, b, sizeof(a))
#define sp(x,y)           fixed<<setprecision(y)<<x
#define setbits(x)        __builtin_popcount(x)
#define fast_in_out       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define ll                long long

//   powermod(a,b,m) ==  powermod(a,b%(m-1),m)  when m is prime fermat's theorem a^(p-1) %p=1 p is prime
int powermod(int a,int b,int c) //  gives (a^b)%c
{
    int ans = 1,tempans=a%c;
    while(b>0)
    {
        if((b&1)==1)
        {
            ans=(ans*tempans)%c;
        }
             tempans=(tempans*tempans)%c;
             b=b>>1;
    }
    return ans;
}

int modinverse(int a,int m)   // gives a inverse wrt m and m is prime
{
    return powermod(a,m-2,m);
}

ll add(ll x, ll y) {
   x += y;
   if (x >= mod) return x - mod;
   return x;
}
ll sub(ll x, ll y) {
   x -= y;
   if (x < 0) return x + mod;
   return x;
}
ll mult(ll x, ll y) {
   return (x * y) % mod;
}
// my template                                              m
// prime factorization                                      pf
// ncr and factorials                                       ncr
// matrix exponentiation of fibonacci series in log(n)      matexpofib
// cycles in a graph                                        cycle
// prime factorization in log(n)                            spf
// disjoint set union                                       dsu

int spf[200005];
void pre()  // call it in main
{
    spf[0]=1;
    spf[1]=1;
    for(int i=2;i<=2e5;i++){
        spf[i]=i;
    }
    for(int i=2;i*i<=2e5;i++){
        if(spf[i]==i){
            for(int j=i*i;j<=2e5;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}

int fact[2000005],inversefact[2000005];

void precomputations(int n)  // is function ko main main ek bar call kr do
{
    fact[0]=1;
    inversefact[0]=1;
    for(int i=1;i<n;i++)
    {
        fact[i]=(fact[i-1]*i)%MOD;
        inversefact[i]=(inversefact[i-1]*modinverse(i,MOD))%MOD;

    }
}

int ncr(int n,int r)
{
   if(n==r|r==0)
        return 1;
    if(r>n)
        return 0;
    if(n<0)
        return 0;
    int temp= fact[n];
    temp= (temp*inversefact[r])%MOD;
    temp=(temp*inversefact[n-r])%MOD;
    return temp;
}
void solve()
{
   int n,m;
   cin>>n>>m;
   int ans =0;
   for(int i=1;i<=m;i++)
   {

         int z=i;
         int temp=1;
         while(z!=1)   // in solve function
         {
               int k = z,cnt=0;
               while(k%spf[z]==0)// (n-1+cnt)
               {
                     cnt++;
                     k/=spf[z];
               }
               temp= mult(temp,ncr(n-1+cnt,n-1));

                  z=k;
         }
         //cout<<i<<" "<<temp<<" "<<endl;
         ans=add(ans,temp);

   }
   cout<<ans;

}

int32_t main()
{
  fast_in_out;

  int t=1;//cin>>t;
  int count=0;
 pre();precomputations(2000005);

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

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define test(x) cout << "Line(" << __LINE__ << ") " #x << ' ' << x << endl
#define printv(x) {\
	for (auto i : x) cout << i << ' ';\
	cout << endl;\
}
#define pii pair <int, int>
#define pll pair <lli, lli>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<typename A, typename B>
ostream& operator << (ostream& o, pair<A, B> a){
    return o << a.X << ' ' << a.Y;
}
template<typename A, typename B>
istream& operator >> (istream& o, pair<A, B> &a){
    return o >> a.X >> a.Y;
}
const int mod = 998244353, abc = 864197532, N = 300101, logN = 19, K = 333;

lli modpow(lli a, int b) {
    lli ans = 1;
    for (; b; b >>= 1, a = a * a % mod) {
        if (b & 1) ans = ans * a % mod;
    }
    return ans;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    if (n == 1 || m == 1) {
        cout << modpow(k, n + m - 1) << endl;
        return 0;
    }
    lli ans = 0;
    for (int i = 1; i <= k; ++i) {
        ans = (ans + (modpow(i, n) + mod - modpow(i - 1, n)) % mod * modpow(k - i + 1, m)) % mod;
    }
    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 60 + 5;

int n;
ll m;
char s[MAXN];

bool chk(ll base)
{
	ll cur = 0;
	for(int i=1; i<=n; ++i)
	{
		if(cur > m / base + 1) return 0;
		cur = cur * base + s[i] - '0';
		if(cur > m) return 0;
	}
	return cur <= m;
}

int main(void)
{
	scanf("%s%lld",s+1,&m);
	n = strlen(s+1);

	int mx = 0;
	for(int i=1; i<=n; ++i) mx = max(mx, s[i] - '0');

	if(n == 1) return printf("%d",s[1] - '0' <= m? 1: 0), 0;

	ll l = mx+1, r = 1e18;
	if(!chk(l)) return printf("0"), 0;
	while(l<r)
	{
		ll mid = (l+r+1)>>1;
		if(chk(mid)) l = mid;
		else r = mid-1;
	}

	printf("%lld",l - mx);
	return 0;
}

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;

#define endl "\n"
#define eb emplace_back
#define mem(a, b) memset(a , b , sizeof(a))

const ll INF = 0x3f3f3f3f;
// const ll mod = 998244353;
// const ll mod = 1e9 + 7;
const double eps = 1e-6;
const double PI = acos(-1);
const double R = 0.57721566490153286060651209;

void solve() {
    string s; ll M;
    cin >> s >> M;
    ll x = 0;
    for(int i = 0;i < (int)s.length(); i++) x = max(x, (ll)(s[i]- '0'));
    x++;
    if(s.length() == 1) {
        if(s[0] - '0' <= M) cout << 1 << endl;
        else cout << 0 << endl;
        return ;
    }
    ll l = 1, r = 1e18 + 10;
    ll t = 0;
    while(l <= r) {
        ll mid = (l + r) / 2;
        __int128 ans = 0;
        __int128 k = mid;
        bool flag = 1;
        for(int i = 0;i < (int)s.length(); i++) {
            ans = ans * k + (ll)(s[i] - '0');
            if(ans <= 0) { flag = 0; break; }
        }
        if(flag && ans <= M) {
            l = mid + 1;
            t = mid;
        }
        else r = mid - 1;
    }
    cout << max(0ll, t - x + 1) << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    // cin.tie(nullptr);
    // cout.tie(nullptr);
#ifdef FZT_ACM_LOCAL
    freopen("../in.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
    signed test_index_for_debug = 1;
    char acm_local_for_debug = 0;
    do {
        if (acm_local_for_debug == '$') exit(0);
        if (test_index_for_debug > 20)
            throw runtime_error("Check the stdin!!!");
        auto start_clock_for_debug = clock();
        solve();
        auto end_clock_for_debug = clock();
        cout << "Test " << test_index_for_debug << " successful" << endl;
        cerr << "Test " << test_index_for_debug++ << " Run Time: "
             << double(end_clock_for_debug - start_clock_for_debug) / CLOCKS_PER_SEC << "s" << endl;
        cout << "--------------------------------------------------" << endl;
    } while (cin >> acm_local_for_debug && cin.putback(acm_local_for_debug));
#else
    solve();
#endif
    return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
ll mod= 1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main(){
  ll n,x;
  cin>>n>>x;
  string s;
  cin>>s;
  ll pt=x;
  rep(i,0,n){
    if(s[i]=='o')pt++;
    else{
      if(pt>0)pt--;
    }
  }
  cout<<pt;
}

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;
using Mat = vector<vector<ll>>;

Mat dot(Mat a, Mat b)
{
    Mat c = Mat(3, VL(3, 0));
    rep(i, 3)
    {
        rep(j, 3)
        {
            rep(k, 3)
            {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    return c;
}

Mat rotP()
{
    Mat c = {{0, 1, 0},
             {-1, 0, 0},
             {0, 0, 1}};
    return c;
}

Mat rotN()
{
    Mat c = {{0, -1, 0},
             {1, 0, 0},
             {0, 0, 1}};
    return c;
}

Mat invX(ll p)
{
    Mat x = {{1, 0, 0},
             {0, 1, -p},
             {0, 0, 1}};
    Mat y = {{1, 0, 0},
             {0, -1, 0},
             {0, 0, 1}};
    Mat z = {{1, 0, 0},
             {0, 1, p},
             {0, 0, 1}};
    z = dot(z, y);
    z = dot(z, x);
    return z;
}

Mat invY(ll p)
{
    Mat x = {{1, 0, -p},
             {0, 1, 0},
             {0, 0, 1}};
    Mat y = {{-1, 0, 0},
             {0, 1, 0},
             {0, 0, 1}};
    Mat z = {{1, 0, p},
             {0, 1, 0},
             {0, 0, 1}};
    z = dot(z, y);
    z = dot(z, x);
    return z;
}

int main()
{
    int n;
    cin >> n;
    vector<pair<ll, ll>> ps(n);
    rep(i, n)
    {
        cin >> ps[i].first >> ps[i].second;
    }
    int m;
    cin >> m;
    vector<Mat> mats(m + 1);
    mats[0] = {{1, 0, 0},
               {0, 1, 0},
               {0, 0, 1}};
    rep(i, m)
    {
        int op;
        cin >> op;
        if (op == 1)
        {
            mats[i + 1] = dot(rotP(), mats[i]);
        }
        else if (op == 2)
        {
            mats[i + 1] = dot(rotN(), mats[i]);
        }
        else if (op == 3)
        {
            ll p;
            cin >> p;
            mats[i + 1] = dot(invY(p), mats[i]);
        }
        else
        {
            ll p;
            cin >> p;
            mats[i + 1] = dot(invX(p), mats[i]);
        }
    }
    int q;
    cin >> q;
    rep(i, q)
    {
        int a, b;
        cin >> a >> b;
        b--;
        ll x = ps[b].first;
        ll y = ps[b].second;
        cout << x * mats[a][0][0] + y * mats[a][0][1] + mats[a][0][2] << " "
             << x * mats[a][1][0] + y * mats[a][1][1] + mats[a][1][2] << endl;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

int gcd(int x, int y) {
	if (x < y) gcd(y, x);
	if (y == 0) return x;
	return gcd(y, x % y);
}
int A[100010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	int ans = 0;
	for (int i = 0; i < N; i++) ans = gcd(ans, A[i]);
	cout << ans << endl;
}

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;

int n, a, ans;

int main() {
	cin >> n >> ans;
	for(int i = 1; i < n; ++i)		cin >> a, ans = __gcd(ans, a);
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define p_q priority_queue
#define m_p make_pair
#define pb push_back
#define ld long double
#define F first
#define S second
#define ull unsigned long long
#define mod 1000000007
#define md 998244353
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define int ll
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll qpow(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string iots(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int stoi(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int n;
int a[200100];
int t[200100];
int mx,mn;
signed main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n)cin>>a[i]>>t[i];
	int d=0;
	mx=1e18;mn=-1e18;
	rep(i,n)
	{
		if(t[i]==1)
		{
			d+=a[i];
			mn+=a[i];
			mx+=a[i];
		}
		if(t[i]==2)
		{
			mn=max(mn,a[i]);
			mx=max(mx,a[i]);
		 }
		if(t[i]==3)
		{
			mn=min(mn,a[i]);
			mx=min(mx,a[i]);
		}
	}
	int q;
	cin>>q;
	rep(i,q)
	{
		int x;
		cin>>x;
		x+=d;
		if(x>mx)x=mx;
		if(x<mn)x=mn;
		cout<<x<<endl;
	}
	return 0;
}
//特判判全
//循环边界
//精度足够
//注意初值

#include <bits/stdc++.h>

using namespace std;

#define maxn 200005
#define ll long long int

ll n, q, x;
ll a, t, low, high, add;

int main(){
	cin >> n;
	low = -1000000000;
	high = 1000000000;
	add = 0;
	for(int i = 0; i < n; i++){
		cin >> a >> t;
		if(t == 1){
			low += a;
			high += a;
			add += a;
		}else if(t == 2){
			low = max(low, a);
			high = max(high, a);
		}else{
			low = min(low, a);
			high = min(high, a);
		}
	}
	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> x;
		//cout << min(high, max(low, x+add)) << "\n";
		cout << max(low, min(high, x+add)) << "\n";
	}
    return 0;
}


#include <iostream>

int main()
{
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  std::cout << b - c << std::endl;
  return 0;
}

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

int64_t solve(int64_t a, int64_t b, int64_t c, int64_t d) {
    // TODO: edit here
    return b - c;
}

// generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;
    auto ans = solve(a, b, c, d);
    cout << ans << endl;
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

using ll = long long;

const int maxn = 1e6 + 5;
const ll mod = 998244353;

ll fac[maxn], ifac[maxn], inv[maxn];

ll nck(ll n, ll k) {
    //cout<<"nck: "<<n<<" "<<k<<endl;

    if (n<k) return 0;
    return fac[n]*ifac[k]%mod*ifac[n-k]%mod;
}

void gen_inv() {
    fac[0]=inv[0]=ifac[0]=1;
    fac[1]=inv[1]=ifac[1]=1;

    for (int i=2; i<maxn; i++) {
	fac[i]=fac[i-1]*i%mod;
	inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	ifac[i]=ifac[i-1]*inv[i]%mod;
    }
}

void add(ll &x, ll y) {
    x %= mod;
    y %= mod;
    x += y;
    x %= mod;
}

ll brute(ll N, ll M) {
    vector<ll> dp(M+1, 0);
    dp[1] = 1;

    for (int it=0; it<N; it++) {
	vector<ll> ndp(M+1, 0);
	for (int i=1; i<=M; i++) {
	    for (int j=1; j<=i; j++) {
		if (i%j==0) {
		    add(ndp[i], dp[j]);
		}
	    }
	}
	dp = ndp;
    }

    ll res = 0;
    for (ll x: dp) {
	add(res, x);
    }
    return res;
}

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

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

    gen_inv();

    ll N, M;
    cin>>N>>M;

    ll res = 0;

    // iterate over last element
    for (int i=1; i<=M; i++) {
	ll bins = N;
	ll cur = 1;
	auto pf = count_pf(i);
	for (ll balls: pf) {
	    cur *= nck(bins-1+balls, balls);
	    cur %= mod;
	}
	//cout<<i<<":"<<cur<<endl;
	add(res, cur);
    }

    //assert(res==brute(N,M));

    out(res);
    return 0;
}

#include<bits/stdc++.h>
#define ll long long int
#define pll pair<ll,ll>
#define vpll vector< pll >
#define mpll map<ll,ll>
#define MOD 998244353
#define all(v) v.begin(),v.end()
#define s(v) v.size()
#define test ll t;cin>>t;while(t--)
#define vec vector<ll>
#define read0(v,n) for(int i=0;i<n;i++)cin>>v[i];
#define read1(v,n) for(int i=1;i<=n;i++)cin>>v[i];
#define trav(a,x) for (auto& a: x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cut(x) {cout<<x;return 0;}
#define print(x) {cout<<x<<nl;continue;}
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORB(i,a,b) for(int i=a;i>=b;i--)
#define err1(a) {cout<<#a<<' '<<a<<nl;}
#define err2(a,b) {cout<<#a<<' '<<a<<' '<<#b<<' '<<b<<nl;}

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define nl '\n'
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define oset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
ll gcd(ll a, ll b)
{
	if (b==0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
ll bpow(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}
mpll factorise(ll n)
{
    mpll fact;
    while (n % 2 == 0)
    {
        fact[2]++;
        n = n/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
           fact[i]++;
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        fact[n]++;
    return fact;
}
const int N=1e6;
ll fac[N];
void precompute()
{
    fac[0]=1;
    FOR(i,1,(ll)5e5)fac[i]=(i*fac[i-1])%MOD;
}
ll ncr(ll n,ll r)
{
    return (((fac[n]*bpow(fac[r],MOD-2))%MOD)*(bpow(fac[n-r],MOD-2)))%MOD;
}

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

	fast
	ll n,m;
	cin>>n>>m;
	precompute();
	ll sum=0;
	FOR(i,1,m)
	{
	    mpll temp=factorise(i);
	    ll x=1;
	    trav(it,temp)
	    {
	        x=(x*ncr(n+it.sc-1,n-1))%MOD;
	    }
	    sum=(sum+x)%MOD;
	}
	cut(sum)

}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  for (int i = 0; i < N; i++){
    cout << i * 2 % N + 1 << ' ' << (i * 2 + 1) % N + 1 << endl;
  }
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (ll i=(ll)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const ll INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(ll x=pow(10,7)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { ll d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll modpow(ll x, ll p) { ll result = 1, now = 1, pm = x; while (now<=p) { if (p&now) { result = result * pm % MOD; } now*=2; pm = pm*pm % MOD; } return result; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main() {
  ll N; cin >> N;
  rep(i,N) {
    ll a = i*2, b = i*2+1;
    ll tca = 0; while ((1<<tca)<=a) tca++;
    while (a>=N) { if (a&(1<<tca)) a ^= (1<<tca); tca--; }
    ll tcb = 0; while ((1<<tcb)<=b) tcb++;
    while (b>=N) { if (b&(1<<tcb)) b ^= (1<<tcb); tcb--; }
    a++; b++;
    cout << a << " " << b << endl;
  }
  return 0;
}


/*** author: yuji9511 ***/
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
ostream& operator<<(ostream& os, lpair& h){ os << "(" << h.first << ", " << h.second << ")"; return os;}
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(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; }

void solve(){
    ll N;
    cin >> N;
    vll a(N), b(N), c(N), d(N), e(N);
    vector<vll> v(N, vll(5));
    rep(i,0,N){
        rep(j,0,5){
            cin >> v[i][j];
        }
    }
    ll ans = 0;
    vector<vector<lpair> > alt(1LL<<5);
    rep(i,0,N){
        rep(bit,1,(1LL<<5)){
            ll min_val = INF;
            rep(j,0,5){
                if(bit & (1LL<<j)){
                    chmin(min_val, v[i][j]);
                }
            }
            alt[bit].push_back({min_val, i});
        }
    }
    rep(i,0,1LL<<5){
        sort(alt[i].begin(), alt[i].end(), greater<lpair>());
    }

    rep(i,0,N){
        rep(j,i+1,N){
            ll lv = 0, rv = 1e9+7;
            while(rv - lv > 1){
                ll mid = (rv + lv) / 2;
                ll bit = 0;
                rep(k,0,5){
                    if(max(v[i][k], v[j][k]) < mid){
                        bit += (1LL<<k);
                    }
                }
                if(bit == 0){
                    lv = mid;
                    continue;
                }
                bool ok = false;
                ll n = min(3LL, (ll)alt[bit].size());
                rep(k,0,n){
                    if(alt[bit][k].first >= mid && alt[bit][k].second != i && alt[bit][k].second != j){
                        ok = true;
                    }
                }
                if(ok){
                    lv = mid;
                }else{
                    rv = mid;
                }
            }
            // print(i,j,lv);
            chmax(ans, lv);
        }
    }
    print(ans);

}

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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#pragma GCC optimize ("Ofast")
#pragma GCC optimization ("unroll-loops, no-stack-protector")
#pragma GCC target ("avx")
#pragma GCC target ("avx2")
#pragma GCC target ("fma")
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI acos(-1)
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// 1 2 3 4 2 3 1
bool vis[200005], strong[200005];
ll p[200005], a[200005], b[200005];
int main(){
	fastio;
	ll n; cin >> n;
	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 >> p[i], p[i]--;
	ll ans = 0, cyc_len = 0;
	for (ll i = 0; i < n; i++){
		if (p[i] == i) continue;
		if (a[i] <= b[p[i]]){
			cout << -1 << "\n"; return 0;
		}
		else{
			if (!vis[i]){
				vis[i] = 1; ll ii = p[i];
				ll mx = a[i], mxdx = i;
				ll cyc_len = 1;
				while (ii != i){
					if (mx < a[ii]){
						mx = a[ii], mxdx = ii;
					}
					vis[ii] = 1; cyc_len++;
					ii = p[ii];
				}
				strong[mxdx] = 1;
				ans += (cyc_len - 1);
			}
		}
	}
	cout << ans << "\n";
	for (ll i = 0; i < n; i++){
		if (strong[i]){
			ll ii = p[i];
			while (ii != i){
				cout << i + 1 << " " << ii + 1 << "\n"; ii = p[ii];
			}
		}
	}
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>
#include <ctype.h>

using namespace std;

typedef long long ll;

const int INF = (1<<30)-1;
const ll LINF = 1e18;

#define rep(i, n) for (int i = 0; i < n; i++)

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

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

int main() {
    int n, m, k;    cin >> n >> m >> k;
    vector<int> a(n+1, 0);
    rep(i, k) {
        int x;  cin >> x;
        a[x] = 1;
    }
    for (int i = 0; i < n+1; i++) {
        int j = i;
        while (j < n+1 && a[j] == 1)
            j++;
        if (j - i >= m) {
            cout << -1 << endl;
            return 0;
        }
        i = j;
    }
    vector<double> b(n+m+10), c(n+m+10), sb(n+m+10, 0), sc(n+m+10, 0);
    for (int i = n-1; i >= 0; i--) {
        if (a[i]) {
            b[i] = 1;
            c[i] = 0;
        }
        else {
            b[i] = (sb[i+1] - sb[i+m+1]) / m;
            c[i] = (sc[i+1] - sc[i+m+1]) / m + 1;
        }
        sb[i] = b[i] + sb[i+1];
        sc[i] = c[i] + sc[i+1];
    }
    cout << fixed << std::setprecision(15) << c[0] / (1 - b[0]) << endl;
    return 0;
}

//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;

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

// --- original code ---
// int X, Y;
// char S[10][12];
// int res;
// {
//   int i, j, k;
//   rd(X,Y,S(X));
//   rep(i,1,X) rep(j,1,Y){
//     k = 0;
//     if(S[i-1][j-1] == '#') k++;
//     if(S[i-1][j  ] == '#') k++;
//     if(S[i  ][j-1] == '#') k++;
//     if(S[i  ][j  ] == '#') k++;
//     res += k % 2;
//   }
//   wt(res);
// }


#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
#define N 110
#define M 5000
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
vector<vector<ll>> conn(N);
vector<vector<ll>> path(M,vector<ll>(2));
vector<ll> fin(M,0);
vector<ll> c(N);

void bfs(ll x) {
    REP(i,conn[x].size()){
        ll next = conn[x][i];
        if (fin[next]!=0) continue;
        if (path[next][0]==x) {
            fin[next]=1;
            bfs(path[next][1]);
        }
        else {
            fin[next]=2;
            bfs(path[next][0]);
        }
    }
    return;
}

int main(){
    ll n, m; cin >> n >> m;
    REP(i,m) {
        ll a, b; cin >> a >> b;a--;b--;
        path[i][0]=a;path[i][1]=b;
        conn[a].pb(i);
        conn[b].pb(i);
    }
    REP(i,n) cin >> c[i];
    REP(i,m) {
        // cout << i << " " << path[i][0] << " " << path[i][1] << " " << c[path[i][0]] << " " << c[path[i][1]] << endl;
        if (c[path[i][0]]>c[path[i][1]]) fin[i]=1;
        else if (c[path[i][0]]<c[path[i][1]]) fin[i]=2;
    }
    // REP(i,m) cout << fin[i] << " ";
    // cout << endl;
    ll now = 0;
    while (now<m) {
        if (fin[now]!=0) {
            now++;
            continue;
        }
        fin[now]=1;
        bfs(path[now][1]);
        // cout << "test1" << " " << now << endl;
        // REP(i,m) cout << fin[i] << " ";
        // cout << endl;
    }
    REP(i,m) {
        if (fin[i]==1) cout << "->" << endl;
        else cout << "<-" << endl;
    }
}

#include <bits/stdc++.h>
#define ll long long
const int INF = 1000000000;
using namespace std;
const int MAX = 105;

int edgeDir[MAX * MAX], c[MAX], used[MAX];

vector<pair<int, pair<int, int> > > g[MAX];

void dfs(int u) {
	used[u] = 1;
	for(auto e : g[u]) {
		int v = e.first;
		int eId = e.second.first;
		int reverted = e.second.second;
		if(c[v] > c[u]) {
			edgeDir[eId] = reverted ^ 1;
		} else if(c[v] == c[u]) {
			edgeDir[eId] = reverted;
			if(!used[v]) {
				dfs(v);
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	int N, M;
	cin >> N >> M;
	for(int i = 0; i < M; i++) {
		int u, v;
		cin >> u >> v;
		--u;--v;
		g[u].push_back({v, {i, 0}});
		g[v].push_back({u, {i, 1}});
	}
	vector<int> verts;
	for(int i = 0; i < N; i++) {
		cin >> c[i];
		verts.push_back(i);
	}
	sort(verts.begin(), verts.end(), [&](int u, int v) {
		return c[u] < c[v];
	});
	for(auto u : verts) {
		//cerr << u << '\n';.
		if(!used[u]) {
			dfs(u);
		}
	}
	for(int i = 0; i < M; i++) {
		if(edgeDir[i]) {
			cout << "<-\n";
		} else {
			cout << "->\n";
		}
	}
}


#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
//#define MOD 998244353
//#define MAX 100100
#define NIL -1
//#define INF 1000000000000000000
//const LL SEG_VAL = 1 << 19;

vector<vector<pair<LL, LL>>> tele(26);
vector<bool> tele_visited(26, false);
vector<vector<LL>> a_num(2010, vector<LL>(2010, 0));
vector<vector<LL>> dist(2010, vector<LL>(2010, NIL));
vector<vector<bool>> visited(2010, vector<bool>(2010, false));
LL h;
LL w;

vector<LL> dx={0,1,0,-1};
vector<LL> dy={1,0,-1,0};

void bfs(LL y, LL x){
    queue<pair<LL, LL>> q;
    q.push(make_pair(y, x));
    visited[y][x]=true;
    pair<LL, LL> u;
    while(!q.empty()){
        u = q.front();
        q.pop();
        for(LL i=0; i<4; i++){
            LL y_new=u.first+dy[i];
            LL x_new=u.second+dx[i];
            if(y_new<0 || y_new>=h){
                continue;
            }
            if(x_new<0 || x_new>=w){
                continue;
            }
            if(a_num[y_new][x_new]==NIL){
                continue;
            }
            if(visited[y_new][x_new]==true){
                continue;
            }
            dist[y_new][x_new]=dist[u.first][u.second]+1;
            visited[y_new][x_new]=true;
            q.push(make_pair(y_new, x_new));
        }
        LL tmp=a_num[u.first][u.second];
        if(tmp!=0){
            if(tele_visited[tmp-1]!=true){
                for(LL i=0; i<tele[tmp-1].size(); i++){
                    LL y_new=tele[tmp-1][i].first;
                    LL x_new=tele[tmp-1][i].second;
                    if(visited[y_new][x_new]==true){
                        continue;
                    }
                    dist[y_new][x_new]=dist[u.first][u.second]+1;
                    visited[y_new][x_new]=true;
                    q.push(make_pair(y_new, x_new));
                }
                tele_visited[tmp-1]=true;
            }
        }
    }
}

int main(){
    cin >> h >> w;
    char a;
    LL h_s;
    LL w_s;
    LL h_e;
    LL w_e;
    for(LL i=0; i<h; i++){
        for(LL j=0; j<w; j++){
            cin >> a;
            if(a=='#'){
                a_num[i][j]=NIL;
            }else if(a=='S'){
                h_s=i;
                w_s=j;
            }else if(a=='G'){
                h_e=i;
                w_e=j;
            }else if(a=='.'){
            }else{
                LL tmp=a-'a';
                tele[tmp].push_back(make_pair(i,j));
                a_num[i][j]=tmp+1;
            }
        }
    }

    dist[h_s][w_s]=0;
    bfs(h_s, w_s);

    /*
    for(LL i=0; i<h; i++){
        for(LL j=0; j<w; j++){
            //cout << a_num[i][j];
            cout << dist[i][j];
        }
        cout << endl;
    }
    */

    /*
    for(LL i=0; i<3; i++){
        for(LL j=0; j<tele[i].size(); j++){
            cout << tele[i][j].first << " " << tele[i][j].second << endl;
        }
    }
    */

    cout << dist[h_e][w_e] << endl;

    return 0;
}

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

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

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int MAX = 1000;
class shuturyoku_unko {
public:
	char C[MAX * 4];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 3) {
				C[i * 4 + 2 - j] = '0' + X % 10;
				X /= 10;
			}
			C[i * 4 + 3] = ' ';
		}
	}
};
constexpr shuturyoku_unko f;
const int dm = 1 << 17;
char* dn = cn, * di = dn, * owad = dn + dm - 20;
void putint(int A) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	if (A >= 1000) {
		int dig = 1;
		if (A >= 100000) dig = 3;
		else if (A >= 10000) dig = 2;
		memcpy(di, f.C + A / 1000 * 4 + 3 - dig, dig);
		memcpy(di + dig, f.C + A % 1000 * 4, 4);
		di += dig + 4;
	}
	else {
		int dig = 1;
		if (A >= 100) dig = 3;
		else if (A >= 10) dig = 2;
		memcpy(di, f.C + A * 4 + 3 - dig, dig + 1);
		di += dig + 1;
	}
}

int N;
int to[400001], ne[400001], he[200001];
int Q[200001], vis[200001], p, q;
ll are[200001];

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

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

	Q[q++] = 1;
	while (p < q) {
		int u = Q[p++];
		vis[u] = -1;
		for (int i = he[u]; i; i = ne[i]) {
			if (vis[to[i]] == 0) {
				Q[q++] = to[i];
			}
		}
	}
	int tmp = Q[N - 1];
	p = 0;
	q = 0;
	Q[q++] = tmp;
	vis[tmp] = 0;
	while (p < q) {
		int u = Q[p++];
		for (int i = he[u]; i; i = ne[i]) {
			if (vis[to[i]] < 0) {
				vis[to[i]] = u;
				Q[q++] = to[i];
			}
		}
	}
	ll m = (1ll << 20) - 1, m0 = ~m, m1 = 1ll << 20;
	for (int i = N - 1; i >= 0; i--) {
		int u = Q[i];
		ll kari = (are[u] & m0) + m1 + u;
		if (are[vis[u]] < kari) are[vis[u]] = kari;
	}

	int k = 0;
	q = 0;
	Q[q++] = tmp;
	while (q) {
		k++;
		int u = Q[q - 1];
		if (u < 0) q--;
		else {
			vis[u] = -k;
			Q[q - 1] = -u;
			int nanika = are[u] & m;
			if (nanika) Q[q++] = nanika;
			for (int i = he[u]; i; i = ne[i]) {
				int v = to[i];
				if (vis[v] >= 0 && v != nanika) {
					Q[q++] = v;
				}
			}
		}
	}

	rep1(i, N) putint(-vis[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please 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;

#define int            long long int
#define double         long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define mii            map <int, int>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;
string s;

void solve()
{
     cin >> n >> s;
     vector <char> v;

     for (int i = 0; i < n; i++)
     {
          if (sz(v) < 2)
               v.pb(s[i]);
          else
          {
               if (s[i] == 'x')
               {
                    char c = v.back();
                    v.pop_back();
                    if (v.back() == 'f' and c == 'o')
                         v.pop_back();
                    else
                    {
                         v.pb(c);
                         v.pb(s[i]);
                    }
               }
               else
                    v.pb(s[i]);
          }
     }
     cout << sz(v);

}

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

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 1e9+7;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 5e5+5;

int32_t main(){

   speed_cubing

   char s,t;
   cin>>s>>t;

   if(s=='Y'){

     cout<<char(t-'a'+'A');

   }
   else
     cout<<t;

   return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define SHOW1d(v,n) {REP(W,n)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {REP(aaa,i){REP(bbb,j)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007LL

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

template<typename T>
void show_vector(vector<T> v) {
	for (auto ele: v)cout << ele << " " ;cout << endl;
}

template<typename T>
void show_vector(vector<vector<T>> v) {
	for (auto ele: v)show_vector(ele);
}

template<typename T>
void show_vector(vector<vector<vector<T>>> v) {
	for (auto ele: v) {
		show_vector(ele);
		cout << endl;
	}
}

void solve() {
	ll n;cin >> n;
	vector<ll> v(n);
	REP(i, n) cin >> v[i], v[i]--;

	vector<ll> tmp(2 * n);
	REP(i, 2 * n)tmp[i] = i % n;
	vector<ll> ans;
	int cou = 0;
	for (ll now: tmp) {
		// cout << "### " << now << " ###" << endl;
		ll pla;
		REP(i, n) if (v[i] == now) pla = i;
		while(pla != now) {
			// cout << now << " " << pla << endl;
			// show_vector(v);
			if (pla % 2 != cou % 2 && pla - 1 >= 0) {
				ans.PB(pla - 1);
				swap(v[pla - 1], v[pla]);
				pla--;
			}
			else if (pla % 2 == cou % 2 && pla < now) {
				ans.PB(pla);
				swap(v[pla], v[pla + 1]);
				pla++;
			}
			else {
				ans.PB(cou % 2);
				swap(v[cou % 2], v[(cou % 2) + 1]);
				if (pla == cou % 2) pla++;
			}
			cou++;
		}
	}

	while (v.size() > 2 && (v[0] != 0 || v[1] != 1 || v[2] != 2)) {
		ans.PB(cou % 2);
		swap(v[cou % 2], v[(cou % 2) + 1]);
		cou++;
	}

	// cout << "end swap" << endl;

	cout << ans.size() << endl;
	REP(i, ans.size()) cout << ans[i] + 1 << " ";cout << endl;

}

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

	ll t;cin >> t;
	REP(i, t)solve();

	return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x = min((x),(y));
#define chmax(x,y) x = max((x),(y));
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<long long,long long>;
const int INF = 1e9;
const long long LINF = 1e18;
const int MOD = 1000000007;
//const int MOD = 998244353;
const double PI = 3.14159265358979323846;

int main(){
    int x;
    cin >> x;
    cout << max(x,0) << endl;
    return 0;
}


#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

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

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }

};

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  llvec x(N), y(N);
  rep(i, N)cin >> x[i]>>y[i];

  ld ok = 1e-10;
  ld ng = 300;
  while(abs(ok-ng)>1e-9){
    ld r= (ok+ng)*0.5;
    UnionFind uf(N+2);
    for(ll i=0;i<N;i++){
      for(ll j=i+1;j<N;j++){
        if(sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2)) <2 * r){
          uf.con(i, j);
        }
      }

      if(abs(y[i]-100)<2*r)uf.con(N, i);
      if(abs(y[i]+100)<2*r)uf.con(N+1, i);
    }
    if(uf.is_con(N, N+1)){
      ng=r;
    }else{
      ok=r;
    }

  }

  cout << setprecision(15)<<ok;

  return 0;
}

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

const long long MOD = 1000000007;
struct mint {
    long long int value;

    mint() : value(0) {}

    explicit mint(long long int value) : value((value % MOD + MOD) % MOD) {}

    mint &fix() {
        value = (value % MOD + MOD) % MOD;
        return *this;
    }

    mint operator-() const { return mint(0) - *this; }

    mint operator~() const { return mint(1) / *this; }

    mint &operator+=(const mint &others) {
        if ((value += others.value) >= MOD) value -= MOD;
        return *this;
    }

    mint &operator-=(const mint &others) {
        if ((value += MOD - others.value) >= MOD) value -= MOD;
        return *this;
    }

    mint &operator*=(const mint &others) {
        (value *= others.value) %= MOD;
        return *this;
    }

    mint &operator/=(const mint &others) {
        (value *= others.pow(MOD - 2).value) %= MOD;
        return *this;
    }

    mint operator+(const mint &a) const { return mint(*this) += a; }

    mint operator-(const mint &a) const { return mint(*this) -= a; }

    mint operator*(const mint &a) const { return mint(*this) *= a; }

    mint operator/(const mint &a) const { return mint(*this) /= a; }

    mint pow(long long int t) const {
        if (!t) return mint(1);
        mint res = pow(t / 2);
        res *= res;
        return (t & 1) ? res * mint(value) : res;
    }

    bool operator<(const mint &a) const { return value < a.value; }

    bool operator<=(const mint &a) const { return value <= a.value; }

    bool operator>(const mint &a) const { return value > a.value; }

    bool operator>=(const mint &a) const { return value >= a.value; }

    bool operator==(const mint &a) const { return value == a.value; }
};

mint ex(mint x, long long int t) {
    return x.pow(t);
}

std::istream &operator>>(std::istream &i, mint &a) {
    i >> a.value;
    return i;
}

std::ostream &operator<<(std::ostream &o, const mint &a) {
    o << a.value;
    return o;
}

void solve(long long N, std::vector<long long> A){
    sort(all(A));
    vector<ll> a = {0};
    a.insert(a.end(), all(A));
    mint ans = mint(1);
    rep(i, N) {
        ans *= mint(a.at(i + 1) - a.at(i) + 1);
    }
    cout << ans << endl;
}

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


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

using namespace std;

const int N = 400005;

int n, b[N];
pair<int, int> a[N];
stack<int> s;
char ans[N];

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

	cin >> n;
	rep(i, 1, 2 * n) {
		int x;
		cin >> x;
		a[i] = {x, i};
	}
	sort(a + 1, a + 2 * n + 1, greater<pair<int, int>>());
	rep(i, 1, n)
		b[a[i].second] = 1;
	rep(i, 1, 2 * n) {
		if (!s.empty() && b[s.top()] != b[i]) {
			ans[s.top()] = '(';
			ans[i] = ')';
			s.pop();
		}
		else
			s.push(i);
	}
	assert(s.empty());
	rep(i, 1, 2 * n)
		cout << ans[i];
	return 0;
}

/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#ifdef ONLINE_JUDGE
#define debug(x)
#define debug2(x, y)
#define debug3(x, y, z)
#define dbg(v)
#else
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
#endif

// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

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

    string s;
    cin >> s;

    if (s[0] == s[1] && s[1] == s[2]) {
        print("Won");
    } else {
        print("Lost");
    }

    return 0;
}

/*
  __ _   ___ _ __  _ __
 / _` | / __| '_ \| '_ \
| (_| || (__| |_) | |_) |
 \__,_(_)___| .__/| .__/
            |_|   |_|
*/


#include <bits/stdc++.h>
#include <set>
#define ll long long
#include <string>
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323846
#define mod 1000000007
#define INF 1e18
// typedef pair<ll, ll> pi;
#define rep(i,n) for(i=0;i<n;i++)
#define repk(i,k,n) for(i=k;i<n;i++)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define oset tree <pair<ll int ,ll int>, null_type, less<pair<ll int,ll int> >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define see(args...)                             \
        {                                            \
            cerr << "LINE " << __LINE__;             \
            string _s = #args;                       \
            replace(_s.begin(), _s.end(), ',', ' '); \
            stringstream _ss(_s);                    \
            istream_iterator<string> _it(_ss);       \
            err(_it, args);                          \
            cerr << endl;                            \
        }
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << ' ' << *it << " = " << a;
    err(++it, args...);
}
void fastio()
{
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

}
void solve()
{
    ll int n; cin >> n;
    ll int a[n], i, j;
    rep(i, n) {
        cin >> a[i];
    }
    vector<ll> ans[200];
    rep(i, (1 << min(8ll, n)))
    {
        ll int s = 0;
        vector<ll> temp;
        rep(j, min(8ll, n))
        {
            if (i & (1 << j))
            {
                s += a[j];
                temp.pb(j + 1);
            }
        }
        s = s % 200;
        // cout << "sum " << s << ' ' << ans[s].size() << endl;
        if (ans[s].size() == 0)
        {
            ans[s] = temp;
        }
        else
        {
            cout << "YES" << endl;
            cout << ans[s].size() << " ";
            for (auto x : ans[s])
                cout << x << ' ';
            cout << endl;
            cout << temp.size() << ' ';
            for (auto z : temp)
                cout << z << ' ';
            cout << endl;
            return;
        }

    }
    cout << "NO" << endl;
}

int main()
{
    fastio();
    ll int t;
    // cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }

}

//HEADER FILES AND NAMESPACES

#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 <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

// DEFINE STATEMENTS

#define num1 1000000007
#define num2 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define REPd(i,a,n) for(ll i=a; i>=n; i--)
#define pb push_back
#define pob pop_back
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define all(x) x.begin(), x.end()
#define M_PI 3.14159265358979323846
#define epsilon (double)(0.0000001)

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long>> vpll;
typedef vector<int> vii;

// DEBUG FUNCTIONS
#ifndef ONLINE_JUDGE

template<typename T>
void __p(T a) {
	cout<<a;
}
template<typename T, typename F>
void __p(pair<T, F> a) {
	cout<<"{";
	__p(a.first);
	cout<<",";
	__p(a.second);
	cout<<"}";
}
template<typename T>
void __p(std::vector<T> a) {
	cout<<"{";
	for(auto it=a.begin(); it<a.end(); it++)
		__p(*it),cout<<",}"[it+1==a.end()];
}
template<typename T>
void __p(std::set<T> a) {
	cout<<"{";
	for(auto it=a.begin(); it!=a.end();){
		__p(*it);
		cout<<",}"[++it==a.end()];
	}

}
template<typename T>
void __p(std::multiset<T> a) {
	cout<<"{";
	for(auto it=a.begin(); it!=a.end();){
		__p(*it);
		cout<<",}"[++it==a.end()];
	}
}
template<typename T, typename F>
void __p(std::map<T,F> a) {
	cout<<"{\n";
	for(auto it=a.begin(); it!=a.end();++it)
	{
		__p(it->first);
		cout << ": ";
		__p(it->second);
		cout<<"\n";
	}
	cout << "}\n";
}

template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
	__p(a1);
	__p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : ";
	__p(arg1);
	cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	int bracket=0,i=0;
	for(;; i++)
		if(names[i]==','&&bracket==0)
			break;
		else if(names[i]=='(')
			bracket++;
		else if(names[i]==')')
			bracket--;
	const char *comma=names+i;
	cout.write(names,comma-names)<<" : ";
	__p(arg1);
	cout<<" | ";
	__f(comma+1,args...);
}
#define trace(...) cout<<"Line:"<<__LINE__<<" ", __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...)
#define error(...)
#endif

// DEBUG FUNCTIONS END

// CUSTOM HASH TO SPEED UP UNORDERED MAP AND TO AVOID FORCED CLASHES
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());  // FOR RANDOM NUMBER GENERATION

ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;   a=a%c;
	while(b>0)
	{
		if(b%2==1)
			res=(res*a)%c;
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
		return ((a%b)+b)%b;
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m)
{
		ll x, y;
		ll g = gcdExtended(a, m, &x, &y);
		g++;   //this line was added just to remove compiler warning
		ll res = (x%m + m) % m;
		return res;
}
ll gcdExtended(ll a, ll b, ll *x, ll *y)
{
		if (a == 0)
		{
				*x = 0, *y = 1;
				return b;
		}
		ll x1, y1;
		ll gcd = gcdExtended(b%a, a, &x1, &y1);
		*x = y1 - (b/a) * x1;
		*y = x1;
		return gcd;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll a,b;
	cin >> a >> b;
	cout << 2*a + 100 - b << "\n";
    return 0;
}


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

int main(){

    int takahashi_num,aoki_num,C;

    // 条件数
    cin >> takahashi_num >> aoki_num >> C;

    if(C==0){
        if(takahashi_num<=aoki_num){
            cout << "Aoki" << endl;
        }else{
            cout << "Takahashi" << endl;
        }
    }else{
        if(aoki_num<=takahashi_num){
            cout << "Takahashi" << endl;
        }else{
            cout << "Aoki" << endl;
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
int INF=1000000000;
const double PI = 3.14159265358979323846;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  a+=c;
  if(a>b)cout << "Takahashi" << endl;
  else cout << "Aoki" << endl;
}


/*
-----------------AUTHOR-----------------------
--------------Parth Mangal--------------------
----------------------------------------------
*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void gareeb(){
	int n;
	cin>>n;
	int arr[n],temp;
	for(int i=0;i<n;i++){
		cin>>temp;
		arr[i]=abs(temp);
	}
	ll m=0;
	for(int i=0;i<n;i++){
		m = m+ arr[i];
	}
	cout<<m<<endl;
	double e=0;
	for(int i=0;i<n;i++){
		e = e+ pow(arr[i],2);
	}
	cout<<fixed<<setprecision(15)<<sqrt(e)<<endl;
	sort(arr,arr+n);
	cout<<arr[n-1];
}

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

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

int main() {
  int N;
  cin >> N;
  int64_t a[N];
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  for (int i=0; i<N; i++){
    if (a[i]<0){
      a[i] = (-1) * a[i];
    }
  }
  int64_t M=0;
  for(int i=0; i<N; i++){
      M+=a[i];
  }
  int64_t x=0;
  double E;
  for(int i=0; i<N; i++){
      x+=a[i]*a[i];
  }
  E=sqrt(x);
  int64_t C=0;
  for(int i=0; i<N; i++){
      C=max(C,a[i]);
  }
  cout << M << endl;
  cout << fixed << setprecision(18) << E << endl;
  cout << C << endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
#include<complex>
#include<numeric>
#include<functional>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
    //p_a^p_n mod p_p
    long long int p_b=1,p_t=1;
    for(;p_b<=p_n;p_b<<=1);
    for(p_b>>=1;p_b>0;p_b>>=1){
        p_t*=p_t;
        if(p_t>=p_p)p_t%=p_p;
        if(p_n&p_b)p_t*=p_a;
        if(p_t>=p_p)p_t%=p_p;
    }
    return p_t;
}

int main(){
    LL n,m;
    int i,j,k;
    LL a,b,c;
    cin>>n>>m;
    a=pow_mod(10,n,m*m);
    cout<<a/m<<endl;
}

#include<iostream>
using namespace std;
#define int long long
int n,m,mod=998244353,ans;
int p[5001][5001];
int power(int a,int b)
{
	if(p[a][b])return p[a][b];
	if(!a)return 0;
	if(!b)return 1;
	int tmp=power(a,b/2);
	tmp=tmp*tmp%mod;
	if(b&1)tmp=tmp*a%mod;
	return p[a][b]=tmp;
}
signed main()
{
	cin>>n>>m;
	if(m==1)
	{
		cout<<1;
		return 0;
	}
	for(int i=1;i<=n-2;i++)
	{
		int cnt=0;
		for(int j=2;j<=m;j++)
		{
			cnt+=power(m-1,i)-power(m-j,i)+mod;
			cnt%=mod;
		}
		ans+=cnt*(n-i-1)%mod*power(m,n-i-2);
		ans%=mod;
	}
	for(int i=1;i<=n;i++)
	{
		ans+=power(m-1,i-1)*m%mod*power(m,n-i);
		ans%=mod;
	}
	cout<<ans;
	return 0;
}