#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;

#define PB push_back
#define MP make_pair
#define A first
#define B second
#define eps 1e-8

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII;

int n, a[4];
int dp[310][310][310], vis[310][310];

void prepare() {
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i <300; i ++ )
        for (int j = 0; j < 300; j ++ )
            for (int k = 0; k < 300; k ++ )
                if (dp[i][j][k] != 0) continue;
                else {
                    for (int l = i + 1; l < 300; l ++ )
                        dp[l][j][k] = 1;
                    for (int l = j + 1; l < 300; l ++ )
                        dp[i][l][k] = 1;
                    for (int l = k + 1; l < 300; l ++ )
                        dp[i][j][l] = 1;
                    for (int l = 1; i + l < 300 && j + l < 300 && k + l < 300; l ++ )
                        dp[i + l][j + l][k + l] = 1;
                }
    memset(vis, 0, sizeof(vis));
    for (int i = 0; i < 300; i ++ )
        for (int j = 0; j < 300; j ++ )
            if (vis[i][j] == 0) {
                for (int k = i + 1; k < 300; k ++ )
                    vis[k][j] = 1;
                for (int k = j + 1; k < 300; k ++ )
                    vis[i][k] = 1;
                for (int k = 1; k + i < 300 && k + j < 300; k ++ )
                    vis[i + k][j + k] = 1;
            }
}

int main() {
    prepare();
    scanf("%d", &n);
    for (int i = 0; i < n; i ++ )
        scanf("%d", &a[i]);
    if (n == 1)
        if (a[0] != 0) printf("BitLGM\n");
        else printf("BitAryo\n");
    if (n == 2)
        if (vis[a[0]][a[1]] == 1) printf("BitLGM\n");
        else printf("BitAryo\n");
    if (n == 3)
        if (dp[a[0]][a[1]][a[2]] == 1) printf("BitLGM\n");
        else printf("BitAryo\n");
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long long         ll;
typedef long double   	  ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;
typedef vector<ll>		  vll;

const ll OO = 1e9;
const ll mod = 1e9+7;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

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

	#endif
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
int n ;
vector< string > arr;

void gen(int i , string w){
	if(i == 4){
		arr.push_back(w);
		return ;
	}

	for(char idx = '0' ; idx<='9';idx++)
		gen(i+1 , w + idx);
}
bool fun(pair< string  , pair < int  ,int> > p , string s){
	set< char > ss;
	lp(i , s.size() )
		ss.insert(s[i]);

	if(ss.size() != 4)
		return 0;

	int in = 0 , nin = 0;
	for(int i = 0 ; i < s.size();i++){
		if(p.first[i] == s[i] ){
			in++;
		}else{
			nin+= (s.find(p.first[i] ) != -1);
		}
	}
	return (in == p.second.first && nin == p.second.second);
}
int main(){
	fast();
	gen(0 , "");
	while(cin>>n){
		pair< string  , pair < int  ,int> > a [11];
		string s ;
		int x , y ;
		vector<string>ans;
		lp(i, n){
			cin>>s>>x>>y;
			a[i] = MP(s , MP(x,y) );
		}
		lp(i , arr.size()){
			bool f = 0;
			lp(j , n){
				if(!fun(a[j] , arr[i]) ){
					f = 1;
					break;
				}
			}
			if(!f){
				ans.push_back(arr[i]);
			}
		}

		if(ans.size() == 0){
			cout<<"Incorrect data\n";
		}else if(ans.size() > 1){
			cout<<"Need more data\n";
		}else cout<<ans[0]<<endl;
	}

	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define maxn 400010
int ans[maxn];

int main()
{
    int n;

    int count5=0,count2=0;
    for(int i=1; i<=maxn; i++)
    {
        int bak = i;
        if(bak % 5 == 0)
        {
            while(bak)
            {
                if(bak % 5 == 0)
                    count5++;
                else
                    break;
                bak /= 5;
            }
        }
        if(bak % 2 == 0)
        {
            while(bak)
            {
                if(bak % 2 == 0)
                    count2++;
                else
                    break;
                bak /= 2;
            }
        }
        if( int tmp = min(count5, count2) )
            ans[i] = tmp;
    }
    //printf("feferf\n");
    while(scanf("%d", &n) != EOF)
    {
        int cnt=1;
        int ans1[100];
        for(int i=0; i<=100; i++)
            ans1[i] = 0;
        for(int i=1; i<=maxn; i++)
        {
            if(ans[i] > n)
                break;
            if(ans[i] == n)
            {
                ans1[0]++;
                ans1[cnt++] = i;
            }
        }
        printf("%d\n", ans1[0]);
        for(int i=1; i<cnt; i++)
            printf("%d%c", ans1[i], i==cnt-1?'\n':' ');

    }

    return 0;
}


#include <iostream>
#include<malloc.h>
#include<list>

using namespace std;

int main()
{
    int *a,b;
    list<int> start;
    list<int> endlist;
    scanf("%d",&b);
    a = (int *)malloc(sizeof(int) * b);
    for(int i=0;i<b;i++) {
        scanf("%d",&a[i]);
    }
    int sum = 0,startidx=0,endindex=0,totcount=0,mprevsum=0;
    for(int j=0;j<b;j++) {
        sum = sum + a[j];
        if(sum == 0 && mprevsum != 0 && startidx > 0) {
            totcount++;
            start.push_back(startidx);
            endlist.push_back(j);
            sum = 0;
            sum = sum + a[j];
            mprevsum = sum;
            startidx = j+1;
            endindex = j+1;
            continue;
        }
        if(startidx == 0)  {
            startidx = j+1;
        }
        endindex++;
        mprevsum = sum;
    }
    if(sum != 0 && totcount == 0)  {
        printf("YES\n");
        printf("1\n");
        printf("%d %d",1,b);
    }
    if(totcount == 0 && sum == 0) {
        printf("NO");
    }
    if(totcount != 0) {
        if(sum != 0) {
            totcount++;
            start.push_back(startidx);
            endlist.push_back(endindex);
        }
        printf("YES\n");
        printf("%d",totcount);
    }
    list<int>::iterator it=start.begin();
    list<int>::iterator it1=endlist.begin();
    for (; it != start.end(); ++it,++it1) {
            printf("\n");
        printf("%d %d",*it,*it1);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pt pair<ll, ll>
int sign(ll x){if(x > 0) return 1;if(x < 0) return -1;return 0;}int half(pt x){if(x.second != 0)return sign(x.second);return -sign(x.first);}
__int128_t cross(pt a, pt b){return (__int128_t)a.first * b.second - (__int128_t)a.second * b.first;}
bool angCmp(pt a, pt b){int A = half(a), B = half(b);if(A == B) return cross(a, b) > 0;return A < B;}
typedef array<ll, 3> T;T a;int eq = 0, neg = 0;vector<pt> cat;struct cmp{bool operator()(const pt&a, const pt&b) const{return angCmp(a, b);}};map<pair<ll, ll>, int, cmp> mp;
T operator*(T a, ll b){for(int i = 0; i < 3; i ++)a[i] *= b;return a;}T operator+(T a, T b){for(int i = 0; i < 3; i ++)a[i] += b[i];return a;}
T operator-(T a, T b){for(int i = 0; i < 3; i ++)a[i] -= b[i];return a;}
ll sum(T a){return a[0] + a[1] + a[2];}ll dot(T a, T b){ll res = 0;for(int i = 0; i < 3; i ++)res += a[i] * b[i];return res;}
pair<ll, ll> lst;bool bad(pt a, pt b){return a == b || cross(a, b) < 0;}void add(pair<ll, ll> p, int x){
	if(p.first == 0 && p.second == 0){eq += x; return;}vector<pair<ll, ll> > cand = {lst, p};if(x == 1){if(!mp.count(p) && mp.count({-p.first, -p.second})) neg ++;mp[p] ++;
	}else{if(mp[p] == 1 && mp.count({-p.first, -p.second})) neg --;auto it = mp.find(p);if(it == mp.begin()) it = mp.end();it --;
		cand.push_back(it -> first);mp[p] --;if(!mp[p]) mp.erase(p);}
	lst = {0, 0};for(pair<ll, ll> i : cand){auto it = mp.find(i);if(it == mp.end()) continue;auto nx = next(it);if(nx == mp.end()) nx = mp.begin();if(bad(i, nx -> first))lst = i;}}
int ans(){if(eq) return 1;if(neg) return 2;if(mp.size() && lst.first == 0 && lst.second == 0)return 3;return 0;}
int main(){	ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);long long rd;cin >> rd; a[0] = rd;cin >> rd; a[1] = rd;cin >> rd; a[2] = rd;int q; cin >> q;
	for(char c; q --;){cin >> c;if(c == 'A'){T x;cin >> rd; x[0] = rd;cin >> rd; x[1] = rd;cin >> rd; x[2] = rd;
			x = x * sum(a) - a * sum(x);pt p = {dot(x, {1, -1, 0}), dot(x, {1, 1, -2})};ll gc = __gcd(abs(p.first), abs(p.second));if(p.first || p.second) p.first /= gc, p.second /= gc;
			cat.push_back(p);add(cat.back(), 1);}else{int r; cin >> r; r --;add(cat[r], -1);}ll get = (ll)ans();cout << get << endl;}return 0;}


#include <iostream>
#include <string>
#include <map>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

const int LEN = 201;
char state[LEN], d[10];
int n, sp, cp;
char winner;

int get_next_cp()
{
    if(cp == n)
    {
        d[0] = 'h';
        return cp - 1;
    }
    if(cp == 1)
    {
        d[0] = 't';
        return cp + 1;
    }
    if(d[0] == 'h') return cp - 1;
    return cp + 1;
}

int main()
{
    while(scanf("%d %d %d", &n, &sp, &cp) != EOF)
    {
        scanf("%s", d);
        scanf("%s", d);
        scanf("%s", state);
       // cout << d << ' ' << state << endl;
        winner = '0';
        int i;
        for(i = 0; ; i++)
        {
           // cout << sp << ' ' << cp << endl;
            if(sp == cp)
            {
                winner = 'c';
                break;
            }
            else if(state[i] == '\0')
            {
                winner = 's';
                break;
            }
            if(state[i] == '0')  //move
            {
                if(d[0] == 'h')
                {
                    if(sp < cp && sp - 1 >= 1) sp--;
                    else if(sp > cp && sp + 1 <= n) sp++;
                }
                else
                {
                    if(sp > cp && sp + 1 <= n) sp++;
                    else if(sp < cp && sp - 1 >= 1) sp--;
                }
                cp = get_next_cp();
            }
            else  //idle
            {
                cp = get_next_cp();
                if(d[0] == 'h')
                {
                    if(cp == n) sp = 1;
                    else sp = n;
                }
                else
                {
                    if(cp == 1) sp = n;
                    else sp = 1;
                }
            }
        }
        if(winner == 'c') printf("Controller %d\n", i);
        else puts("Stowaway");
    }
}


#include<iostream>
using namespace std;
int main ()
{
  int i,j,sum=0,a,b,jih=0;
  cin>>a>>b;
  a > b ? i=a-b : i=b-a;
  if(i%2==0)
    jih=1;
  for(j=1;j<=i/2;j++)
   sum+=2*j;
  if(jih==0)
  sum+=j;
  cout<<sum;
  return 0;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_set>
#include <cmath>
#include <regex>
#include <fstream>

#define ll long long
#define  MOD 1000000007

using namespace std;

int main() {

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

	ll x, y, n;

	cin >> x >> y >> n;

	vector<ll> d;

	d.push_back(x);
	d.push_back(y);
	d.push_back(((y - x) + MOD) % MOD);
	d.push_back(((-x) + MOD) % MOD);
	d.push_back(((-y) + MOD) % MOD);
	d.push_back(((x - y) + MOD) % MOD);

	if (d.size() == 1) {
		cout << (d[0] + MOD) % MOD << endl;
	}
	else {
		cout << (d[((n - 1) % 6)] + MOD) % MOD << endl;
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
//y>-2 y
//g>-1y 1b
//b>-3 b
int main()
{
    long long int a,bl,c;
    long long int y,b;

    scanf("%lld %lld",&y,&b);
    scanf("%lld %lld %lld",&a,&bl,&c);

    long long int sy,sb;
    sy=(2*a)+bl;
    sb=(3*c)+bl;
    long long int sum;
    if(y<sy&&b<sb) {
    sum=(sy-y)+(sb-b);
    }
    else if(y<sy&&b>sb) {
    sum=(sy-y);
    }
    else{
    sum=(sb-b);
    }
    if(sum<=0) {
        sum=0;
    }
    printf("%lld\n",sum);
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    ll S = 0;
    REP(i, n){
        if(a[i]>=0)S += a[i];
        else S -= a[i];
    }
    cout << S << endl;

    return 0;
}


#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <map>
#include <set>
using namespace std;

int main()
{
  int a,o=0,n=0,m=0;
  cin >>a;
  vector<int> v;
  for(int i=0;i<a;i++)
  {
    int q;
    cin >>q;
    v.push_back(q);
  }
  if(v[0]==0)
    n++;
  else
    m++;
  for(int i=1;i<v.size();i++)
  {
    if(v[i]==v[i-1] && v[i]!=0)
      m++;
    else if(v[i]==0)
    {
      o+=min(n,m);
      m=0;
    }
    else if(v[i]!=0)
    {
      o+=min(n,m);
      m=1;
    }
    if(v[i]==0)
      n++;
  }
  if(v[v.size()-1]!=0)
    o+=min(n,m);
  cout <<o;
  return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int n,a,b;
int main() {
    scanf("%d%d%d",&n,&a,&b);
    a=a+b;
    a%=n;
    a=(a+n)%n;
    if(a==0) a=n;
    cout<<a;
}


#include <iostream>

using namespace std;

int main() {
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	long long ans = 0;

	for (int i = 1; i <= n; i++) {
		int x = i + b - c;
		int y = i + a - d;
		int z = a + x - d;
        if (1 <= x && x <= n && 1 <= y && y <= n && 1 <= z && z <= n) {
            ans++;
        }
	}
	cout << ans * n << endl;
}


#include <bits/stdc++.h>

using namespace std;

long long da1[60],da2[60],n,s1,s2;
int main() {
	while(cin>>n) {
		s1=s2=0;
		for(int i=1; i<=n; ++i) {
			cin>>da1[i];
			s1+=da1[i];
		}
		for(int i=1; i<=n; ++i) {
			cin>>da2[i];
			s2+=da2[i];
		}
		if(s2<=s1) cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,int> iii;

#define N 300
#define M 21
#define MOD 1000000007
#define PI acos(-1)
#define rep(i,a,b) for(int i = a; i < b; i++)
#define reps(i,a,b) for(int i = a; i >= b; i--)
#define sc scanf
#define pc printf
#define pb push_back
#define F first
#define S second

int n,cur,x[N],y[N];
string home;
map<string,int>mp;
bool mark[N][N];
string c,d,e;
int deg[N];

int main()
{
    cin >> n;

    int id = 0;
    cin >> home;
    mp[home] = ++id;
    rep(i,0,n){
        cin >> e;
        c = "";d = "";
        c += e[0],c += e[1],c += e[2];
        d += e[5],d += e[6],d += e[7];
        //cout << c << " " << d << endl;
        if(!mp[c]){
            mp[c] = ++id;

        }
        if(!mp[d]){
            mp[d] = ++id;
        }
        deg[mp[c]]++;
        deg[mp[d]]++;
        //cout << c << " " << d << " " << mp[c] << " " << mp[d] << endl;

    }

    rep(i,1,id+1){
        if(deg[i] % 2 > 0){
            puts("contest");
            return 0;
        }
    }

    puts("home");

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
	int i,n;
	string s;
	cin >> n >> s;
	for (i = 0; i < n - 1 && s[i] =='1'; i++);
	cout << i+1;
	return 0;
}


#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    long long int n,k,m,l;
    cin>>n>>k;
    if (n%2==1)
    m=n/2+1;
    else
        m=n/2;
    if (k<=m)
    {
       cout<< k*2-1;
    }
    else
    {
        l=k-m;
        cout<<l*2;
    }

    return 0;
}


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

const int N = 18003000 + 5;

int n, cmp[N];
vector<int> ans;

void sieve() {
  cmp[1] = cmp[0] = 1;
  for(long long i = 2; i <= 10000; i++) {
    if(!cmp[i]) for(long long j = i*i; j < N; j += i) cmp[j] = 1;
  }
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  sieve();
  cin >> n;
  ans.assign(n+1, 0);
  int aux = (n*(n+1))/2;

  if(!cmp[aux]) {
    for(int i = 1; i <= n; i++) cout << 1 << " \n"[i == n];
    return 0;
  }

  if(!cmp[aux-2]) {
    for(int i = 1; i <= n; i++) cout << 1 + (i == 2) << " \n"[i == n];
    return 0;
  }

  if(aux & 1) {
    ans[1] = ans[2] = 3;
    aux -= 3;
  }

  int p1 = -1, p2 = -2;
  for(int i = 0; i <= aux - i; i++) {
    if(!cmp[i] and !cmp[aux-i]) {
      p1 = i, p2 = aux-i;
      break;
    }
  }

  if(p1 != -1) {
    for(int i = n; i >= 1; i--)
      if(!ans[i] and i <= p1) ans[i] = 1, p1 -= i;

    for(int i = n; i >= 1; i--)
      if(!ans[i] and i <= p2) ans[i] = 2, p2 -= i;
  }

  for(int i = 1; i <= n; i++) cout << ans[i] << " \n"[i == n];
}


#include <bits/stdc++.h>

using namespace std;

long long n,m,i,j,b[15],k,mi=7654457,s,x,g=1;
string st,st1;
char c[10005];
bool zero(string st)
{
    if (st=="0") return 1;
    if (st[0]=='0') return 0;
    return 1;
}
int main()
{
    cin>>n>>k;
    for (i=1;i<=k;i++) g*=10;
    sprintf(c," %d",n);
    st=c;
    m=st.length()-1;
    //b[1]=b[2]=b[3]=1;
    while (b[0]==0)
    {
        st1="";
        for (j=m;j>=1&&b[j];j--);
        b[j]=1;
        for (i=j+1;i<=m;i++) b[i]=0;
        for (i=1;i<=m;i++)
        if (b[i]) st1+=st[i];
        sscanf(st1.c_str(),"%d",&x);
        if (x%g==0&&zero(st1))
        {
            s=m;
            for (i=1;i<=m;i++) s-=b[i];
            if (s<mi) mi=s;
        }
    }
    cout<<mi;
    return 0;
}


#include<iostream>
using namespace std;
int a[10],n;
int main()
{
    cin>>n;
    a[1]=a[7]=a[9]=1;
    if((a[n%10]||n>9&&n<30||a[n/10])&&n!=12)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
    return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

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

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

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

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

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

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

namespace io {
    void setIn(string s) { freopen(s.c_str(),"r",stdin); }
    void setOut(string s) { freopen(s.c_str(),"w",stdout); }
    void setIO(string s = "") {
        ios_base::sync_with_stdio(0); cin.tie(0);
        if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
    }

    // double input seems slow on CF
    void re(double& x) { string t; cin >> t; x = stod(t); }
    void re(ld& x) { string t; cin >> t; x = stold(t); }
    template<class T> void re(T& x) { cin >> x; }
    template<class Arg, class... Args> void re(Arg& first, Args&... rest) { re(first); re(rest...); }

	// pair
	template<class T1, class T2> istream& operator>>(istream& is, pair<T1,T2>& p) {
	    is >> p.f >> p.s;
	    return is;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) {
	    os << '{' << a.f << ", " << a.s << '}';
	    return os;
	}

    // vector
	template<class T> istream& operator>>(istream& is, vector<T>& a) {
	    int sz; is >> sz; a.resize(sz);
	    F0R(i,sz) is >> a[i];
	    return is;
	}
	template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	    os << "{";
	    F0R(i,sz(a)) {
	        if (i) os << ", ";
	        os << a[i];
	    }
	    os << "}";
	    return os;
	}
}

using namespace io;

map<pi,int> m, key;

ll cross(pi O, pi A, pi B) {
    return (ll)(A.f-O.f)*(B.s-O.s)
            -(ll)(A.s-O.s)*(B.f-O.f);
}

vpi convex_hull(vpi P) {
    sort(all(P)); P.erase(unique(all(P)),P.end());
    int n = sz(P);
    if (n == 1) return P;

    vpi bot = {P[0]};
    FOR(i,1,n) {
        while (sz(bot) > 1 && cross(bot[sz(bot)-2], bot.back(), P[i]) <= 0) bot.pop_back();
        bot.pb(P[i]);
    }
    bot.pop_back();

    vpi up = {P[n-1]};
    F0Rd(i,n-1) {
        while (sz(up) > 1 && cross(up[sz(up)-2], up.back(), P[i]) <= 0) up.pop_back();
        up.pb(P[i]);
    }
    up.pop_back();

    bot.insert(bot.end(),all(up));
    return bot;
}

int n;

vpi v, c;
vi col;
vpi ans;

void addEdge(pi a, pi b) {
    ans.pb({key[a],key[b]});
}

int area(pi a, pi b, pi c) {
    b.f -= a.f, b.s -= a.s;
    c.f -= a.f, c.s -= a.s;
    return abs(b.f*c.s-b.s*c.f);
}

bool in(pi a, pi b, pi c, pi z) {
    return area(a,b,z)+area(b,c,z)+area(c,a,z) == area(a,b,c);
}

void go(pi a, pi b, pi c, vpi res) {
    for (auto t: res) if (m[t] == m[a]) {
        addEdge(a,t);
        vpi x,y,z;
        for (auto T: res) if (T != t) {
            if (in(c,a,t,T)) x.pb(T);
            else if (in(b,a,t,T)) y.pb(T);
            else z.pb(T);
        }
        go(c,a,t,x);
        go(b,a,t,y);
        go(t,b,c,z);
        return;
    }
    for (auto t: res) addEdge(b,t);
}

void solveTri(pi a, pi b, pi c) {
    vpi res;
    for (auto z: v) if (z != a && z != b && z != c && in(a,b,c,z)) res.pb(z);
    go(a,b,c,res);
}

void solveDif() {
    int cur = 0; while (col[cur] == 1) cur ++;
    while (col[cur] == 0) cur = (cur+1)%sz(col);
    while (col[cur] == 1) cur = (cur+1)%sz(col);
    rotate(c.begin(),c.begin()+cur,c.end());
    rotate(col.begin(),col.begin()+cur,col.end());

    cur = 0; while (col[cur] == 0) cur ++;
    FOR(i,1,cur) {
        addEdge(c[i],c[i-1]);
        solveTri(c[cur],c[i],c[i-1]);
    }
    /*cout << col << "\n";
    cout << sz(c) << "\n" << cur << "\n";

    cout << ans  << "\n";*/

    FOR(i,cur+1,sz(col)) {
        addEdge(c[i],c[i-1]);
        solveTri(c[0],c[i],c[i-1]);
    }
}

void solveEq() {
    F0R(i,sz(c)-1) addEdge(c[i],c[i+1]);
    for (auto a: v) if (m[a] != col[0]) {
        F0R(i,sz(c)) solveTri(a,c[i],c[(i+1)%sz(c)]);
        return;
    }
    map<pi,int> bad;
    for (auto a: c) bad[a] = 1;
    for (auto a: v) if (!bad[a]) addEdge(c[0],a);
}

int main() {
    setIO(); re(n);

    F0R(i,n) {
        int x,y,c; re(x,y,c);
        m[{x,y}] = c;
        key[{x,y}] = i;
        v.pb({x,y});
    }

    c = convex_hull(v);
    for (auto a: c) col.pb(m[a]);
    int dif = 0;
    F0R(i,sz(col)) if (col[i] != col[(i+1)%sz(col)]) dif ++;
    if (dif > 2) {
        cout << "Impossible";
        exit(0);
    }
    bool o = 0;
    for (int i: col) if (i != col[0]) o = 1;
    if (o) solveDif();
    else solveEq();
    cout << sz(ans) << "\n";
    for (auto a: ans) cout << a.f << " " << a.s << "\n";
}

/*
* (Actually read this pls)
    * Rlly bad errors: int overflow, array bounds
    * Less bad errors: special cases (n=1?), set tle
    * Common sense: do smth instead of nothing
*/


#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;

#define fo(i,n) for(int i=0; i<(int)n; i++)
#define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define pii pair<int,int>

#define mod 1000000007LL

long long dp[101][10010];
int n,k;
long long m;
long long c[101][101];
long long p[101][101][101];

long long fpow(long long a, long long b) {
    if (b==0) return 1LL;
    long long tmp = fpow(a,b/2LL);
    tmp = (tmp*tmp)%mod;
    if (b%2==0) return tmp;
    return (tmp*a)%mod;
}

int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    cin>>n>>m>>k;

    for (int i=0; i<=100; i++) {
        c[i][0] = 1;
        c[i][i] = 1;
        for (int j=1; j<i; j++) c[i][j] = (c[i-1][j]+c[i-1][j-1])%mod;
    }
    for (int i=0; i<=100; i++) for (int j=0; j<=i; j++) for (int t=1; t<=100; t++) p[i][j][t] = fpow(c[i][j],(m+n-t)/n);
    dp[0][0] = 1;

    for (int i=1; i<=n; i++) {
        for (int j=0; j<=k; j++) {
            for (int t=0; t<=n; t++) {
                if (j-t<0) continue;

                dp[i][j] = (dp[i][j] + (dp[i-1][j-t]*p[n][t][i])%mod)%mod;

            }

            //cout<<dp[i][j]<<" "<<i<<" "<<j<<endl;
        }
    }

    cout<<dp[n][k]<<endl;

    return 0;

}


#include <bits/stdc++.h>

#define pb push_back
#define pp pop_back
#define mp make_pair
#define ld long double
#define f first
#define s second
#define ll long long

using namespace std;

const int N = 1e5 + 5;

const int mod = 1e9 + 7;

ll a1, a2, b1, b2, l, r;

ll gcd (ll a, ll b, ll & x, ll & y) {
	if (a == 0) {
		x = 0; y = 1;
		return b;
	}
	ll x1, y1;
	ll d = gcd (b%a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}

bool find_any_solution (ll a, ll b, ll c, ll & x0, ll & y0, ll & g) {
	g = gcd (abs(a), abs(b), x0, y0);
	if (c % g != 0)
		return false;
	x0 *= c / g;
	y0 *= c / g;
	if (a < 0)   x0 *= -1;
	if (b < 0)   y0 *= -1;
	return true;
}

void shift_solution (ll & x, ll & y, ll a, ll b, ll cnt) {
	x += cnt * b;
	y -= cnt * a;
}

ll find_all_solutions (ll a, ll b, ll c, ll minx, ll maxx, ll miny, ll maxy) {
	ll x, y, g;
	if (! find_any_solution (a, b, c, x, y, g))
		return 0;
	a /= g;  b /= g;

	ll sign_a = a>0 ? +1 : -1;
	ll sign_b = b>0 ? +1 : -1;

	shift_solution (x, y, a, b, (minx - x) / b);
	if (x < minx)
		shift_solution (x, y, a, b, sign_b);
	if (x > maxx)
		return 0;
	ll lx1 = x;

	shift_solution (x, y, a, b, (maxx - x) / b);
	if (x > maxx)
		shift_solution (x, y, a, b, -sign_b);
	ll rx1 = x;

	shift_solution (x, y, a, b, - (miny - y) / a);
	if (y < miny)
		shift_solution (x, y, a, b, -sign_a);
	if (y > maxy)
		return 0;
	ll lx2 = x;

	shift_solution (x, y, a, b, - (maxy - y) / a);
	if (y > maxy)
		shift_solution (x, y, a, b, sign_a);
	ll rx2 = x;

	if (lx2 > rx2)
		swap (lx2, rx2);
	ll lx = max (lx1, lx2);
	ll rx = min (rx1, rx2);

	return (rx - lx) / abs(b) + 1;
}

void get(ll a, ll b, ll low, ll high, ll &al, ll &ar)
{
  al = (low - b) / a;
  if (1ll * al * a + b < low) al++;
  ar = (high - b) / a;
  if (1ll * ar * a + b > high) ar--;
}

int main()
{
  ios_base::sync_with_stdio(0);

  clock_t start = clock();

  cin >> a1 >> b1 >> a2 >> b2 >> l >> r;
  ll l1, r1, l2, r2;
  get(a1, b1, l, r, l1, r1);
  get(a2, b2, l, r, l2, r2);
//  cout << l1 << " " << r1 << " " << l2 << " " << r2 << endl;
  if (l1 > r1 || l2 > r2 || r1 < 0 || r2 < 0) cout << 0 << endl;
  else
  {
    l1 = max(l1, 0ll);
    l2 = max(l2, 0ll);
    r1 = max(r1, 0ll);
    r2 = max(r2, 0ll);
    cout << find_all_solutions(a1, -a2, b2 - b1, l1, r1, l2, r2) << endl;
  }

  double duration = ((double) clock() - start) / (double) CLOCKS_PER_SEC;
//  cout << "Time: " << fixed << setprecision(10) << duration << endl;

  return 0;
}


#include <stdio.h>
#include <vector>
#include <algorithm>
#include <climits>
#include <cassert>

using std::vector;

int main() {
	int n;
	scanf("%d", &n);
	vector<int> seq(n + 1);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &seq[i]);
	}

	const int INF = INT_MAX - 1;
	vector<vector<vector<vector<int>>>> dp(n + 1, vector<vector<vector<int>>>(n + 2, vector<vector<int>>(n + 2, vector<int>(2, INF)))); // [i][nOdds][nEvens][last 0/1] -> cnt
	for (int nEvens = 0; nEvens <= n; nEvens++) {
		for (int nOdds = 0; nOdds <= n; nOdds++) {
			dp[0][nEvens][nOdds][0] = 0;
			dp[0][nEvens][nOdds][1] = 0;
		}
	}

	for (int i = 1; i <= n; i++) {
		for (int nEvens = 0; nEvens <= i; nEvens++) {
			int nOdds = i - nEvens;

			int e_last_even = nEvens == 0 ? INF : dp[i - 1][nEvens - 1][nOdds][0];
			int e_last_odd = nEvens == 0 ? INF : dp[i - 1][nEvens - 1][nOdds][1];
			int o_last_even = nOdds == 0 ? INF : dp[i - 1][nEvens][nOdds - 1][0];
			int o_last_odd = nOdds == 0 ? INF : dp[i - 1][nEvens][nOdds - 1][1];
			if (!seq[i]) {
				dp[i][nEvens][nOdds][0] = std::min(e_last_even, e_last_odd + 1);
				dp[i][nEvens][nOdds][1] = std::min(o_last_even + 1, o_last_odd);
			} else if (seq[i] % 2) {
				dp[i][nEvens][nOdds][1] = std::min(o_last_even + 1, o_last_odd);
			} else {
				dp[i][nEvens][nOdds][0] = std::min(e_last_even, e_last_odd + 1);
			}
		}
	}

	int ans = std::min(dp[n][n / 2][n / 2 + (n % 2)][0], dp[n][n / 2][n / 2 + (n % 2)][1]);
	printf("%d", ans);
	return 0;
}


#include<iostream>
#include<fstream>
#include<cmath>
#include<string>
#include<set>
#include<algorithm>
using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		s[i] = tolower(s[i]);
		if (!(s[i] == 'e' || s[i] == 'y' ||
			  s[i] == 'u' || s[i] == 'i' ||
			  s[i] == 'a' || s[i] == 'o'))
			cout << '.' << s[i];

	}
	cout << endl;

	return 0;
}


// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 1e-8
#define patkan 9
#define ff first
#define ss second
using uint = unsigned int;
using cat = long long;
using dbl = long double;
constexpr dbl pi = 3.14159265358979323846;
using namespace std;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

template <typename T>
T abs(T x) { return (x < 0) ? (-x) : x; }

cat gcd(cat a, cat b) {
	if(a > b) swap(a, b);
	while(a) {
		cat c = b%a;
		b = a;
		a = c;
	}
	return b;
}

cat pw(cat a, cat e, cat mod) {
	if(e <= 0) return 1;
	cat x = pw(a, e/2, mod);
	x = x * x % mod;
	return (e&1) ? x * a % mod : x;
}

template <typename T>
class fin {
	vector<T> node_val;

	int lastone(int x) { return x & (x ^ (x-1)); }

public:
	fin(int N, T init_val) {
		node_val.resize(N+10, init_val);
	}

	void put(int pos, T val) {
		for(int i = pos+1; i < (int)node_val.size(); i += lastone(i))
			node_val[i] += val;
	}

	T get(int pos) {
		T ret = 0;
		for(int i = pos+1; i > 0; i -= lastone(i))
			ret += node_val[i];
		return ret;
	}
};

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(12);
	int N;
	cin >> N;
	constexpr cat mod = 998244353;
	constexpr cat inv2 = (mod+1)/2;
	constexpr cat inv3 = (mod+1)/3;
	vector<int> cnt_arb(N+1, 0);
	cnt_arb[0] = 1;
	for(int i = 1, s = 0; i <= N; i++) {
		cnt_arb[i] = (1 + s + (cnt_arb[i-1] + 1) * inv2) % mod * cnt_arb[i-1] % mod;
		s += cnt_arb[i-1];
		if(s >= mod) s -= mod;
	}
	cat ans = (2 * cnt_arb[N] - cnt_arb[N-1]) % mod;
	ans = (ans + inv3 * cnt_arb[N-1] % mod * (cnt_arb[N-1]+1) % mod * (cnt_arb[N-1]+2)) % mod;
	cat s = 0;
	for(int i = 0; i < N-1; i++) s += cnt_arb[i];
	s %= mod;
	ans = (ans + s * (s+1) % mod * cnt_arb[N-1] + s * cnt_arb[N-1] % mod * (cnt_arb[N-1]+1)) % mod;
	for(int i = 1; i < N; i++) ans = (ans + 1LL * cnt_arb[N-1-i] * (cnt_arb[i] - cnt_arb[i-1])) % mod;
	if(ans < 0) ans += mod;
	cout << ans << "\n";
}

// look at my code
// my code is amazing


#include <bits/stdc++.h>
#define fs first
#define sc second

using namespace std;

const int inf = 1000 * 1000 * 1000 + 228;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    set <pair <int, int> > st;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        auto it = st.lower_bound({l, inf});
        if (it != st.begin()) {
            it--;
            pair <int, int> p = *it;
            if (p.sc >= l) {
                st.erase(it);
                l = p.fs;
                r = max(r, p.sc);
            }
        }
        while (1) {
            it = st.lower_bound({l, -1});
            if (it != st.end()) {
                pair <int, int> p = *it;
                if (p.fs <= r) {
                    st.erase(it);
                    r = max(r, p.sc);
                } else {
                    st.insert({l, r});
                    break;
                }
            } else {
                st.insert({l, r});
                break;
            }
        }
        cout << st.size() << '\n';
    }
    return 0;
}


#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#define INF 0x3f3f3f3f
using namespace std;
int p[16]={1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0};
int main()
{
    int n,ans,a;

    scanf("%d",&n);
    if(n==0) cout<<1;
    else{
        ans=0;
        while(n)
        {
            a=n%16;
            n/=16;
            ans+=p[a];
        }
        cout<<ans<<endl;
    }

    return 0;
}


#include<iostream>

#include<queue>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<cmath>
#define MOD 1000000007
#define MAXN 55
using namespace std;
struct node
{
      int n1,n2,t;
}h,p;
__int64 dis[MAXN][MAXN][2],methods[MAXN][MAXN][2];
queue<node> Q;
int n,k;

__int64 Cal(int r,int l)
{
    __int64 result=1;
    for(int i=1;i<=l;i++)
        result=(result*(r-i+1)/i)%MOD;
    return result;
}

int main()
{
      int i,j;
      while (~scanf("%d%d",&n,&k))
      {
              int n1,n2;
              n1=n2=0;
              for (i=1;i<=n;i++)
              {
                     int W;
                     scanf("%d",&W);
                     if (W==50) n1++; else n2++;
              }
              memset(dis,0,sizeof(dis));
              memset(methods,0,sizeof(methods));
              dis[n1][n2][0]=1;
              methods[n1][n2][0]=1;
              h.n1=n1,h.n2=n2,h.t=0;
              while (!Q.empty()) Q.pop();
              Q.push(h);
              while (!Q.empty())
              {
                     h=Q.front();
                     Q.pop();
                     for (j=0;j<=h.n2;j++)
                     {
                        //   if (j*100>k) break;
                           for (i=0;i<=h.n1;i++)
                           {
                                  if (!j && !i) continue;
                                  if (i*50+j*100>k) break;
                                  p.n1=n1-h.n1+i,p.n2=n2-h.n2+j,p.t=1-h.t;
                                  if (!dis[p.n1][p.n2][p.t])
                                  {
                                         Q.push(p);
                                         dis[p.n1][p.n2][p.t]=dis[h.n1][h.n2][h.t]+1;
                                          for(int l=0;l<20000000;l++)
              {
                  int sum=0;

                      sum+=l;

              }
                                  }
                              if (dis[p.n1][p.n2][p.t]==dis[h.n1][h.n2][h.t]+1)
                                  {

                                        __int64 t;
                                         t=(Cal(h.n1,i)*Cal(h.n2,j))%MOD;
                                         t=(t*methods[h.n1][h.n2][h.t])%MOD;
                                         methods[p.n1][p.n2][p.t]=(methods[p.n1][p.n2][p.t]+t)%MOD;
                                  }
                           }
                     }
              }
              printf("%I64d\n%I64d\n",dis[n1][n2][1]-1,methods[n1][n2][1]);
              for(int l=0;l<1000000;l++)
              {
                  int sum=0;
                  for(int lm=0;l<1000000;l++)
                  {

                      sum+=lm;
                  }
              }

      }
      return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <unordered_map>
#include <cassert>
#include <time.h>

#define prev asasdasd
#define next aasdasda
#define rank asdasdknlasd

using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
	for (T x : s)
		cout << x << " ";
	cout << endl;
}

vector<int> p;
vector<vector<int> > can;
vector<int> v;
int maxi = 1e8;

void gen(ll s, int cur, int prev, int now){
	if (s > maxi)
		return;
	can.push_back(v);
	if (now + 1 <= prev){
		v[cur]++;
		gen(s * p[cur], cur, prev, now + 1);
		v[cur]--;
	}
	if (now > 0){
		for (int i = cur + 1; i < p.size(); i++){
			v[i]++;
			gen(s * p[i], i, now, 1);
			v[i]--;
		}
	}
}

const int MAX = 6100;
const int MAXC = 200;
int dist[MAX][MAXC];

int cnt(int x){
	int answer = 1;
	for (int i = 0; i < 8; i++)
		answer *= can[x][i] + 1;
	return answer;
}

int color[MAX];
map<vector<int>, int> mapa;

void precalc(){
	p = {2, 3, 5, 7, 11, 13, 17};
	v.resize(8);
	gen(1, 0, 100, 0);
	int n = can.size();
	for (int i = 0; i < n; i++)
		mapa[can[i]] = i;
	for (int i = 0; i < n; i++)
		fill(dist[i], dist[i] + MAXC, MAX);
	vector<int> diff;
	for (int i = 0; i < n; i++)
		diff.push_back(cnt(i));
	sort(diff.begin(), diff.end());
	diff.resize(unique(diff.begin(), diff.end()) - diff.begin());
	// cout << n << " " << diff.size() << endl;
	for (int i = 0; i < n; i++)
		color[i] = lower_bound(diff.begin(), diff.end(), cnt(i)) - diff.begin();
	for (int i = 0; i < n; i++)
		fill(dist[i], dist[i] + MAXC, MAX);
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			int d = 0;
			for (int l = 0; l < 8; l++)
				d += abs(can[i][l] - can[j][l]);
			dist[i][color[j]] = min(dist[i][color[j]], d);
		}
	}
}

int translate(int a){
	if (a == 1)
		return 0;
	int b = 2;
	vector<int> power;
	while (b * b <= a){
		if (a % b == 0){
			int cnt = 0;
			while (a % b == 0){
				cnt++;
				a /= b;
			}
			power.push_back(cnt);
		}
		b++;
	}
	if (a > 1)
		power.push_back(1);
	sort(power.begin(), power.end());
	reverse(power.begin(), power.end());
	while (power.size() < 8)
		power.push_back(0);
	return mapa[power];
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	// freopen("test.in", "r", stdin);
	precalc();
	int n;
	cin >> n;
	while (n-- > 0){
		int a, b;
		cin >> a >> b;
		a = translate(a);
		b = translate(b);
		// cout << a << " " << b << endl;
		// print(can[a]);
		// print(can[b]);
		int answer = MAX;
		for (int i = 0; i < MAXC; i++)
			answer = min(answer, dist[a][i] + dist[b][i]);
		cout << answer << endl;
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
    int i,j,k,l,m;
    char s[55];
    scanf("%s",&s);
    l=strlen(s);
    m=l;
    l=l-1;
    j=l/2;
    k=j+1;
    if(m%2==1)
    {
        while(j>=1)
        {
            printf("%c%c",s[j],s[k]);
            j--;
            k++;
        }
        printf("%c",s[0]);
    }
     else if(m%2==0)
    {
        while(j>=0)
        {
            printf("%c%c",s[j],s[k]);
            j--;
            k++;
        }

    }

}


/**
 *      author : azhar556
 *      28 October 2018   2:45 AM (+7)
**/

#include <bits/stdc++.h>
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()

using namespace std;

typedef double db;
typedef long long i64;

const int MAX = 1e9 + 7;
const db PI = 3.1415926535;

void solve()
{
	int a, b, c;
	cin >> a >> b >> c;

	int res = -1;
	for (int i = 1; i <= 100000; i++)
	{
		a *= 10;
		if (a / b == c)
		{
			res = i; break;
		}
		a %= b;
	}

	cout << res;
}

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

	solve();

	cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
	return 0;
}


#include<bits/stdc++.h>
int main(){int x;std::cin>>x;std::cout<<2-x*x;}


#include <bits/stdc++.h>

using namespace std;

char check[10]={'a','e','i','o','u','1','3','5','7','9'};

int main()
{
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        for(int j=0;j<10;j++) {
            if(s[i]==check[j]) {
                ans++;break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

static long long inf = (1LL << 58LL);
static long long F[6];
static long long ten[6] = {1, 10, 100, 1000, 10000, 100000};
static long long dp[1000005];
int N, K;

int main(){
	cin >> K;
	for(int i = 0;i <= 5;i++) cin >> F[i];

	int Q; cin >> Q;
	assert(Q == 1);

	int N; cin >> N;

	///0-1 knapsack with duplicate elements
	fill(dp,dp+N+1,-inf); dp[0] = 0;
	for(int d = 0;d <= 5;d++){
		long long left = 3 * (K - 1);
		long long group = 1;

		///grouping 3*(K-1) elements into groups of powers of 2
		while(left > 0){
			group = min(group, left);

			long long value = group * F[d];
			long long weight = group * ten[d] * 3;
			for(int i = N;i >= weight;i--) dp[i] = max(dp[i], dp[i-weight] + value); ///knapsack DP

			left -= group;
			group *= 2;
		}
	}

	long long ans = 0;
	for(int X = 0;X <= N;X++){
		///calculating the fortune of X
		long long fortune = 0;
		int x = X;
		for(int d = 0;d <= 5;d++){
			int rem = x % 10;
			if(rem == 3 || rem == 6 || rem == 9) fortune += (rem / 3) * F[d];
			x /= 10;
		}

		ans = max(ans, fortune + dp[N-X]);
	}

	cout << ans;
}


//try2
#include <iostream>
using namespace std;

int main()
{
  int n;
  cin >> n;
  int x[n];
  bool endd = false;
  for (int k = 0; k < n; k++)
    cin >> x[k];
  int like;
  while (endd == false)
  {
    for (int k = 0; k < n; k++)
      for (int j = 0; j < n; j++)
        {
          if (x[k]>x[j])
            x[k] = x[k] - x[j];
          if (x[k]<x[j])
            x[j] = x[j] - x[k];
        }
    like = x[0];
    endd = true;
    for (int k = 0; k < n; k++)
      if (x[k] != like)
        endd = false;
  }
  int summ = 0;
  for (int k = 0; k < n; k++)
    summ += x[k];
  cout << summ << endl;

  return 0;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cassert>
using namespace std;

inline int ask(int a1,int a2,int a3){ // 1: a1,a2 2: a2,a3 3: a1,a3;
  printf("%d %d %d\n",a1,a2,a3);
  fflush(stdout); char c;
  do c=getchar(); while (!(c>='A' && c<='Z'));
  return c=='X'?1:(c=='Y'?2:3);
}

const int N=2005;

int n;
int ncnt,pnt;
int ls[N],rs[N],ps[N],lc[N],rc[N];
int size[N],depth[N],sum,minv,rt;
int del[N];

inline void dfs(int u,int fa){
  size[u]=u<=n; depth[u]=depth[fa]+1; int maxv=0;
  int v;
  v=ls[u];
  if (v && v!=fa && !del[v]){
    dfs(v,u); size[u]+=size[v];
    maxv=max(maxv,size[v]);
  }
  v=rs[u];
  if (v && v!=fa && !del[v]){
    dfs(v,u); size[u]+=size[v];
    maxv=max(maxv,size[v]);
  }
  v=ps[u];
  if (v && v!=fa && !del[v]){
    dfs(v,u); size[u]+=size[v];
    maxv=max(maxv,size[v]);
  }
  maxv=max(maxv,sum-size[u]);
  if (u>n && maxv<minv) minv=maxv,rt=u;
}

inline void _new(int u){
  int a=++ncnt,b=++pnt;
  if (ps[u]) { if (ls[ps[u]]==u) ls[ps[u]]=a; else rs[ps[u]]=a; }
  ps[a]=ps[u]; rs[a]=u; ls[a]=b;
  ps[u]=a; ps[b]=a;
  lc[b]=rc[b]=b; lc[a]=lc[ls[a]]; rc[a]=rc[rs[a]];
}

int S=0,Si;
inline void Size(int u,int fa){
  S++; Si+=u<=n; int v;
  v=ls[u]; if (v && v!=fa && !del[v]) Size(v,u);
  v=rs[u]; if (v && v!=fa && !del[v]) Size(v,u);
  v=ps[u]; if (v && v!=fa && !del[v]) Size(v,u);
}

int vst[N];

inline void Divide(int u){
  S=0; Si=0; Size(u,0);
  //assert(u); vst[u]=1;
  if (S==1) { _new(u); return; }
  sum=Si; minv=1<<30;
  dfs(u,0);
  int g=rt; while ((!ls[g] || del[ls[g]]) && (!rs[g] || del[rs[g]])) g=ps[g];
  int t=ask(lc[ls[g]],rc[rs[g]],pnt+1);
  if (t==1){ //ls[u],rs[u]
    del[ls[g]]=del[rs[g]]=1;
    Divide(g);
  }else if (t==2){ //rs[u],g
    del[g]=1;
    Divide(rs[g]);
  }else{
    del[g]=1;
    Divide(ls[g]);
  }
}

int main(){
  //freopen("t.in","r",stdin);
  //freopen("t.out","w",stdout);
  scanf("%d",&n);
  ncnt=n; pnt=1; lc[1]=rc[1]=1;
  for (int i=2;i<=n;i++){
    for (int j=1;j<=2*n-1;j++) del[j]=vst[j]=0;
    Divide(1);
  }
  printf("-1\n");
  for (int i=1;i<=ncnt;i++)
    printf("%d ",ps[i]?ps[i]:-1);
  return 0;
}


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

const int MOD = 998244353;

ll dp[2][505][505][2];
ll gp[2][505][505][2];
ll qp[505];

void test_case() {
    int n, k;
    scanf("%d%d", &n, &k);
    int ck = min(n, k);
    dp[1][1][1][0] = 1;
    dp[1][1][1][1] = 1;
    gp[1][1][1][0] = 1;
    gp[1][1][1][1] = 1;
    for(int i = 2; i <= n; ++i) {
        int t = i & 1;
        int cj = min(i, ck);
        for(int j = 1; j <= cj; ++j) {
            dp[t][j][1][0] = gp[1 - t][j][j][1];
            dp[t][j][1][1] = gp[1 - t][j][j][0];
            for(int l = 2; l <= j; ++l) {
                dp[t][j][l][0] = dp[1 - t][j][l - 1][0];
                dp[t][j][l][1] = + dp[1 - t][j][l - 1][1];
                if(l == j) {
                    dp[t][j][l][0] += dp[1 - t][j - 1][l - 1][0];
                    dp[t][j][l][1] += dp[1 - t][j - 1][l - 1][1];
                }
            }
            for(int l = 1; l <= j; ++l) {
                dp[t][j][l][0] %= MOD;
                dp[t][j][l][1] %= MOD;
                gp[t][j][l][0] = (gp[t][j][l - 1][0] + dp[t][j][l][0]) % MOD;
                gp[t][j][l][1] = (gp[t][j][l - 1][1] + dp[t][j][l][1]) % MOD;
            }
        }
    }

    int t = n & 1;
    for(int j = 1; j <= ck; ++j)
        qp[j] = (qp[j - 1] + gp[t][j][j][0]) % MOD;

    ll ans = 0;
    for(int i = 1; i <= ck; ++i)
        ans += (gp[t][i][i][0] + gp[t][i][i][1]) % MOD * qp[min(ck, k / i - (k % i == 0))] % MOD;

    ans %= MOD;
    printf("%lld\n", ans);
}

int main() {
#ifdef KisekiPurin
    freopen("KisekiPurin.in", "r", stdin);
#endif // KisekiPurin
    int t = 1;
    //scanf("%d", &t);
    for(int ti = 1; ti <= t; ++ti) {
        //printf("Case #%d: ", ti);
        test_case();
    }
}

/*
    1. С���������˻���
        ����Ϊ0��1�᲻������������������ı�����С��Ҫ�������㣬ǿ��ͨ�����������һ����ȵȡ�
    2. �ڴ棺
        �ڴ�Ŀռ���û�п�������ʱ�з���ߣ���ʱ�ж����¼ӵıߡ��߶�������4������
        �ɳ־û����ݽṹ�᲻���ڴ��������������ʱvector�᲻�ᷭ�����ַ���Сд�п�����
        ���������н��г�ʼ����memset�᲻�ᷭ����
    3. ���������
        �˷�������ˣ�����ȡģ�ˣ������������%d�����޷�����Խ�������ˣ�
    4. ϰ�ߣ�
        ��������ָ������ֵ�𣿷���ֵ��void������ÿһ����֧������ʽ�ķ���ֵ��ȷ���������ķ�֧����assertһ�ѡ�
        Yes��No��û�з�����Сд��û�д���û�и��n��m����ɢ��֮���cn��û�д����кͿո�Ҫ��ô����priorityҪ�ѷ��ŷ�������
    5. ����bug��
        �����������ӻ����������ӻ���
*/


/**
	试问岭南应不好,却道,此心安处是吾乡。
**/
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <queue>
//#include <tr1/unordered_set>
//#include <tr1/unordered_map>
//#include <bitset>
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define inf 1e9
#define debug(a) cout << #a" = " << (a) << endl;
#define debugarry(a, n) for (int i = 0; i < (n); i++) { cout << #a"[" << i << "] = " << (a)[i] << endl; }
#define clr(x, y) memset(x, y, sizeof x)
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) \
	for(i=a;a<b?i<=b:i>=b;a<b?i++:i--)

int cal(int x,int c)
{
	int l=-inf,r=inf;
	int ans = -inf;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(mid*2+c<=x)
		{
			ans = max(ans,mid);
			l=mid+1;
		}
		else r = mid-1;
	}
	return ans;
}

int main()
{
//	freopen("input.txt","r",stdin);
	int x1,x2,y1,y2;
	while(~scanf("%d%d%d%d",&x1,&y1,&x2,&y2))
	{
		if( (y1-x1)%2 )
		{y1--;y2--;}
		ll ans;
		int t = (x2-x1)/2;
		if(x1%2)
			ans = (ll)(cal(y2,1)-cal(y1-1,1)) * (t+1) + (ll)(cal(y2,0)-cal(y1-1,0)) * t;
		else
			ans = (ll)(cal(y2,1)-cal(y1-1,1)) * t + (ll)(cal(y2,0)-cal(y1-1,0)) * (t+1);
		printf("%I64d\n",ans);
	}
	return 0;
}


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

inline int F(int a, int b) { return a*a + b*b - a*b; }

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int N = n+1;
	long long res = 0;
	for(int i = m+1; i <= (n+1)/2; ++i) {
		int p = 0;
		int j = m+1, k = m+1;
		int S = 2*i*i + N*(N+j-3*i-k) + i*(j+k) - j*k;
		int x = i-N, y = i+N;
		for( ; j <= n-m; ++j) {
			while(k <= n-m && S >= 0) {
				S += x-j;
				++k;
			}
			p += n-m+1-k;
			S += y-k;
		}

		if((n & 1) && i == (n+1)/2)
			res += p;
		else res += 2*p;
	}

	printf("%lld\n", 3*res);
	return 0;
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define clr( a , v ) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define sz size()
#define FORN( i , s , n ) for( int i = s ; i < (int)(n) ; i++ )
#define FOR( i , n ) FORN( i , 0 , n )
#define FORIT(i,x) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define read ios::sync_with_stdio(false)
#define unos(x) __builtin_popcount (x)
#define TAM 1000005

using namespace std;

typedef long long int64;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;

void GCD (int64 a , int64 b , int64& G, int64& x, int64& y){ // G=GCD(a,b)= ax + by
    if(b==0)    {G=a; x=1;y=0;  }
    else{
        GCD(b,a%b,G,y,x);   y-=floor(a/b)*x;
    }
}

int MCD (int x,int y){
        return (y==0 ? x:MCD(y,x%y));
}

int MCM(int x ,int y){
        return (x*y/MCD(x,y));
}

queue <int> carta1, carta2;
int aux1[20] , aux2[20];

int main() {
    int n,k1,k2;
    scanf("%d",&n);
    scanf("%d",&k1);
    int cont=0,battles=0;
    FOR(i,k1) scanf("%d",&aux1[i]);
    scanf("%d",&k2);
    FOR(i,k2) scanf("%d",&aux2[i]);
    FOR(i,k1) carta1.push(aux1[i]);
    FOR(i,k2) carta2.push(aux2[i]);

    while(carta1.size()!=0 && carta2.size()!=0 ){
        battles++; cont++;
        int auxi1=carta1.front();
        int auxi2=carta2.front();
        carta1.pop();
        carta2.pop();
        if(auxi1>auxi2){
            carta1.push(auxi2);
            carta1.push(auxi1);
        }
        else if(auxi2>auxi1){
            carta2.push(auxi1);
            carta2.push(auxi2);
        }
        if(cont==1000000){
            printf("-1\n");
            return 0;
        }
    }
    printf("%d ",battles);
    if(carta1.size()==0){
        printf("2\n");
    }
    if(carta2.size()==0){
        printf("1\n");
    }
    return 0;
}


#include<bits/stdc++.h>
#define For(i,m,n) for(register int i=m;i<n;i++)
#define rFor(i,m,n) for(register int i=m;i>n;i--)
#define r(a) read(a)
#define rr(a,b) read(a),read(b)
#define rrr(a,b,c) read(a),read(b),read(c)
using namespace std;
typedef long long ll;
typedef unsigned long long Ull;
template <class T>
inline void read(T &x)
{
	x=0;
    T f=1;
    char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	x=x*f;
}
const int MaxN = 50005, MaxM = 4*1e7+500;
const int SMALL_INF=1e8;
const int MOD=100003;
int n,m,k;

ll C(int x,int y)
{
    ll res=1;
    For(i,1,y+1){
        res*= x - y + i ;
        res/= i;
    }
    return res;
}

ll fac(int n)
{
    if(n <= 1){
        return 1;
    }
    return fac(n - 1) * n;
}

void input()
{
    r(n);
    int k=n/2;
    ll ans = C(n , k) * fac(k) * fac(k) / 2 / k / k;
    cout<<ans;
}

int main()
{
    // freopen("out.txt","w",stdout);
    input();

    return 0;
}


// Author:: MUKUL KUMAR RAI
// Institution:: Jalpaiguri Government Engineering College
//If you are not doing well now just stick to it and learn new things one day you will be...
//Compete with yourself
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
///*template{{{
#define sz(x) (ll)x.size()
#define all(x) x.begin(),x.end()
#define trav(a,x) for(auto &a:x)
#define fr(i,a,b)  for(ll i=a;i<=b;i++)
#define fr1(i,a)   for(ll i=0;i<a;i++)
#define frr(i,a,b) for(ll i=b;i>=a;i--)
#define frr1(i,a)   for(ll i=a-1;i>=0;i--)
#define sorta(a,n) sort(a,a+n)
#define sortd(a,n) sort(a,a+n,greater<ll>())
#define sorva(a) sort(a.begin(),a.end())
#define sortvd(a) sort(a.begin(),a.end(),greater<ll>())
#define tc(t) while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
using vi= vector<ll>;
using vvi= vector<vi>;
using vb =vector<bool>;
using vc =vector<char>;
using vs =vector<string>;
using vld =vector<ld>;
using pii =pair<ll,ll>;
using psi =pair<string,ll>;
using pci =pair<char,ll>;
using vpii =vector<pii>;
//}}}template*/
ll const mod=1e9+7;
ll const maxn=1e5+5;
ll const inf=1e18;
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modinverse(ll a, ll m){
    return powm(a,m-2,m);
}
bool prime(ll x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++)if(x%i==0)return false;
    return true;
}
ll divisor(ll x){
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
vector<ll> sieve(ll n) {
    bool prim[n+1];
    memset(prim, true, sizeof(prim));

    for (ll p=2; p*p<=n; p++) {
        if (prim[p] == true) {
            for (int i=p*p; i<=n; i += p)
                prim[i] = false;
        }
    }
    vector<ll>v;
    for(int i=2;i<=n;i++)if(prim[i])v.push_back(i);
    return v;
}
ll const N=1e6+2;
ll a,b,n;
ll fact[N];
ll inv[N];
bool check(ll x){
    while(x){
        ll p=x%10;
        if(p!=a and p!=b)return false;
        x/=10;
    }
    return true;
}

void solve(){
    cin>>a>>b>>n;
    inv[0]=1;
    fact[0]=1;
    for(ll i=1;i<=n;i++){
        fact[i]=mul(fact[i-1],i);
        inv[i]=modinverse(fact[i],mod);
    }
    vi v;
    for(int i=0;i<=n;i++){
        if(check(i*a+(n-i)*b))v.pb(i);
    }
    ll ans=0;
    for(auto r:v){
        ans=add(ans,mul(fact[n],mul(inv[r],inv[n-r])));
    }
    cout<<ans;

}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fio;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
   return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
using namespace std;

typedef long long ll;
#ifdef WIN32
#define llf "%I64d"
#else
#define llf "%lld"
#endif
#define initIO(pn) freopen(pn ".in", "r", stdin), freopen(pn ".out", "w", stdout)
#define arrset(p, v) memset(p, v, sizeof(p))
const int MAXN = 1e3 + 10;

int n, m;
ll c[MAXN], g[MAXN], a1[MAXN], a2[MAXN], b1[MAXN], b2[MAXN];

inline void work(ll x, int n, ll *d1, ll *d2) {
	if (n == 0) {
		d1[n] = d2[n] = 0;
		return;
	}
	if (n == 1) {
		d1[n] = (x == 2); d2[n] = (x == 1);
		return;
	}
	if (x <= c[n - 1]) {
		work(x, n - 1, d1, d2);
		d1[n] = min(d1[n - 1], d2[n - 1] + 2);
		d2[n] = min(d2[n - 1], d1[n - 1]) + 1 + g[n - 2];
	} else {
		work(x - c[n - 1], n - 2, d1, d2);
		d1[n] = d1[n - 2] + 1;
		d2[n] = d2[n - 2];
	}
}

inline ll dis(ll u, ll v, int n) {
	if (n <= 1) return (u != v);
	if (u <= c[n - 1]) {
		if (v > c[n - 1])
			return min(a1[n - 1], a2[n - 1]) + b1[n - 2] + 1;
		else
			return min(dis(u, v, n - 1), min(a1[n - 1] + b2[n - 1], b1[n - 1] + a2[n - 1]) + 2);
	} else
		return dis(u - c[n - 1], v - c[n - 1], n - 2);
}

void lucky() {
#ifndef ONLINE_JUDGE
	initIO("graph");
#endif
	scanf("%d %d", &m, &n);
	n = min(n, 80);          // c[80] = 6e16
}

int main() {
	ll u, v;
	lucky();
	c[0] = 1; c[1] = 2;
	for (int i = 2; i <= n; i++)
		c[i] = c[i - 1] + c[i - 2];
	g[0] = 0; g[1] = g[2] = 1;
	for (int i = 3; i <= n; i++)
		g[i] = g[i - 2] + 1;
	while (m--) {
		scanf(llf llf, &u, &v);
		if (u > v) swap(u, v);
		work(u, n, a1, a2);
		work(v, n, b1, b2);
		printf(llf "\n", dis(u, v, n));
	}
	return 0;
}


//#include "pch.h"
#include <iostream>

using namespace std;

int main()
{
	int n, i, k = 0, max = 0;
	char k1 = '0';
	cin >> n;
	int *a = new int[n+1];
	a[n] = 1001;
	for (i = 0; i < n; i++) cin >> a[i];
	if (a[0] == 1 && a[1] == 2) {
		k++;
		k1 = '1';
	}
	for (i = 1; i < n + 1; i++) {
		if (a[i] == a[i - 1] + 1) {
			k++;
			k1 = '1';
		}
		else if (k1 == '1') {
			k1 = '0';
			if (max < k) max = k;
			k = 0;
		}
	}
	if (max < k) max = k;
	if (max!=0) cout << max - 1 << endl;
	else cout << "0" << endl;
	delete[] a;
//	system("pause");
	return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<list>
#include<queue>
#include<vector>
#include<stack>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<string.h>
#include<string>
#define mod 1000000009
#define LL long long int
using namespace std;
int r,b;
int points[2][20][2]={0};
bool flag=false;
int cha(int x,int y,int x2,int y2)
{
    if((x*y2-x2*y)>0)return 1;
    else return -1;
}
bool connect(int i,int j,int a[])
{
    int x[2][2]={0};
    int y[2][2]={0};
    x[0][0]=points[0][i][0];
    x[0][1]=points[1][a[i]][0];
    x[1][0]=points[0][j][0];
    x[1][1]=points[1][a[j]][0];

    y[0][0]=points[0][i][1];
    y[0][1]=points[1][a[i]][1];
    y[1][0]=points[0][j][1];
    y[1][1]=points[1][a[j]][1];

    int tmp1=cha(x[1][0]-x[0][0],y[1][0]-y[0][0],x[0][1]-x[0][0],y[0][1]-y[0][0]);
    int tmp2=cha(x[1][1]-x[0][0],y[1][1]-y[0][0],x[0][1]-x[0][0],y[0][1]-y[0][0]);

    int tmp3=cha(x[0][0]-x[1][0],y[0][0]-y[1][0],x[1][1]-x[1][0],y[1][1]-y[1][0]);
    int tmp4=cha(x[0][1]-x[1][0],y[0][1]-y[1][0],x[1][1]-x[1][0],y[1][1]-y[1][0]);

    if(tmp1*tmp2<0 && tmp3*tmp4<0)return true;
    else return false;

}
bool check(int a[])
{
    for(int i=0;i<r;++i)
    {
        for(int j=i+1;j<r;++j)
        {
            if(connect(i,j,a))return false;
        }
    }
    return true;
}
void matching(int a[],bool used[],int ind)
{
    if(ind==r)
    {
        if(check(a))flag=true;
    }
    else
    {
        for(int i=0;i<r;++i)
        {
            if(!used[i])
            {
                a[ind]=i;
                used[i]=1;
                matching(a,used,ind+1);
                used[i]=0;
            }
        }
    }
}
int main()
{
    scanf("%d%d",&r,&b);
    if(r!=b)
    {
        cout<<"No"<<endl;
    }
    else
    {
        for(int i=0;i<r;++i)cin>>points[0][i][0]>>points[0][i][1];
        for(int i=0;i<r;++i)cin>>points[1][i][0]>>points[1][i][1];
        bool used[20]={0};
        int a[20]={0};
        matching(a,used,0);
        if(flag)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


#include<cstdio>
#define ll long long
using namespace std;
int main(){
	ll w1,w2,h1,h2,ans=0;
	scanf("%lld%lld%lld%lld",&w1,&h1,&w2,&h2);
	ans+=w1+w1+h1+h1+h2+h2+4;
	printf("%lld\n",ans);
	return 0;
}


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

ll a[10],ans,w;

void knp(int n, ll s){
	if(!n){
		ans = max(ans,s);
		return;
	}
	for(ll k = 8,i=min((w-s)/n,a[n]);k>0&&i>=0;i--,k--){
		knp(n-1,s+max((ll)0,i*n));
	}
}

int main(){
    // freopen("input.txt","r",stdin);
    cin>>w;
    for(int i=1;i<=8;i++){
    	cin>>a[i];
    }
    knp(8,0);
    cout<<ans<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair<ll,ll>
#define C continue
#define B break
#define pb push_back
#define R return
using namespace std;
ll w[100003];
P w1[200003];
vector <char> v,ans;
map <ll,ll> M,M1;
ll a,b,c,n,m,q,k,x,c1,b1;
ll poww(ll x,ll y){
    if (x==0) R 0;
    if (x==1) R 1;
    if (y==0) R 1;
    if (y==1) R x;
    ll d=poww(x,y/2);
    if (y%2) R d*d*x;
    R d*d;
}
ll l,r,y;
ll inf=-999999999;
bool anss;
int main()
{
    char d='a';
    cin >>n;
    w[2]=1;
    for (int i=3;;i++){
        w[i]=w[i-1]+i-1;
        if (w[i]>100000) {a=i;B;}
    }
    for (int i=a;i>=1;i--){
        if (w[i]<=n){
            n-=w[i];
            for (int j=0;j<i;j++) printf("%c",d);
            d++;
            if (i==1) R 0;
            i++;
        }
    }
    R 0;
}


/*
最先想到的思路肯定是递归了，使用dfs。
我一开始写了一个正向的，从(1,1) 往后找。
可是这样并不行，因为有太多种情况了，运算的次数是指数级的，再多的剪枝也不行。
所以我们采用逆向bfs。
定义函数 void dfs(int a, int b, int step)。step 是操作的次数。
主程序：输入 n，然后从 1 遍历到 n，每次执行 dfs(i,n,0) 。
*/
#include <bits/stdc++.h>
using namespace std;
int n,ans;
void dfs(int a, int b, int s) {
	if(a<1 || b<1 || s>=ans) return;
	if(a==1 && b==1) { ans=min(ans,s); return; }
	if(a>b) dfs(a-b,b,s+1);
	else dfs(a,b-a,s+1);
}
int main() {
	scanf("%d",&n);
	ans=n;
	for(int i=1; i<=n; i++) dfs(i,n,0);
	printf("%d", ans); return 0;
}


#include<stdio.h>
int mymin(int a,int b)
{
    if(a>b)
    {
        return b;
    }
    else
    {
        return a;
    }
}
int main()
{
    int n,a[10],b[10],c[10],d[10],i,min1,min2,temp;
    while(~scanf("%d",&n))
    {
        temp=0;
        for(i=1;i<5;i++)
        {
            scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
        }
        for(i=1;i<5;i++)
        {
            min1=mymin(a[i],b[i]);
            min2=mymin(c[i],d[i]);
            if(min1+min2<=n)
            {
                temp=i;
                break;
            }
        }
        if(temp)
        {
            printf("%d %d %d\n",temp,min1,n-min1);
        }
        else
        {
            printf("-1\n");
        }
    }
    return 0;
}
/*2017-04-28 19:18:16.226*/


#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;

ll dp[2002][2002];
ll k,pa,pb;
const ll mod = 1e9 + 7;
ll ME(ll x,ll nn,ll M)
{
    ll result=1;
    while(nn>0)
    {
        if(nn % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        nn=nn/2;
    }
    return result;
}
map<ll,ll> cache;
ll inv(ll x)
{
        if(cache.count(x)) return cache[x];
        return cache[x] = ME(x,mod-2,mod);
}
ll solve(ll ones, ll ma)
{
        if(ma >= k) {
                return ma;
        }
        if(ones + ma >= k) {
                ll kk = ones + ma;
                ll ret = (kk*pb + pa)%mod; ret = (ret * inv(pb))%mod;
                return ret;
        }
        if(ones >= 2000 || ma >= 2000) return 0;
        ll &ret = dp[ones][ma];
        if(ret != -1) return ret;
        ret = (pa * solve(ones+1,ma))%mod;
        ret = (ret + (pb * solve(ones, ma+ones))%mod )%mod;
        return ret;
}
int main()
{
        cin >> k >> pa >> pb;
        ll A = pa;
        ll B = pb;
        A = inv(A + B);
        pa = (pa * A)%mod; pb = (pb * A)%mod;
        memset(dp, -1,sizeof dp);

        cout << solve(1,0) << endl;
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << ": " << x << endl
typedef long long ll;

ll getProduct(int freqArr[10]) {
    ll product = 1;
    for (int i = 0; i < 10; i++) {
        product *= freqArr[i];
    }
    return product;
}

void solve() {
    ll k;
    cin >> k;
    int freqArr[10];
    string cf = "codeforces";
    for (int i = 0; i < 10; i++) {
        freqArr[i] = 1;
    }
    int index = 0;
    while (getProduct(freqArr) < k) {
        freqArr[index]++;
        index++;
        if (index == 10) index = 0;
    }

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < freqArr[i]; j++) {
            putchar(cf[i]);
        }
    }
    printf("\n");
}

int main() {
    // int t;
    // cin >> t;
    // while (t--)
    solve();
}


#include<iostream>
using namespace std;
int a[105];
bool f[200005];
int main(){
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++) {
	cin>>a[i];sum+=a[i];}
	if(sum&1){
	cout<<"0";
		return 0;
	}
	sum/=2;
	f[0]=1;
	for(int i=1;i<=n;i++)
		for(int j=sum;j>=a[i];j--)
			f[j]|=f[j-a[i]];
	if(!f[sum]){
	   cout<<"0";
		return 0;
	}
	int minc=1e5,minp=0;
	for(int i=1;i<=n;i++){
		int x=a[i],cnt=0;
		while(!(x&1)){
			x>>=1;
			cnt++;
		}
		if(cnt<minc) minc=cnt,minp=i;
	}
	cout<<"1"<<endl;
	cout<<minp;
	return 0;
}


#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cstring>
#include<string>
#include<stack>
#include<map>
#include<cstdio>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const int MOD = 4096;
int che[102];
int n;
int ans;
string s;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	cin >> s;
	s += 'A';
	for (int i = 'z'; i >= 'a'; i--) {
		for (int j = 0; j < n; j++) {
			if (s[j] == i) {
				//cout << (char)i << ' ' << j << "\n";
				int l = j - 1;
				int r = j + 1;
				while (l > 0 && che[l]) {
					l--;
				}
				while (r < n && che[r]) {
					r++;
				}
				if (l >= 0 && s[l] == i - 1) {
					che[j] = 1;
					ans++;
				}
				else if (r <= n && s[r] == i - 1) {
					che[j] = 1;
					ans++;
				}
				if (che[j]) {
					int ll = j - 1;
					int rr = j + 1;
					while (ll > 0 && che[ll]) {
						ll--;
					}
					while (ll >= 0 && s[ll] == i && che[ll] == 0) {
						ans++;
						che[ll] = 1;
						ll--;
						while (ll>0 && che[ll]) {
							ll--;
						}
					}
				}
			}
		}
	}
	cout << ans;
}


#include <vector>
#include <queue>
#include <algorithm>
#include <memory.h>
#include <string>
#include <iostream>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;

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

	ll x, s;
	cin >> x >> s;
	// s - x = (a&b)*2
	ll dif = s - x;
	if (dif < 0 || dif & 1) { //0보다 작거나 홀수일때
		cout << -1;
		return 0;
	}
	if (dif == 0) {
		if(x){
			cout << 1 << "\n";
			cout << x;
		}
		else {
			cout << 0;
		}
		return 0;
	}
	ll a = (s - x)/2; // a and b
	ll ans1 = a;
	ll ans2 = a;
	vector<ll> ans;
	if (a & x) {
		ans.push_back(a);
		ans.push_back(a);
		ans.push_back(x);
	}
	else {
		ans.push_back(a);
		ans.push_back(a + x);
	}
	ll _size = ans.size();
	cout << _size << "\n";
	for (ll i = 0; i < _size; i++) {
		cout << ans[i] << " ";
	}
}


#include<stdio.h>
#define lli long long int

lli n,c1,c2,pr=0;

lli calc(lli gr)
{
    lli num=n/gr;
    lli r=n%gr;
    lli ret=gr*c1;
    ret+=r*(n/gr)*(n/gr)*c2;
    ret+=(gr-r)*(n/gr-1)*(n/gr-1)*c2;
    return ret;
}

int main() {
    scanf("%lld%",&n);
    scanf("%lld%",&c1);
    scanf("%lld%",&c2);
    char s[n+1];
    gets(s);
    int ch=0;
    int i;
    for(i=0;i<n;i++)
        if(s[i]=='1')
            pr++;
        else
            ch++;
    int l=1,h=pr;
    lli ans=calc(l);
    for(i=l+1;i<=h;i++)
    {
        lli cur=calc(i);
        if(cur<ans)
            ans=cur;
    }
    printf("%lld",ans);
    return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        long long int r,k;
        long long int x,y;
        cin>>r;
        k=r-3;
        if(k<1){
            cout<<"NO"<<endl;
            return 0;
        }
        if(k%2!=0){
            cout<<"NO"<<endl;
            return 0;
        }
       else{
           cout<<1<<" ";
           cout<<(r-3)/2;
       }
        return 0;
    }


#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
#define INF 9223372036854775807
#define cin(x) scanf("%lld",&x)
#define pmp(x,y) push_back(make_pair(x,y))
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define ld double
#define PI 3.14159265
#define sz(a) (ll)a.size()
#define F first
#define S second
using namespace std;

map<char,ll> m;
string s;
int main()
{

	cin>>s;

	ll cnt=0;
	char ch;
	for(ll i=0;i<sz(s);i++)
	{
		if(i%4==0)
		{
			if(s[i]=='!')
				cnt++;
			else
				ch=s[i];
		}
	}

	m[ch]=cnt;

	cnt=0;

	for(ll i=0;i<sz(s);i++)
	{
		if(i%4==1)
		{
			if(s[i]=='!')
				cnt++;
			else
				ch=s[i];
		}
	}

	m[ch]=cnt;

	cnt=0;

	for(ll i=0;i<sz(s);i++)
	{
		if(i%4==2)
		{
			if(s[i]=='!')
				cnt++;
			else
				ch=s[i];
		}
	}

	m[ch]=cnt;

	cnt=0;

	for(ll i=0;i<sz(s);i++)
	{
		if(i%4==3)
		{
			if(s[i]=='!')
				cnt++;
			else
				ch=s[i];
		}
	}

	m[ch]=cnt;

	cout<<m['R']<<" "<<m['B']<<" "<<m['Y']<<" "<<m['G'];
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2050,p=998244353;
int n,m,ans;
int fac[N<<2],ifac[N<<2],inv[N<<2];
void init(int lim){
	fac[0]=ifac[0]=inv[1]=1;
	for(int i=2;i<=lim;i++)
		inv[i]=inv[p%i]*(p-p/i)%p;
	for(int i=1;i<=lim;i++){
		fac[i]=fac[i-1]*i%p;
		ifac[i]=ifac[i-1]*inv[i]%p;
	}
}
int C(int n,int m){
	return fac[n]*ifac[n-m]%p*ifac[m]%p;
}
signed main(){
	scanf("%lld%lld",&n,&m);
	init(max(n,m)<<2);
	for(int i=1;i<m;i++){
		int sum=0;
		for(int j=n-1;j>=1;j--){
			sum=(sum+C(j+m-i-1,m-i-1)*C(n-j-1+m-i,m-i)%p)%p;
			ans=(ans+sum*C(i+j-1,i)%p*C(i-1+n-j,i-1)%p)%p;
//			printf("%lld %lld : %lld %lld\n",i,j,sum,ans);
		}
//		printf("%lld %lld\n",sum,ans);
	}
	for(int i=1;i<n;i++){
		int sum=0;
		for(int j=m-2;j>=1;j--){
			sum=(sum+C(j+1+n-i-1,n-i-1)*C(m-j-2+n-i,n-i)%p)%p;
			ans=(ans+sum*C(i+j-1,i)%p*C(i-1+m-j,i-1)%p)%p;
//			printf("two, %d %d : %lld %lld\n",i,j,sum,ans);
		}
//		printf("two, %lld %lld\n",sum,ans);
	}
	printf("%lld\n",ans*2%p);
	return 0;
}
/*
3 3
72

2020 2021
50657649

2 3
10

3 2
10
*/


#include<bits/stdc++.h>
using namespace std;
int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c-'0');c=getchar();}
    return x*f;
}
int n,m;
double dp[1010][1010];
inline double f(int n,int m)
{
    if(!n)return 1.0/(m+1.0);
    if(!m)return 1.0;
    if(dp[n][m])return dp[n][m];
    double A=1.0*m/(m+1.0)*(1.0-f(m-1,n)),B=1.0;
    double C=1.0/(m+1.0)+A,D=1.0-f(m,n-1);
    double P=(D-B)/(A-B-C+D);
    return dp[n][m]=P*A+(1-P)*B;
}
int main()
{
    n=read(),m=read();
    double ans=f(n,m);
    printf("%.10lf %.10lf",ans,1.0-ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct l
{
    long long n ;
    int i;
};
long long gcd (long long x , long long y)
{
    if(x > y) swap(x,y);
    if(!x) return y ;
    else return gcd(y%x,x);
}
bool ss(l x , l y)
{
    if(x.n == y.n)
        return x.i < y.i ;
    else
        return x.n < y.n ;
}
long long lcm (long long x , long long y)
{
    return (x/gcd(x,y))*y;
}
long long fast_power(long long base , long long power)
{
    if(power == 1) return base ;
    else if(power%2) return base*fast_power(base*base,power/2);
    else return fast_power(base*base,power/2);
}
long long nCr (long long n , long long r )
{
    if(r > n) return 0;
    if(2*r > n) r = n-r ;
    if(!r) return 1;
    long long ans = n ;
    for(int i = 2 ; i <= r ; i++)
    {
        ans*=(n-i+1);
        ans/=i ;
    }
    return ans ;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a , b , c ;
    cin >> a >> b >> c ;
    long long ans = 0 ;
    for(long long i = 4 ; i <= c-1 ; i++)
    {
        long long x = c-i;
        if(x < 1) continue ;
        else ans+=nCr(a,i)*nCr(b,x);
    }
    cout << ans << endl ;
}


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

typedef long long ll;

int main()
{
	ll n, k;
	cin >> n >> k;
	if ( k > 2*n - 1 )
	{
		puts("0");
		return 0;
	}

	ll b = min( n, k );
	if ( b == k ) b -= 1ll;
	ll a = k - b;
	ll ans = (b-a+1ll) / 2ll;
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h> // strings/streams
using namespace std;
int main(){
    int n; cin >> n;
    int v[n];
    for( int i = 0 ; i < n ; ++i ){
        cin >> v[i];
    }
    sort( v, v+n );
    if( v[0] == v[n/2-1] && v[n-1] == v[n/2] && v[0] != v[n-1] ){
        cout << "YES\n";
        cout << v[0] << ' ' << v[n-1] << '\n';
    }else cout << "NO\n";
}


#include<bits/stdc++.h>
#include<string>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll              long long
#define ull             unsigned long long
#define ldb             long long double
#define pll             pair<long long, long long>
#define pb              emplace_back
#define pf              push_front
#define pof             pop_front
#define pob             pop_back
#define ft              front
#define sz              size
#define gcd             __gcd
#define bk              back
#define ub              upper_bound
#define lb              lower_bound
#define sum             accumulate
#define bs              binary_search
#define fr              first
#define sc              second
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define ins             insert
#define bg              begin
#define rep(i,a,b)      for(i=a;i<=b;i++)
#define repr(i,a,b)     for(i=a;i>=b;i--)
#define Ndigits         floor(log10(N)+1)
#define N               1000000
#define M               1000000007
#define pi              3.141592653589793238
#define FASTIO          std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
    FASTIO
    //freopen("input.txt", "r", stdin);   // to be uncommented when I/P
    //freopen("output.txt", "w", stdout); // & O/P are in file format
    ll n,i,j,p=0,d;
    cin>>n;
    vector<ll> x(n),c(101);
    rep(i,0,n-1) cin>>x[i];
    sort(all(x));
    rep(i,0,n-1)
    {
        d=0;
        rep(j,1,x[i])
        {
            if(c[j]>0)
            {
                d++;
                c[j]--;
                c[j+1]++;
                break;
            }
        }
        if(d==0)
        {
            p++;
            c[1]++;
        }
    }
    cout<<p;
    return 0;
}


#include <bits/stdc++.h>

const int S = 640;
const int N = 100000;
const int INF = (1 << 30);

int fa[S + 5][N + 5], f[N + 5][S + 5];
int find(int o, int x) {return fa[o][x] = (fa[o][x] == x ? x : find(o, fa[o][x]));}

int l[N + 5], v[N + 5], m; bool vis[S + 5];
int solve() {
	for(int i=0;i<=S;i++) vis[i] = false;
	for(int j=0;j<=S;j++) for(int i=1;i<=m+1;i++) fa[j][i] = i, f[i][j] = -INF;
	for(int i=1;i<=m;i++) fa[0][i] = i + 1, f[i][0] = INF;

	for(int i=m;i>=1;i--) {
		l[i] = 0;
		while( f[i][l[i]] != -INF ) l[i]++;
		vis[--l[i]] = true;

		for(int j=0;j<=l[i];j++) f[i][j] = (v[i] << 1) - f[i][j];
		for(int j=1;j<=l[i];j++) f[i][j] = std::max(f[i][j], f[i][j - 1]);
		for(int j=0;j<=l[i];j++) f[i][j] = std::upper_bound(v + 1, v + m + 1, f[i][j]) - v;

		for(int j=0;j<l[i];j++) {
			int le = f[i][j], ri = f[i][j + 1] - 1;
			for(int p=find(j+1,le);p<=ri;p=find(j+1,le))
				f[p][j + 1] = v[i], fa[j + 1][p] = p + 1;
		}

		int le = f[i][l[i]], ri = m;
		for(int p=find(l[i]+1,le);p<=ri;p=find(l[i]+1,le))
			f[p][l[i] + 1] = v[i], fa[l[i] + 1][p] = p + 1;
	}

	int ret = 0; while( vis[ret] ) ret++; return ret;
}

int main() {
	int ans = 0, n; scanf("%d", &n);
	for(int i=1;i<=n;i++) {
		scanf("%d", &m);
		for(int j=1;j<=m;j++) scanf("%d", &v[j]);
		ans ^= solve();
	}
	puts(ans ? "YES" : "NO");
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    string a[n+1];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int eaten =0;
    for(int i=0; i<n;i++){
        for(int j=0; j<m; j++){
            if(a[i][j]=='W'){
                 if (a[i-1][j] == 'P' || a[i+1][j] == 'P' || a[i][j-1] == 'P' || a[i][j+1] == 'P'){
                     eaten++;
                 }
            }
        }
    }
    cout<<eaten;
    return 0;
}


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

int main()
{
    //freopen("in", "r",stdin);
    int ln,tt=0;
    cin>>ln;
    string str;
    cin>>str;
    for(int i=1;i<ln/2;i++)
    {
        for(int j=0;j<ln;j++)
        {
            tt=0;
            for(int k=j;k<ln;k+=i)
            {
                if (str[k]=='*')
                    tt++;
                else
                    break;
            }
            if(tt>=5)
            {
               cout<< "yes"<<endl;
               return 0;
            }
        }
    }

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


#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
using namespace std;

char c1[1005];
char c2[1005];
int k;
int num[2][1005];
int sum[2];
int inf=1000000007;

int main()
{

    scanf("%s%s%d",c1,c2,&k);

    int l=strlen(c1);
    int t=0;
    num[0][0]=1;
    sum[0]=1;

    for (int i=0;i<k;i++)
    {
        int nxtsum=0;
        for (int j=0;j<l;j++)
        {
            int curnxtval=sum[t]-num[t][j];
            if (curnxtval<0)
                curnxtval+=inf;
            nxtsum+=curnxtval;
            num[t^1][j]=curnxtval;
            if (nxtsum>inf)
                nxtsum-=inf;
        }
        sum[t^1]=nxtsum;
        t^=1;
    }
    int ans=0;
    for (int i=0;i<l;i++)
    {
        bool good=true;
        for (int j=0;j<l && good;j++)
            if (c1[j]!=c2[(i+j)%l])
                good=false;
        if (good)
        {
            ans+=num[t][i];
            if (ans>inf)
                ans-=inf;
        }
    }
    printf("%d",ans);

    return 0;
}


#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std;

const int base = 13331;

struct Operation {
	int t, v;
	char c;
} op[100000];

int s1[100002], s2[100002], sa[100001], rank[100001], up[100001];
int depth1[100001], depth2[100001], pre[100001][18];
long long hash[100001], pow[18];
pair<int, int> range[100001];

bool cmp(int a, int b) {
	int lg = 0;
	while (1 << lg <= depth2[a] && 1 << lg <= depth2[b]) lg ++;
	for (int i = lg - 1; i >= 0; i --) {
		long long t1 = hash[a] - hash[pre[a][i]] * pow[i];
		long long t2 = hash[b] - hash[pre[b][i]] * pow[i];
		if (t1 == t2) {
			a = pre[a][i];
			b = pre[b][i];
		}
	}
	return up[a] < up[b];
}

int goUp(int x, int step) {
	for (int i = 0; 1 << i <= step; i ++)
		if (step & 1 << i) x = pre[x][i];
	return x;
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i ++) {
		int x, y;
		char tmp[11];
		scanf("%d%d%s", &x, &y, tmp);
		op[i].t = x;
		op[i].v = y - 1;
		op[i].c = tmp[0];
	}

	hash[0] = 0;
	up[0] = 0;
	depth1[0] = 0;
	memset(pre, -1, sizeof(pre));
	int tot = 1;
	for (int i = 0; i < n; i ++)
		if (op[i].t == 2) {
			depth2[tot] = depth2[op[i].v] + 1;
			hash[tot] = hash[op[i].v] * base + op[i].c;
			up[tot] = op[i].c;
			pre[tot][0] = op[i].v;
			for (int j = 1; 1 << j <= depth2[tot]; j ++)
				pre[tot][j] = pre[pre[tot][j - 1]][j - 1];
			tot ++;
		}

	pow[0] = base;
	for (int i = 1; 1 << i <= tot; i ++) pow[i] = pow[i - 1] * pow[i - 1];
	for (int i = 0; i < tot; i ++) sa[i] = i;
	stable_sort(sa, sa + tot, cmp);
	for (int i = 0; i < tot; i ++) rank[sa[i]] = i;

	memset(s1, 0, sizeof(s1));
	memset(s2, 0, sizeof(s2));
	long long ans = 0;
	int cur1 = 1, cur2 = 1;
	range[0] = make_pair(0, tot);
	depth1[0] = 0;
	for (int i = 0; i < n; i ++) {
		if (op[i].t == 1) {
			depth1[cur1] = depth1[op[i].v] + 1;
			if (range[op[i].v].first != -1) {
				int head, tail;
				head = range[op[i].v].first;
				tail = range[op[i].v].second - 1;
				while (head <= tail) {
					int mid = (head + tail) / 2;
					if (up[goUp(sa[mid], depth1[op[i].v])] < op[i].c) {
						head = mid + 1;
					} else {
						tail = mid - 1;
					}
				}
				int l = head;
				head = range[op[i].v].first;
				tail = range[op[i].v].second - 1;
				while (head <= tail) {
					int mid = (head + tail) / 2;
					if (up[goUp(sa[mid], depth1[op[i].v])] > op[i].c) {
						tail = mid - 1;
					} else {
						head = mid + 1;
					}
				}
				int r = tail + 1;
				if (l >= r) {
					range[cur1] = make_pair(-1, -1);
				} else {
					range[cur1] = make_pair(l, r);
					for (int j = r; j > 0; j -= j & -j) ans += s1[j];
					for (int j = l; j > 0; j -= j & -j) ans -= s1[j];
					for (int j = l + 1; j <= tot; j += j & -j) s2[j] ++;
					if (r < tot) {
						for (int j = r + 1; j <= tot; j += j & -j) s2[j] --;
					}
				}
			} else {
				range[cur1] = make_pair(-1, -1);
			}
			cur1 ++;
		} else {
			int t = rank[cur2];
			for (int j = t + 1; j <= tot; j += j & -j) s1[j] ++;
			for (int j = t + 1; j > 0; j -= j & -j) ans += s2[j];
			cur2 ++;
		}
		printf("%I64d\n", ans + cur2);
	}

	return 0;
}


#include<iostream>
#include <cstdio>
using namespace std;
const long long mod=1000000007;
long long x,k,t;
long long pow(long long a,long long b){
	long long ans=1;
    a%=mod;
	while(b){
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b=b>>1;
	}
	return ans;
}
int main(){
	scanf("%lld",&t);
	while(t--){
		scanf("%lld%lld",&x,&k);
		printf("%lld\n",pow(x,k));
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<set>
#define ll long long
using namespace std;
ll n, m, x, y, sum = 1;
ll dx = 1, dy = 1;
char a, b;
ll sum1 = 0;
set <pair <ll, ll> > s;
void operation()
{
	ll k = 0;
	while (1){
		s.insert(pair <ll, ll> (x, y));
		k ++;
	//	cout << x << " " << y << endl;
		if (s.size() == n+m-2){
			printf("%I64d", sum);
			exit(0);
		}
		ll stepa, stepb;
		if (dx == -1)
		{
			stepa = x - 1;
		}else stepa = n - x;
		if (dy == -1)
		{
			stepb = y - 1;
		}else stepb = m - y;
		ll temp = sum;
		sum += min (stepa, stepb);
		if (temp == sum){
			sum1 ++;
			if (sum1 > (ll) 1e6){
				printf("-1");
				exit(0);
			}
		}else sum1 = 0;
		if (k > (ll) 1e6) {
			printf("-1");
			exit(0);
		}
		x += dx * (sum - temp);
		y += dy * (sum - temp);
		if (x * -dx == 1 || x * dx == n){
			dx = -1 * dx;
		}
		if (y * -dy == 1 || y * dy == m){
			dy = -1 * dy;
		}
	}
}
int main()
{
	scanf("%lld%lld%lld%lld", &n, &m, &x, &y);
	cin >> a >> b;
	if (a == 'U') dx = -1;
	if (b == 'L') dy = -1;
	operation();
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=1e5+10;

ll a,b;
ll ans;
vector<ll>prime;

int main(){

	scanf("%lld %lld",&a,&b);
	ll tmp = a;
	for(ll i = 2;i * i <= tmp;i++)
	{
		if(tmp % i  == 0)
		{
			prime.push_back(i);
			while(tmp % i == 0)
			tmp /= i;
		}
	}
	if(tmp > 1)
	prime.push_back(tmp);
	ans = 0;
	int len = prime.size();
	while(b)
	{
		ll g = __gcd(a,b);
		a /= g;
		b /= g;
		ll res = b;
		for(ll i = 0;i < len;i++)
		{
			ll x = prime[i];
			if(a % x == 0)
			res = min (res,b % x);
		}
		ans += res;
		b -= res;
	}
	printf("%lld\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;

	int res = 0;
	string ans;
	for (int i = 0; i < n - 1; ++i)
	{
		int cur = 0;
		for (int j = 0; j < n - 1; ++j)
			if (s[j] == s[i] && s[j + 1] == s[i + 1])
				++cur;
		if (res < cur)
		{
			res = cur;
			ans = string(1, s[i]) + string(1, s[i + 1]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	long long p;
	int k;
	scanf("%I64d %d",&p,&k);
	vector<long long> ans;
	while(p)
	{
		long long tmp=p%k;
		while(tmp<0)
			tmp+=k;
		ans.push_back(tmp);
		p-=tmp;
		p/=k;
		p=-p;
	}
	printf("%lu\n",ans.size());
	for(int i=0;i<ans.size();i++)
		printf("%I64d ",ans[i]);
	puts("");
	return 0;
}


//In the name of God
#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main ()
{

  int n,m,k;
  cin >> n >> m >> k;
  int a[n];
  for (int x = 0 ; x < n ;x++)
      cin >> a[x];
 if ( m <= k)
     {
         cout << 0;
         return 0;
     }

sort(&a[0],&a[n]);

int lamp = k;
int ans = 1;
int rah_1 = 0;
for ( ; ans <= n; ans++ )
{

       if (a[n-ans] != 1)
        lamp += a[n-ans]-1;
       else
           rah_1++;

    if (lamp >= m)
    {
        cout << ans - rah_1;
        return 0;
    }
 //   cout << lamp<<endl;

}

cout << -1;

    return 0;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = (int)3e8 + 50;

bitset<M> p;

void sieve() {
    p.set();
    p[1] = false;
    for(int i = 2; i * i < M; i++) {
        if(!p[i]) continue;
        for(int j = 2 * i; j < M; j += i) {
            p[j] = false;
        }
    }
}

int main(){
    sieve();

    int l, r;
    cin >> l >> r;
    int cnt = 0;
    for(int i = (l + 2) / 4 * 4 + 1; i <= r; i += 4) {
        if(p[i]) cnt++;
    }
    if(l <= 2 && 2 <= r) cnt++;
    cout << cnt << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#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 3.14159265358979
#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;
ll mod = 1e9 + 7;
ll dp[505][505];
ll p2[250005];
int main(){
	p2[0] = 1; for (ll i = 1; i < 250005; i++) p2[i] = (p2[i - 1] * 2) % mod;
	ll n, s; cin >> n >> s;
	for (ll i = 0; i <= n; i++) dp[i][0] = 1;
	for (ll i = 1; i <= n; i++){
		for (ll j = 1; j <= min(i, s); j++){
			for (ll k = j - 1; k <= i; k++){
				(dp[i][j] += (dp[k][j - 1] * (p2[i - k] - 1) % mod * p2[k * (i - k)])) %= mod;
			}
		}
	}
	cout << dp[n][s] << endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,sq,k;
	cin>>n;
	sq=int(sqrt(n));
	k=n-sq*sq;
	if(sqrt(n)==sq){
		cout<<sq*4;
		return 0;
	}
	else {
		if(sq<k)cout<<sq*4+4;
		else cout<<sq*4+2;
	}
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <ctime>

using namespace std;

#define vi vector<int>
#define vvi vector< vi >
const int mod = 1000*1000*1000+7;

vvi mul(vvi &a, vvi &b) {
	int n = a.size();
	vvi ret(n, vi(n, 0));
	for(int k=0;k<n;++k)
	for(int i=0;i<n;++i)
	for(int j=0;j<n;++j)
		ret[i][j] = (ret[i][j] + (long long)a[i][k] * b[k][j]) % mod;
	return ret;
}

vvi pw(vvi a, vvi mat, int x) {
	int n = a.size();
	vvi ret(n, vi(n, 0));
	for(int i=0;i<n;++i) ret[i][i] = 1;
	while(x) {
		if(x & 1) ret = mul(ret, mat);
		mat = mul(mat, mat), x >>= 1;
	} return mul(a, ret);
}

int w[10];
int adj[10][1<<7][1<<7];

int main() {
#ifdef LOCAL
	freopen("input.txt","r",stdin);
#endif
	for(int i=1;i<=7;++i) scanf("%d",w+i);
	int last = 0;
	for(int i=1;i<=7;++i) if(w[i]) last = i;
	for(int len=1;len<=7;++len) {
		for(int i=0;i<(1<<len);++i) for(int j=0;j<(1<<len);++j) {
			int c0 = 0, c1 = 1;
			for(int k=0;k<len;++k) {
				int nc0 = c0 + c1;
				int nc1 = c0;
				if(!(i>>k & 1) || !(j>>k & 1)) nc1 += c1;
				c0 = nc0, c1 = nc1;
			} adj[len][i][j] = c1;
		}
	}

	int prv[1<<7] = {0};
	int nxt[1<<7];

	prv[0] = 1;
	for(int len=1;len<=7;++len) {
		memset(nxt,0,sizeof(nxt));

		vvi a(1<<len, vi(1<<len, 0));
		vvi mat(1<<len, vi(1<<len, 0));
		for(int i=0;i<(1<<(len-1));++i) {
			a[i + (1<<(len-1))][i + (1<<(len-1))] = prv[i];
		}
		for(int i=0;i<(1<<len);++i) for(int j=0;j<(1<<len);++j)
			mat[i][j] = adj[len][i][j];

		if(len == last) {
			w[len]--;
			vvi ret = pw(a, mat, w[len]);
			for(int i=0;i<(1<<len);++i) for(int j=0;j<(1<<len);++j)
				nxt[i] = (nxt[i] + ret[j][i]) % mod;

			int ans = 0;
			for(int i=0;i<(1<<len);++i)
				ans = (ans + (long long)adj[len][i][(1<<len)-1] * nxt[i]) % mod;
			printf("%d\n",ans);
		}
		else {
			vvi ret = pw(a, mat, w[len]);
			for(int i=0;i<(1<<len);++i) for(int j=0;j<(1<<len);++j)
				nxt[i] = (nxt[i] + ret[j][i]) % mod;
			memcpy(prv,nxt,sizeof(prv));
		}

	}
}


#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

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

string s1, s2;

typedef tuple<ll, ll, ll> T;

#define NN 201
bool visited[NN][NN][NN+20];
char moves[NN][NN][NN+20];
T par[NN][NN][NN+20];

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

	cin>>s1>>s2;

	queue<T> fringe;
	memset(moves, -1, sizeof moves);
	fringe.push({0, 0, 0});
	visited[0][0][0] = true;
	while (1) {
		T u = fringe.front();
		ll i, j, b;
		tie(i, j, b) = u;
		fringe.pop();
		//cout<<i<<" "<<j<<" "<<b<<endl;
		if (u==T{s1.size(), s2.size(), 0}) {
			string ans="";
			while (moves[get<0>(u)][get<1>(u)][get<2>(u)]!=-1) {
				ans+=moves[get<0>(u)][get<1>(u)][get<2>(u)];
				u = par[get<0>(u)][get<1>(u)][get<2>(u)];

			}
			reverse(ans.begin(), ans.end());
			cout<<ans<<endl;
			return 0;
		}
		for (auto c:"()") {
			T v = {((i<s1.size() && s1[i]==c)?i+1:i), ((j<s2.size()&&s2[j]==c)?j+1:j), (c=='('?b+1:b-1)};
			if (get<2>(v)<0 || get<2>(v)>210) continue;
			if (visited[get<0>(v)][get<1>(v)][get<2>(v)]) continue;
			fringe.push(v);
			visited[get<0>(v)][get<1>(v)][get<2>(v)] = 1;
			moves[get<0>(v)][get<1>(v)][get<2>(v)] = c;
			par[get<0>(v)][get<1>(v)][get<2>(v)] = u;
		}
	}
}


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

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

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

 freeopen

 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout);
 */

typedef pair<ll,ll> ii;
const int mx = 200100;
const int md = 1000000007;

bool compare(const pair<int,int>& a,const pair <int,int>& b) {
    return a.first < b.first || (a.first == b.first && a.second > b.second);
}

string s;
int n;

int cari(int a,int b) {
    //cout << a << " " << b << " = ";
    int ans = INT_MAX;
    pair <int,int> temp = mp(-1,-1);
    repi(0,s.size(),1) {
        if(a != b) {
            if(s[i]-'0' == a) temp.fi = i;
            if(s[i]-'0' == b) temp.se = i;
        }
        else {
            if(s[i]-'0' == a) {
                temp.fi = temp.se;
                temp.se = i;
            }
        }
    }

    if(temp.fi != -1 and temp.se != -1) {
        if(temp.fi < temp.se) ans = min(ans,(n-2)-temp.fi+(n-1)-temp.se);
        else if(temp.fi == n-1) ans = min(ans,(n-temp.se)-1);
        else {
            //cout << temp.fi << " vs " << temp.se << endl;
            ans = min(ans,(n-2)-temp.fi+(n-1)-temp.se+1);
        }
    }
    if(n == 2) return ans;
    int z = -1,g=0;
    repi(0,n,1) {
        if(i != temp.fi and i != temp.se) {
            if(s[i] != '0') {
                g += i;
                z = i;
                break;
            }
        }
        else {
            g--;
        }
    }
    //cout << z << endl;
    if(z == -1) ans = INT_MAX;
    if(ans == INT_MAX) return ans;
    return ans+g;
}

int main() {
    cin >> s;
    n = s.size();
    if(n == 1) printf("%d\n",(s == "0" ? 0 : -1));
    else {
        int ans = INT_MAX;
        ans = min(ans,cari(0,0));
        ans = min(ans,cari(2,5));
        ans = min(ans,cari(5,0));
        ans = min(ans,cari(7,5));
        if(ans == INT_MAX) printf("-1\n");
        else printf("%d\n",ans);
    }
}


#include <iostream>
const int mod = 1000000007;
using namespace std;

int mi[1000001],rev[1000001],cp[1000001];

int quick(int a,int b)
{
   if (!b)
      return 1;
   int t=quick(a,b>>1);
   t=1LL*t*t%mod;
   if (b&1)
      t=1LL*t*a%mod;
   return t;
}

inline int P(int n,int m)
{
   if (m>n)
      return 0;
   return 1LL*mi[n]*rev[n-m]%mod;
}

inline int C(int n,int m)
{
   if (m>n)
      return 0;
   return 1LL*mi[n]*rev[n-m]%mod*rev[m]%mod;
}

int main()
{
   int k,w,s=0;
   cin>>k>>w;
   mi[0]=rev[0]=1;
   for (int i=1;i<=k;i++)
   {
      mi[i]=1LL*mi[i-1]*i%mod;
      rev[i]=1LL*rev[i-1]*quick(i,mod-2)%mod;
   }
   cp[0]=1;
   for (int i=1;i<=k;i++)
      cp[i]=(1LL*cp[i-1]*i+1)%mod;
   for (int i=1;i<=min(k,w-2);i++)
   {
      int t=quick(k,w-i-2);
      s=(s+2LL*P(k,i)*P(k,i)%mod*t%mod*k%mod*i-1LL*P(k,i)*P(k,i)%mod*t%mod*i%mod*i%mod+mod)%mod;
   }
   if (k>=w-1)
      s=(s+2LL*P(k,w-1)*P(k,w-1)%mod*(w-1)-1LL*P(k-1,w-2)*P(k-1,w-2)%mod*(w-1)%mod*(w-1)%mod*k%mod+mod)%mod;
   for (int i=0;i<=k-w;i++)
      s=(s+2LL*P(k,w+i)*w%mod*P(k-i-1,w-1))%mod;
   for (int i=0;i<=min(k,w-1);i++)
   {
      long long t=0;
      if (k-2*(w-1)+i>=0)
         t+=1LL*(w-1-i)*(w-1-i)%mod*cp[k-2*(w-1)+i];
      if (k-2*(w-1)+i-1>=0)
         t+=1LL*(k-2*(w-1)+i)*cp[k-2*(w-1)+i-1];
      if (t)
         s=(s-t%mod*C(w-1,i)%mod*C(w-1,i)%mod*P(k,i)%mod*mi[i]%mod*P(k-i,w-1-i)%mod*P(k-w+1,w-1-i)%mod+mod)%mod;
   }
   cout<<s<<endl;
   return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define fr first
#define sc second

long long n,fq[10];
vector<pair<long long,long long>> ky[10];

int main()
{
	long long i,j,k,l,w,sz;
	string s;

	ky[2].push_back({2,1});
	ky[3].push_back({3,1});
	ky[4].push_back({2,2});
	ky[4].push_back({3,1});
	ky[5].push_back({5,1});
	ky[6].push_back({3,1});
	ky[6].push_back({5,1});
	ky[7].push_back({7,1});
	ky[8].push_back({2,3});
	ky[8].push_back({7,1});
	ky[9].push_back({2,1});
	ky[9].push_back({3,2});
	ky[9].push_back({7,1});
	scanf("%lld",&n);
	cin>>s;
	for(i=1;i<=n;i++)
	{
		fq[s[i-1]-'0']++;
	}
	for(i=9;i>1;i--)
	{
		k=fq[i];
		fq[i]=0;
		sz=ky[i].size();
		for(j=0;j<sz;j++)
		{
			l=ky[i][j].fr;
			w=ky[i][j].sc;
			fq[l]+=k*w;
		}
	}
	for(i=9;i>1;i--)
	{
		for(j=0;j<fq[i];j++)
		{
			printf("%lld",i);
		}
	}
	printf("\n");
}


#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char s[n];
    cin>>s;

    /*int len=n-4;
    len=n-len;
    len--;*/

    int len=n-3;

    vector<int>v;

    char a[]="ACTG";

    for(int i=0;i<len;i++)
    {
        long long sum=0;
        for(int j=i,y=0;y<=3;j++,y++)
        {
            /*if(s[j]=='Z')
            {
                if(a[y]=='T') sum+=6;
                else if(a[y]=='A') sum+=1;
                else if(a[y]=='C') sum+=3;
                else sum+=7;
            }
            else if(s[j]>a[y])
            {
                int u=s[j];
                int b=a[y];
                int ans=u-b;
                sum+=ans;
            }
            else
            {
                int u=s[j];
                int b=a[y];
                int ans=b-u;
                sum+=ans;
            }*/

            int u=s[j]-64;
            int b=a[y]-64;
            int mx=max(u,b);
            int mn=min(u,b);

            int ans=mx-mn;
            if(ans<=13)
            {
                sum+=ans;
            }
            else
            {
                if(ans==14) sum+=12;
                else if(ans==15) sum+=11;
                else if(ans==16) sum+=10;
                else if(ans==17) sum+=9;
                else if(ans==18) sum+=8;
                else if(ans==19) sum+=7;
                else if(ans==20) sum+=6;
                else if(ans==21) sum+=5;
                else if(ans==22) sum+=4;
                else if(ans==23) sum+=3;
                else if(ans==24) sum+=2;
                else if(ans==25) sum+=1;
            }
        }
        v.push_back(sum);
    }

    sort(v.begin(),v.end());
    int royal=v[0];
    cout<<royal<<endl;
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
int B[3];
int getd(int m,int y)
{
	if (m==1||m==3||m==5||m==7||m==8||m==10||m==12)
		return 31;
	if (m==4||m==6||m==9||m==11)
		return 30;
	if (y%4==0)
		return 29;
	return 28;
}
int BD,BM,BY;
int tb[3];
bool used[3];
bool hefa()
{
	if (tb[1]<=12&&tb[1]>=1)
	{
		if (tb[2]>0&&tb[2]<=getd(tb[1],tb[0]))
		{
			return true;
		}
	}
	return false;
}
bool low()
{
	int x=tb[0]*10000+tb[1]*100+tb[2];
	int y=BY*10000+BM*100+BD;
	if (x<y)
	{
		return true;
	}
	return false;
}
void copyb()
{
	BY=tb[0];
	BM=tb[1];
	BD=tb[2];
}
void getB(int t)
{
	if (t==3)
	{
		if (hefa()&&low())
		{
			copyb();
		}
	}
	for(int i=0;i<3;i++)
	{
		if (used[i])
			continue;
		used[i] = true;
		tb[t]=B[i];
		getB(t+1);
		used[i] =false;
	}
}
int main()
{
	int DD,MM,YY;

	char x;
	cin>>DD>>x>>MM>>x>>YY;
	cin>>B[0]>>x>>B[1]>>x>>B[2];
	BD=B[0];
	BM=B[1];
	BY=B[2];
	getB(0);
	if (YY-BY<18)
	{
		cout<<"NO"<<endl;
	}
	else if(YY-BY>18)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		int t = MM*100+DD;
		int tt = BM*100+BD;
		if (t>=tt)
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

	}
	return 0;
}