#include <bits/stdc++.h>
#include <unordered_map>
// luv or wat
using namespace std;
#define int long long
#define PII pair <int, int>
vector <int> love; vector <int> primes, divisors;
unordered_map <int, vector <int> > dividesx;
int isnotprime [1000005];
int dp [7050][7050];
map <int, int> findpos;
bool checkprime (int a)
{
    for (int g=0; g<primes.size(); g++)
    {
        if (a%primes[g]==0) return false;
    }return true;
}
main()
{
    for (int g=2; g<=1000000; g++)
    {
        if (isnotprime[g]) continue;
        for (int y=2*g; y<=1000000; y+=g)
        {
            isnotprime[y]=1;
        }
    }
    for (int g=2; g<=1000000; g++)
    {
        if (isnotprime[g]) continue;
        primes.push_back(g);
    }
    int a; cin >> a;
    if (a==1){cout << 0; return 0;
    }

    for (int g=1; g*g<=a; g++)
    {
        if (g*g==a)
        {
            divisors.push_back(g); continue;
        }
        if (a%g==0)
        {
            divisors.push_back(g);
            divisors.push_back(a/g);
        }
    }
    sort(divisors.begin(), divisors.end());
    for (int g=0; g<divisors.size(); g++) findpos[divisors[g]]=g;
    for (int g=0; g<primes.size(); g++)
    {
        int x=primes[g];
        int flag=0;
        while (x+1<=a)
        {
            if (a%(x+1)==0)
            {
                dividesx[primes[g]].push_back(x+1); flag=1;
            }
            x*=primes[g];
        }
        if (flag) love.push_back(primes[g]);
    }
    for (int g=0; g+1<divisors.size(); g++)
    {
        int x=(a/divisors[g])-1;
        if (x<=1000000) continue;
        if (checkprime(x)){
            love.push_back(x);
            dividesx[x].push_back(x+1);
        }
    }sort(love.begin(), love.end());
    for (int g=0; g<=love.size();g++)
    dp[0][g]=1;
    for (int g=1; g<divisors.size(); g++)
    {
        for (int t=love.size()-1; t>=0; t--)
        {if (love[t]>divisors[g])continue;
            for (int z=0; z<dividesx[love[t]].size(); z++)
            {
                if (divisors[g]%dividesx[love[t]][z]) continue;
                int ll=divisors[g]/dividesx[love[t]][z];
                dp[g][t]+=dp[findpos[ll]][t+1];
            }
            dp[g][t]+=dp[g][t+1];
        }
    }
    cout << dp[divisors.size()-1][0];
    return 0;
}


#include<cstdio>
#define mod 1000000007
typedef long long ll;
int n;
ll s,f[25],fac[1000005],inv[1000005],ans;
void init()
{
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=1000000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=1000000;i++) fac[i]=fac[i-1]*i%mod,inv[i]=inv[i-1]*inv[i]%mod;
}
ll combine(ll x,ll y)
{
	if(x<=1000000&&y<=1000000) return fac[x]*inv[y]%mod*inv[x-y]%mod;
	return combine(x/mod,y/mod)*combine(x%mod,y%mod)%mod;
}
void dfs(int now,int cnt,ll sum)
{
	if(now>n)
	{
		if(s<sum) return ;
		if(cnt&1) ans=(ans-combine(n+s-sum-1,n-1)+mod)%mod;
		else ans=(ans+combine(n+s-sum-1,n-1))%mod;
		return ;
	}
	dfs(now+1,cnt,sum);
	dfs(now+1,cnt+1,sum+f[now]+1);
}
int main()
{
	init();
	scanf("%d%lld",&n,&s);
	for(int i=1;i<=n;i++) scanf("%lld",&f[i]);
	dfs(1,0,0);
	printf("%lld\n",ans);
	return 0;
}


#include<iostream>
using namespace std;
int main(){
    int m,a;
    cin>>a>>m;
    int x=a,ans=0;
    while(true){
        a+=a;
        a%=m;
        if(a==0){
            ans=0;
            break;
        }
        if(a==x){
            ans=1;
            break;
        }
    }
    if(ans==1)  cout<<"No";
    if(ans==0)  cout<<"Yes";
}


#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int chrcmp(char ch){
	// A, E, I, O, U, Y
	if (ch=='a' || ch=='A' || ch=='e' || ch=='E' ||
	    ch=='i' || ch=='I' || ch=='o' || ch=='O' ||
		ch=='u' || ch=='U' || ch=='y' || ch=='Y' )return 0; else return 1;
	}
main(){char c,str[110],str1[100]="",max;
       while((c=getch())!='?')if(c<='z' && c>='A')max=c;
	    if(chrcmp(max))printf("NO");else printf("YES");
	    //getch();
		return 0;
	   }


#include<bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define nd second
#define st first

typedef long long ll;
typedef long long int lli;
typedef long long unsigned llu;
typedef pair < int,int > pii;
typedef pair < lli,lli > plli;

const int MAX = 1e6+7;

string s;

int main()
{
	cin>>s;
	int k ;
	if(s[s.length()-1]=='h')
	{
		if(s[1]<='9' && s[0]>='0')
			k = (s[0]-'0')*10 + s[1]-'0';
		else
			k= s[0]-'0';

		if(k==31)
			printf("7");
		else if(k==30)
			printf("11");
		else
			printf("12");
	}
	else if(s[s.length()-1]=='k')
	{
		k=s[0]-'0';
			puts((k==5 || k==6)?"53":"52");
	}
	else while(1);
}


#include <iostream>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <cassert>
#include <functional>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <random>
#include <deque>
#include <bitset>

using namespace std;

void answer(int x)
{
    cout << x << endl;
}
const int N = 505;
long long cnt[9];

long long W;
const long long we = 500;
const long long co = 50;
const long long predm = 10000;
const long long maxw = 10000;
 long long dp[predm][maxw];
int main() {
    cin >> W;
    for(int i = 1; i <= 8; i++)
        cin >> cnt[i];
    long long ans = 0;
    for(int i = 1; i <= 8; i++)
    {
        if(W > we && cnt[i] > co)
        {
            long long delta = W - we;
            long long amo = min(delta / i, cnt[i] - co);
            W -= amo*i;
            ans += amo*i;
            cnt[i] -= amo;
        }
    }
    W = min(W, 1LL*1000);
    for(int i = 1; i <= 8; i++)
    {
        cnt[i] = min(cnt[i], (W+i)/i);
    }

    vector <int> v = {};
    long long ww = 0;
    for(int i = 1; i <= 8; i++)
    {
        for(int j = 0; j < cnt[i]; j++){
            v.push_back(i);
            ww += i;
        }
    }

    dp[0][0] = 1;
    ww = min(ww, W);
    /*if (ww >= maxw)
        cout << "ddddd" << endl;
    if(v.size() > predm )
        cout << "hhhh" << endl;*/
    for(int i = 1; i <= v.size(); i++)
    {
        for(int j = 0; j <= ww; j++)
        {
            if(dp[i-1][j] == 1){
                dp[i][j + v[i-1]] = 1;
                dp[i][j] = 1;
            }
        }
    }

    long long f = 0;
    for(int j = 0; j <= ww ; j++ )
        if(dp[v.size()][j] ==1)
            f = j;
    ans += f;
    cout << ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define freopen freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define MOD 998244353
#define IOS ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
ll mx=-1e9,mn=1e9+5;
ll T,n,m,k,ans,a[10],b,c,d,l,r,sum,mid,coin,z,cnt,pos,number,cnt1,x,y,utga,xx,yy;
vector<ll> v,v1;
map<ll,ll> mp,mm;
map<ll,ll> :: iterator it;
pair<ll,ll> p[100005];
queue<ll> q;
priority_queue<ll> pq;
ll dp[35000][1000];
char ch[105][105];
bool prime[1000005];
int main(){
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>a[i];
    }
    if(n==1){
        cout<<"YES"<<endl;
        for(int i=2; i<=n; i++) cout<<a[i]<<" ";
        return 0;
    }
    if(n==2){
        for(int i=1; i<=5000; i++){
            for(int j=i; j<=5000; j++){
                v.clear();
                v.pb(i);
                v.pb(j);
                v.pb(a[1]);
                v.pb(a[2]);
                sort(v.begin(), v.end());
                if((v[1]+v[2])%2==1 || (v[0]+v[1]+v[2]+v[3])%4!=0) continue;
                x=(v[1]+v[2])/2;
                y=(v[1]+v[2]+v[3]+v[0])/4;
                z=v[3]-v[0];
                if(x==y && x==z && y==z){
                    cout<<"YES"<<endl;
                    cout<<i<<" "<<j;
                    return 0;
                }
            }
        }
        cout<<"NO"<<endl;
        return 0;
    }
    if(n==3){
        for(int i=1; i<=1e5; i++){
            v.clear();
            v.pb(a[1]);
            v.pb(a[2]);
            v.pb(a[3]);
            v.pb(i);
            sort(v.begin(),v.end());
            if((v[1]+v[2])%2==1 || (v[0]+v[1]+v[2]+v[3])%4!=0) continue;
            x=(v[1]+v[2])/2;
            y=(v[1]+v[2]+v[3]+v[0])/4;
            z=v[3]-v[0];
            if(x==y && x==z && y==z){
                cout<<"YES"<<endl;
                cout<<i;
                return 0;
            }
        }
        cout<<"NO";
        return 0;
    }
    v.pb(a[1]);
    v.pb(a[2]);
    v.pb(a[3]);
    v.pb(a[4]);
    sort(v.begin(),v.end());
    if((v[1]+v[2])%2==0 || (v[0]+v[1]+v[2]+v[3])%4==0){
        x=(v[1]+v[2])/2;
        y=(v[1]+v[2]+v[3]+v[0])/4;
        z=v[3]-v[0];
        if(x==y && x==z && y==z){
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
}


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

#define lli long long int

int main()
{
    lli n;

    scanf("%lld",&n);

    lli ans,fun=0,first=0;

    lli cut=1,a;
    lli test=n;

    vector<lli> v;

    while(test)
    {
        v.push_back(test%10);

        test = test/10;
    }

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

    for(int i=0;i<v.size();i++)
    {
        if(v[i]==0)
        {
            first = i;
            break;
        }
    }

    if(first!=0)
    {
        if(v[first-1]!=1)
        {
            cut *= (v[first-1]-1);
        }

        for(int i=0;i<first-1;i++)
            cut *= v[i];

        cut *= pow(9,(v.size()-first));
    }
    else if(first==0)
    {
        cut *= pow(9,v.size()-1);

        if(v[0]!=1 && v.size()!=1)
            cut *= v[0]-1;
    }

    //printf("%lld\n",cut);

    for(lli i=n;i>=1;i--)
    {
        lli m=i;

        ans=1;

        while(m)
        {
            ans *= (m%10);
            m = m/10;
        }

        fun = max(fun,ans);

        /*
        if(ans>=fun)
        {
            fun = ans;
            ans1 = i;
        }
        */

        if(fun>=cut)
        {
            //printf("%lld\n",i);
            break;
        }
    }

    printf("%lld",fun);
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef vector <string> vs;
typedef vector <int> vi;
#define clr(x) memset((x), 0, sizeof(x))
#define SORT(x) sort(x.begin(),x.end())
#define forn(i, n) for(int i = 0; i< n; i++)
#define forns(i, start, end) for(int i = start; i<= end; i++)
#define all(i, x) for(int i = 0; i< x.size(); i++)
#define ll long long
const long double EPS = 1e-11;

int n,k,ans = 100000000;
string ss[8];
int main()
{
//	freopen("test.txt","r",stdin);
//  freopen("test.txt","w",stdout);
	cin>>n>>k;
	forn(i,n)
	{
		cin>>ss[i];
	}
	for(int i1 = 0; i1 < k; i1 ++)
	for(int i2 = 0; i2 < k; i2 ++)
	for(int i3 = 0; i3 < k; i3 ++)
	for(int i4 = 0; i4 < k; i4 ++)
	for(int i5 = 0; i5 < k; i5 ++)
	for(int i6 = 0; i6 < k; i6 ++)
	for(int i7 = 0; i7 < k; i7 ++)
	for(int i8 = 0; i8 < k; i8 ++)
	{
		unsigned char f = 0;
		string str[8];
		f = 0xf0;
		switch(k)
		{
		case 1:
			f = 1;
		case 2:
			f = 0xfc | 1<<i1 | 1<<i2;
			break;
		case 3:
			f = 0xf8 | 1<<i1 | 1<<i2 | 1<<i3;
			break;
		case 4:
			f = f | (1<<i1) | (1<<i2) | (1<<i3) | (1<<i4);
			break;
		case 5:
			f = 0xe0 | 1<<i1 | 1<<i2 | 1<<i3 | 1<<i4 | 1<<i5;
			break;
		case 6:
			f = 0xc0 | 1<<i1 | 1<<i2 | 1<<i3 | 1<<i4 | 1<<i5 | 1<<i6;
			break;
		case 7:
			f = 0x80 | 1<<i1 | 1<<i2 | 1<<i3 | 1<<i4 | 1<<i5 | 1<<i6 | 1<<i7;
			break;
		case 8:
			f = 1<<i1 | 1<<i2 | 1<<i3 | 1<<i4 | 1<<i5 | 1<<i6 | 1<<i7 | 1<<i8;
			break;
		default:
			break;
		}
		if(f == 0xff)
		{
			int x,minN = 100000000,maxN = 0;
			forn(i,n)
			{
				str[i].push_back(ss[i].at(i1));
				if(k > 1)
				str[i].push_back(ss[i].at(i2));
				if(k > 2)
				str[i].push_back(ss[i].at(i3));
				if(k > 3)
				str[i].push_back(ss[i].at(i4));
				if(k > 4)
				str[i].push_back(ss[i].at(i5));
				if(k > 5)
				str[i].push_back(ss[i].at(i6));
				if(k > 6)
				str[i].push_back(ss[i].at(i7));
				if(k > 7)
				str[i].push_back(ss[i].at(i8));
				sscanf(str[i].c_str(),"%d",&x);
				if(x < minN)
					minN = x;
				if(x > maxN)
					maxN = x;
			}
			if(maxN - minN < ans)
				ans = maxN - minN;
		}
	}
	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],c=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    //int k=strlen(a);
    for(int i=0; i<n-1; i++)
    {
        if(a[i]!=0)
        {
            if(a[i]!=a[i+1])
              c++;
            if(i==n-2){
            if((a[n-1]==a[n-2])||(a[n-1]!=a[n-2]))
                c++;
            }
        }

    }
    printf("%d\n",c);

}


#include<iostream>
using namespace std;

int main()
{
	int n, B;
	cin >> n >> B;
	int *seq = new int[5];
	for (int i = 0; i < n; i++)
		cin >> seq[i];
	int balance=0, i=0, c=0;

	for (i = 0; i < n-2; i++)
	{
		if (seq[i] % 2 == 0) balance++;
		else balance--;
		if (balance == 0 && (seq[i + 1] - seq[i] <= B)) { c++; B = B - seq[i + 1] - seq[i]; }
	}
	cout << c;
	return 0;
}


#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
#define home freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
using namespace std;

int main()
{
	boost
	#ifndef ONLINE_JUDGE
	home
	#endif

	int n; cin >> n;
	while(n--)
	{
		int x; cin >> x;
		int t = 3;
		int s = 7;
		ll ss1 = t+s;
		ll ss2 = t+s;
		int flag = 0;
		for(int i = 0; i <= x; i ++)
		{
			if(!(x % t) || !(x % s) || !(x % ss1) || !(x % ss2) || !(x % (ss1+s)) || !(x % (ss2+t)) )
			{
				flag++;
				break;
			}
			ss1+=t;
			ss2+=s;
			t+=t;
			s+=s;
		}
		if(flag)cout << "YES\n";
		else cout << "NO\n";
	}

}


#include<bits\stdc++.h>
#define ll long long
#define ld long double
#define qw " "
#define we endl
#define ff first
#define ss second
#define Q 10007
using namespace std;
ll n,m,t,k=1,a[Q][Q],i,j;
main(){
	cin>>n>>m>>t;
	if(t==0)return cout<<1<<qw<<1,0;
	for(i=2;i<=n;i++){
		a[i][1]=k;
		k++;
	}
	for(i=n;i>=1;i--){
		if(n%2==0){
			for(j=2;j<=m;j++){
				a[i][j]=k;
				k++;
				if(k==t)return cout<<i<<qw<<j,0;
			}
		}
		else{
			for(j=m;j>=2;j--){
				a[i][j]=k;
				k++;
				if(k==t)return cout<<i<<qw<<j,0;
			}
		}
	}

}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <cstring>
#include <list>
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXN = 10000;
const int MAXM = 10000;
const int MAXSPECIAL = 10;
const int MAXQ = 200000;
const int MAXW = 25;

const int MAXGN = MAXN;
const int MAXGM = MAXM;

typedef struct MF {
	int n, m;
	int ghead[MAXGN], gnxt[2 * MAXGM], gto[2 * MAXGM]; ll gcap[2 * MAXGM];
	void init(int _n) { n = _n, m = 0; REP(i, n) ghead[i] = -1; }
	void addedge(int a, int b, ll c) { gnxt[2 * m + 0] = ghead[a], ghead[a] = 2 * m + 0, gto[2 * m + 0] = b, gcap[2 * m + 0] = c; gnxt[2 * m + 1] = ghead[b], ghead[b] = 2 * m + 1, gto[2 * m + 1] = a, gcap[2 * m + 1] = 0; ++m; /*printf("%d->%d\n",a,b);*/ }
	int d[MAXGN];
	int q[MAXGN], qhead, qtail;
	int cur[MAXGN];
	ll dinic(int s, int t) {
		ll ret = 0; int niter = 0;
		while (true) {
			REP(i, n) d[i] = INT_MAX; qhead = qtail = 0; d[s] = 0, q[qhead++] = s;
			while (qtail < qhead && d[t] == INT_MAX) { int at = q[qtail++]; for (int x = ghead[at]; x != -1; x = gnxt[x]) { int to = gto[x]; if (gcap[x] == 0 || d[to] != INT_MAX) continue; d[to] = d[at] + 1; q[qhead++] = to; } }
			if (d[t] == INT_MAX) return ret;
			REP(i, n) cur[i] = ghead[i];
			ret += dfs(s, t, LLONG_MAX); ++niter;
		}
	}
	ll dfs(int at, int t, ll rem) {
		ll ret = 0; if (at == t) return rem;
		if (d[at] >= d[t]) return 0;
		for (; cur[at] != -1; cur[at] = gnxt[cur[at]]) {
			int to = gto[cur[at]]; ll cap = gcap[cur[at]]; if (d[to] != d[at] + 1 || cap == 0) continue;
			ll now = dfs(to, t, min(cap, rem));
			rem -= now; ret += now; if (gcap[cur[at]] != LLONG_MAX) gcap[cur[at]] -= now; if (gcap[cur[at] ^ 1] != LLONG_MAX) gcap[cur[at] ^ 1] += now; if (rem == 0) return ret;
		}
		return ret;
	}
	vector<int> findpath(int s, int t) {
		vector<int> ret;
		int at = s;
		while (at != t) {
			bool found = false;
			for (int x = ghead[at]; x != -1; x = gnxt[x]) {
				if (x % 2 != 0 || gcap[x ^ 1] == 0) continue;
				++gcap[x], --gcap[x ^ 1], found = true; at = gto[x]; ret.PB(x); break;
			}
			assert(found);
		}
		return ret;
	}
} MF;

int n, m, nspecial, nq;
MF g;
int qval[MAXQ][MAXSPECIAL], qans[MAXQ];

int s, t;
int flowwith[1 << MAXSPECIAL];
int qsum[1 << MAXSPECIAL];

void rec(int mask, int at, int sofar) {
	if (at == nspecial) { flowwith[mask] = sofar; return; }
	rec(mask, at + 1, sofar);
	assert(g.gcap[2 * at + 0] == 0);
	g.gcap[2 * at + 0] = MAXW;
	int extra = g.dinic(s, t);
	rec(mask | (1 << at), at + 1, sofar + extra);
	REP(i,extra) {
		int a = g.gto[2 * at + 1], b = g.gto[2 * at + 0];
		g.findpath(s, a); g.findpath(b, t); assert(g.gcap[2 * at + 1] > 0); --g.gcap[2 * at + 1]; ++g.gcap[2 * at + 0];
	}
	assert(g.gcap[2 * at + 0] == MAXW);
	g.gcap[2 * at + 0] = 0;
}

void solve() {
	s = 0, t = n - 1;
	int initflow = g.dinic(s, t);
	rec(0, 0, initflow);

	REP(i, nq) {
		qsum[0] = 0; REP(bit, nspecial) REP(mask, 1 << bit) qsum[mask | (1 << bit)] = qsum[mask] + qval[i][bit];
		int cur = INT_MAX;
		REP(mask, 1 << nspecial) cur = min(cur, flowwith[(1 << nspecial) - mask - 1] + qsum[mask]);
		qans[i] = cur;
	}
}

void run() {
	scanf("%d%d%d%d", &n, &m, &nspecial, &nq);
	g.init(n);
	REP(i, m) { int a, b, c; scanf("%d%d%d", &a, &b, &c); --a, --b; g.addedge(a, b, c); }
	REP(i, nq) REP(j, nspecial) scanf("%d", &qval[i][j]);
	solve();
	REP(i, nq) printf("%d\n", qans[i]);
}

int main() {
	run();
	return 0;
}


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

long long int CalcIntegerRoot(long long int n);
long long int CalcVolume(long long int ap, long long int bp, long long int cp);

int main()
{
	using namespace std;

	long long int n;
	cin >> n;

	long long int npmin, npmax;

	//===============================
	//n = 1026;

	long long int min=10000000000;
	long long int vol = 0;
	long long int ost, c, ab;
	long long int maxminap;

	//temp:
	//long long int minCurA, volA, cA, cB, cC;

	const int sizeArrDiv = 100;
	long long int arrDivider[sizeArrDiv];

	//=== calc div ===
	long long int dMax;
	long long int np = 0;
	long long int nc;
	bool isDiv2 = false, isDiv3 = false, isDiv4 = false, isDiv5 = false;

	arrDivider[np++] = 1;
	if(n%2 == 0)
	{
		arrDivider[np++] = 2;
		isDiv2 = true;
	}
	if(n%3 == 0)
	{
		arrDivider[np++] = 3;
		isDiv3 = true;
	}
	if(n%4 == 0)
	{
		arrDivider[np++] = 4;
		isDiv4 = true;
	}
	if(n%5 == 0)
	{
		arrDivider[np++] = 5;
		isDiv5 = true;
	}

	nc = 6;
	dMax = n/5;
	for( ; nc < dMax; nc++)
	{
		if(n%nc == 0)
		{
			arrDivider[np++] = nc;
		}
	}
	if(isDiv5)
	{
		arrDivider[np++] = n/5;
	}
	if(isDiv4)
	{
		arrDivider[np++] = n/4;
	}
	if(isDiv3)
	{
		arrDivider[np++] = n/3;
	}
	if(isDiv2)
	{
		arrDivider[np++] = n/2;
	}
	arrDivider[np++] = n;
	//=================

	for(int a=0; a < np; a++)
	{
		for(int b=0; b < np; b++)
		{
			ab = arrDivider[a]*arrDivider[b];

			if(n%ab == 0)
			{
				c = n/ab;

				vol = CalcVolume(arrDivider[a], arrDivider[b], c) - n;
				if(vol < min)
				{
					min = vol;
				}
			}
		}
	}

	npmin = min;
	npmax = CalcVolume(n, 1, 1) - n;
	cout << npmin << " " << npmax;
	getch();
	return 0;

	//for(int a=1; a <= n; a++)
	//{
	//	//minCurA = 10000000000;

	//	if(n%a)
	//	{
	//		continue;
	//	}

	//	for(int b=1; b <=n; b++)
	//	{
	//		if(n%b)
	//		{
	//			continue;
	//		}
	//
	//		ab = a*b;

	//		if(n%ab)
	//		{
	//			continue;
	//		}

	//		c = n/ab;

	//		//for(int c=1; c <= n; c++)
	//		//{
	//		//	if((a*b*c) == n)
	//		//	{
	//				vol = CalcVolume(a, b, c) - n;
	//				if(vol < min)
	//				{
	//					min = vol;
	//				}

	//				//if(vol < minCurA)
	//				//{
	//				//	minCurA = vol;
	//				//	cA = a;
	//				//	cB = b;
	//				//	cC = c;
	//				//}
	//		//	}
	//		//}

	//	}

	//	int curIjk = 1;
	//}
	//
	//npmin = min;
	//npmax = CalcVolume(n, 1, 1) - n;
	//cout << npmin << " " << npmax;
	////getch();
	return 0;

	//===============================

	//long long int ap, bp, cp;
	//long long int tempmin, tempn;
	//
	//long long int root = CalcIntegerRoot(n);
	//maxminap = root;
	////if(maxminap > 600)
	//if(maxminap > 700)
	//{
	//	maxminap = 700;
	//}
	//npmin = 10000000000;

	////int sizeInc = 1;
	//long long int tempMinA;

	//for(ap = 1; ap <= maxminap; ap++)
	//{
	//	if(n%ap != 0)
	//	{
	//		continue;
	//	}

	//	tempn = n/ap;
	//	root = CalcIntegerRoot(tempn);
	//	//sizeInc = 1;
	//	tempMinA = 10000000000;
	//
	//	if(root*root == tempn)
	//	{
	//		bp = root;
	//		cp = root;
	//	}
	//	else
	//	{
	//		bp = root;

	//		//if(tempn%2 != 0)
	//		//{
	//		//	sizeInc = 2;
	//		//	if(bp%2 == 0)
	//		//	{
	//		//		bp--;
	//		//	}
	//		//}
	//
	//		while(tempn%bp != 0)
	//		{
	//			bp--;
	//			//bp -= sizeInc;
	//		}

	//		if(bp == 1)
	//		{
	//			cp = tempn;
	//		}
	//		else if(bp == 2)
	//		{
	//			cp = tempn/2;
	//		}
	//		else if(bp == 3)
	//		{
	//			cp = tempn/3;
	//		}
	//		else
	//		{
	//			cp = root+1;

	//			/*if(cp%2 == 2)
	//			{
	//				cp++;
	//			}*/

	//			while(tempn%cp != 0 && cp < tempn)
	//			{
	//				cp++;
	//				//cp += sizeInc;
	//			}

	//			if(cp == tempn)
	//			{
	//				bp = 1;
	//			}
	//		}

	//		while(bp*cp != tempn)
	//		{
	//			bp--;

	//			/*if(bp%2 == 0)
	//			{
	//				bp--;
	//			}*/

	//			while(tempn%bp != 0)
	//			{
	//				bp--;
	//				//bp -= sizeInc;
	//			}

	//			//if(bp == 1)
	//			//{
	//			//	cp = tempn;
	//			//	break;
	//			//}
	//			//else if(bp == 2)
	//			//{
	//			//	cp = tempn/2;
	//			//	break;
	//			//}
	//			//else if(bp == 3)
	//			//{
	//			//	cp = tempn/3;
	//			//	break;
	//			//}

	//			//cp++;
	//			//while(tempn%cp != 0 && cp < tempn)
	//			//{
	//			//	cp++;
	//			//}
	//			//if(cp == tempn)
	//			//{
	//			//	bp = 1;
	//			//	break;
	//			//}
	//			cp = tempn/bp;
	//		}
	//	}

	//	tempmin = CalcVolume(ap, bp, cp) - n;
	//	if(tempmin < npmin)
	//	{
	//		npmin = tempmin;
	//	}
	//}

	//npmax = CalcVolume(n, 1, 1) - n;

	//cout << npmin << " " << npmax;

	//getch();
	//return 0;
}

long long int CalcVolume(long long int ap, long long int bp, long long int cp)
{
	return (ap+1)*(bp+2)*(cp+2);
}

long long int CalcIntegerRoot(long long int n)
{
	//long long int root = -1;
	//long long int cs = 1;
	//while(n >= 0)
	//{
	//	root++;
	//	n -= cs;
	//	cs += 2;
	//}

	long double ld = n;
	long double ldr = sqrt(ld);
	long long int root = (long long int)ldr;

	return root;
}


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

int main(){
	int vp,vd,t,f,c; cin>>vp>>vd>>t>>f>>c;
	double x = ((vd*t)/(vd-vp));
	double time= c/vp,time1 =x;
	if(vp>vd){cout<<"0"<<endl;}
	else if(x>=c/vp){cout <<"0"<<endl;}
	time = time-x;
	int n=0;
	while(time>0){
		n++;
		x = (2*vp*time1+vd*f)/(vd-vp);
		time = time -x;
		time1 = time1+x;
	}
	cout<<n<<endl;
}


#include <iostream>

using namespace std;

int main()
{
int l,r,a,k=0;
cin>>l>>r>>a;
if(l==0&&r!=0||r==0&&l!=0)
{
    cout<<"0";
}
else{
k=l+r+a;
while(true){
if(k%2!=0)
    k=k-1;
}
cout<<k;
}
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
	int* A = new int[30];
	for (size_t i = 0; i <= 30; i++)
	{
		A[i] = pow(2, i);
	}
	int x = 0;
	cin >> x;
	for (size_t i = 0; i <= 30; i++)
	{
		if (A[i] == x)
		{
			cout << 1;
			return 0;
		}
		else if(A[i]<x && A[i + 1]>x)
		{
			cout << (x % A[i]) + 1;
		}
	}
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <conio.h>
#include <locale.h>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cmath>
using namespace std;

#define PI 3.14159265

int main() {
	freopen("input.txt","r",stdin);
	long long ax,ay,bx,by,cx,cy;
	cin >> ax >> ay >> bx >> by >> cx >> cy;
	long long s1,s2;
	s1=pow(ax-bx,2)+pow(ay-by,2);
	s2=pow(cx-bx,2)+pow(cy-by,2);
	if(s1!=s2){
		cout << "NO";
		getch();
		return 0;
	}
	long long a[2],b[2];
	a[0]=ax-bx;
	a[1]=ay-by;
	b[0]=cx-bx;
	b[1]=cy-by;
	double a1,b1;
	long long ab;
	ab=a[0]*b[0]+a[1]*b[1];
	a1=sqrt(pow(a[0],2)+pow(a[1],2));
	b1=sqrt(pow(b[0],2)+pow(b[1],2));
	if(ab/sqrt(pow(a[0],2)+pow(a[1],2))*sqrt(pow(b[0],2)+pow(b[1],2))>0){
		cout << "NO";
		return 0;
	}
	cout << "YES";
	getch();
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cassert>

using namespace std;

typedef long long ll;
typedef double real;
typedef pair<int, int> ii;

template <typename T>
string toString(T x)
{
	if (x == 0) return "0";
	bool negative = x < 0;
	string res;
	while (x)
	{
		res.push_back('0' + x % 10);
		x /= 10;
	}
	if (negative) res.push_back('-');
	reverse(res.begin(), res.end());
	return res;
}

void ioFromFile(string inputFileName, string outputFileName)
{
	ifstream fin(inputFileName);
	ofstream fout(outputFileName);
	cin.rdbuf(fin.rdbuf());
	cout.rdbuf(fout.rdbuf());
}

int read()
{
	int res;
	scanf("%d", &res);
	return res;
}

template <typename T>
T gcd(T a, T b) { return a == 0 ? b : gcd(b % a, a); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
//---------------------------------------------------

int main()
{
	int maxsec = read();
	int n = read();
	int nd = read();
	int ninsec = read();

	int res = 0;
	int numdivided = maxsec + 1;
	while (n)
	{
		if (nd > 0)
		{
			if (numdivided > maxsec)
			{
				res++;
				numdivided = 0;
			}
			numdivided++;
		}
		else
		{
			res++;
		}
		n -= ninsec;
	}

	cout << res;

	return 0;
}

/*

*/


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//
//using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

/*** Typedef ***/
typedef int ll;
//typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
typedef    long double   ld;

//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;

/*** Loops ***/
#define ffit(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)
#define F(a,b) for(int i = a; i < b; i++)
#define ff1(i,a,b) for(ll i = a; i < b; i++)
#define ff2(i,a,b) for(ll i = b-1; i >= a; i--)
#define ff3(i,a,b,m) for(ll i = a; i <b; i+=m)
#define ipar(ar,n) ll ar[n]; ff1(i,0,n) cin>>ar[i];
#define opar(ar,n) ff1(i,0,n) cout<<ar[i]<<" ";
#define foRev(num) for(ll i = num - 1; i >= 0; i--)
#define forIn(arr, num) for(ll i = 0; i < num; i++) sc1(arr[i]);
#define forIn1(arr, num) for(ll i = 1; i <= num; i++) sc1(arr[i]);
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define apnt(arr, num) for(ll i = 0; i < num; i++) cout << arr[i] << (i + 1 < num ? ' ' : '\n');

/*** Define Values ***/

#define PI acos(-1.0)
#define eps 1e-7
#define size1 15
#define mdd 1000000007
/*** STLs ***/
#define sf(a)            scanf("%lld",&a)
#define sff(a,b)         scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define cu continue
#define br break
#define rsz resize
#define ins insert
#define ft front
#define bk back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define rr return
#define mem(name, value) memset(name, value, sizeof(name))
#define MN3(n1,n2,n3) min(n1,min(n2,n3))
#define MN4(n1,n2,n3,n4) min(n1,min(n2,min(n3,n4)))
#define MX3(n1,n2,n3) max(n1,max(n2,n3))
#define MX4(n1,n2,n3,n4) max(n1,max(n2,max(n3,n4)))
#define mxar(a,n) *max_element(a,a+n)
#define mnar(a,n) *min_element(a,a+n)
#define arr_sm(a,n) accumulate(a,a+n,0)
#define vc_sm(ve) accumulate(ve.begin(),ve.end(),0)
#define mx_vc(ve) *max_element(ve.begin(),ve.end())
#define mn_vc(ve) *min_element(ve.begin(),ve.end())
//#define endl " \n"

/*** STLs ***/
typedef vector <ll> vll;
#define vvll vector<vll>
typedef set <ll> sll;
typedef multiset <ll> msll;
typedef multimap <ll,ll> mpll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll, ll> > vpll;
typedef priority_queue <pair <ll, ll> > pqpll;
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ml unordered_map<ll,ll>
///typedef    unordered_multiset<int>   umsi;
typedef    unordered_set<ll>   us;

///vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.

/*** Sorts ***/
#define czero(n)                    __builtin_popcountll(n) // count the number of 1's in the bit representation of a number
#define cenzero(n)                  __builtin_ctzll(n) // count the number of zereos from the end of the bit representation of a number until a 1
#define countbegzero(n)             __builtin_clzxll(n)
#define checkparity(n)              __builtin_parityll(n)// checks whether the number of bits are even or odd
#define all(v) (v).begin(), (v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtgrt(v) sort(all(v), greater<ll>())
#define prsrt greater<pair<int,int>>()
/*** Some Prints ***/
#define ip(n) ll n; cin>>n;
#define is(s) string s; cin>>s;
#define ipp(n,k) ll n; cin>>n; ll k; cin>>k;
#define ip3(n,m,k) ll n; cin>>n;ll m;cin>>m; ll k; cin>>k;
#define kl    '\n'
#define no cout << "NO" << '\n'
#define yes cout << "YES" << '\n'
#define case cout << "Case " << t++ << ": ";
#define ps(x,y)         fixed<<setprecision(y)<<x
#define inf             1e18
#define w(x)             ll x; cin>>x; while(x--)
#define go(i, a) for (auto &i : a)
#define go1(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)
//#define mk(arr,n,type) type *arr=new type[n];
#define sz(obj) (int(obj.size()))
#define ipve(vc,n) vll vc(n); ff1(i,0,n){cin>>vc[i];}
#define ipvc(vc,n) vll vc; ff1(i,0,n){ip(x);vc.pb(x);}
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define depressed()                    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//bool ans = all_of(arr, arr + 6, [](int x) {return x & 1; } );
const double pi = 3.141592653589793238460;
#define TRC
#ifdef TRC
#define trc(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trc(...)
#endif

void fun()
{
  ip3(a,b,h); ipp(w,n);
 vll v(n);
 go(i,v) cin>>i;
  srtgrt(v);
  if(n>34)
  {
    n = 34;
    v.resize(n);
  }
  ll tot = 1;
  ll ct = 0;
  vll vv;
  vv.pb(1);
  mll m;
  m[1] = 1;
  if(h>=a && w>=b)
  {
    cout<<0;rr;
  }
  swap(h,w);
  if(h>=a && w>=b)
  {
    cout<<0;rr;
  }
  go(x,v)
  {
    ct++;
    tot*=x;
    vll tm;
    go(y,vv)
    {
      tm.pb(x*y);
    }
    go(y,tm)
    {
      if(y<2e5+5 && !m[y])
      {
        vv.pb(y);
      }
    }
    go(y,vv)
    {
      if((h*y>=a && w*(tot/y)>=b) || (h*(tot/y)>=a && w*y>=b))
      {
        cout<<ct;rr;
      }

    }
  }
  cout<<-1;
}

int main()
{
// tasklist
// taskkill /f /im mo.exe
    depressed();
  ll t = 1;
 //cin>>t;
  while(t--)
  {
     fun();
  }
  //cer;
  return 0;
}


// *CoDeD by Ye.A
# include <iostream>
# include <cstdlib>
# include <cstdio>
# include <string>
# include <algorithm>

using namespace std;

int main ()
{
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++)
    {
        string t;
        for (int j = 0; j < n; j++)
            if (i != j)
                t.push_back (s[j]);
        string q = t;
        reverse (q.begin(), q.end());
        if (q == t)
        {
            t.clear();
            for (int j = 0; j < n; j++)
            {
                if (j == n - i + 1)
                {
                    t.push_back (s[i]);
                    j--;
                }
                else
                    t.push_back (s[j]);
            }
            if (n - i + 1 > n)
                t.push_back (s[i]);
            cout << t;
            return 0;
        }
    }
    puts ("NA");
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
using namespace std;
#define SIZE(vn) vn.size()
const long long modulo = 1000000007;
#define MOD(n)   ((n)%modulo)
#define SET0(zn) memset(zn,0,sizeof(zn))
#define SET(zn, k) memset(zn,k,sizeof(zn))
#define REP(i,n)  for (int i=0; i<(n); ++i)
typedef long long LL;
template <class T> void refreshMin(T & a, const T & b) {if (a>b) a = b;}
template <class T> void refreshMax(T & a, const T & b) {if (a<b) a = b;}
template <class T> void refreshMin(T & a, const T & b, T & c, const T & d) {if (a>b) {a = b; c = d;}  }
template <class T> void refreshMax(T & a, const T & b, T & c, const T & d) {if (a<b) {a = b; c = d;}  }
template <class T> T bitAnd(T  a, T  b) {return a & b;}
template <class T> T bitOr(T  a, T  b) {return a | b;}
template <class T> T bitXor(T  a, T  b) {return a ^ b;}
bool boolXor(bool  a, bool  b) {return (!a && b) || (a && !b);}
int main(int argc, char const *argv[]) {
	LL a, b;
	cin>>a>>b;
	LL re = 0;
	while(true) {
		if (a==0) break;
		if (a>=b) {
			re++;
			a-=b;
			continue;
		}

		re+= b/a;
		LL c = b % a;
		b = a; a = c;
	}
	cout<<re<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
#define eps 1e-10
#define maxl 100010
#define mem(i,j) memset(i,j,sizeof(i))
int prime[maxl];
vector<int> v;
int cnt[maxl];
void init(){
    memset(prime,1,sizeof(prime));
    prime[0]=prime[1]=0;
    v.clear();
    for(int i=2;i<maxl;i++) if(prime[i]){
        v.push_back(i);
        for(int j=i+i;j<maxl;j+=i) prime[j]=0;
    }
}
void add(ll n){
    for(int i=0;i<v.size();i++){
        while(n%v[i]==0){
            n/=v[i];
            cnt[i]++;
        }
        if(n==1) break;
    }
}

int main()
{
  //  freopen("in.txt", "r", stdin);
    init();
    ll n;
    cin>>n;
    add(n);
    ll res=1;
    for(int i=0;i<v.size();i++) if(cnt[i]) res*=v[i];
    cout<<res<<endl;
}


#include <iostream>
using namespace std;

int main()
{
	double l, d, v, g, r;
	cin>>l>>d>>v>>g>>r;
	double dtime=d/v;
	double ptime=0;
	if (dtime>g)
	{
		while (dtime>ptime)
		{
			ptime=g+r;
		}
		dtime=0;
	}
	double ltime=(l-d)/v;
	double res=ltime+ptime+dtime;
	printf("%.10lf",res);
	system("pause");
	return 0;
}


#include <iostream>

int main()
{
    unsigned char arr[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 1};
    unsigned int n = 0;

    std::cin >> n;

    int first_digit = n / 10;
    int second_digit = n % 10;
    int count = arr[first_digit] * arr[second_digit];
    std::cout << ( count == 1 ? 2 : count);

    return true;
}


#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<algorithm>
#include<cctype>

using namespace std;
int main(){
	bool f = 1;
	int n;
	cin >> n;
		string a;
		cin >> a ;
		int u=0, l=0;
		int g = abs(max(u, l)-n/2);
		for (int i = 0; i < a.length(); i++)if (islower(a[i]))l++; else u++;
		if (l<u)
		for (int i = 0; i < a.length(); i++){ if (l == n / 2){ break; }if (isupper(a[i])){ l++; a[i] = tolower(a[i]); } }
		else
		for (int i = 0; i < a.length(); i++){ if (u == n / 2){ break; }if (islower(a[i])){ u++; a[i] = toupper(a[i]); } }

		cout << g<<endl<<a << endl;
	system("pause");
}


#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
#define pb push_back
#define fio cin.sync_with_stdio(false)
#define takeinput1 vector<ll>v(n);for(int i=0;i<n;i++){cin>>v[i];}
#define takeinput2 vector<ll>u(n);for(int i=0;i<n;i++){cin>>u[i];}
int main(){
    ll l1,r1,t1;cin>>l1>>r1>>t1;
    ll l2,r2,t2;cin>>l2>>r2>>t2;ll k;
    if(t1>t2){
        k=t1;t1=t2;t2=k;
        k=l1;l1=l2;l2=k;
        k=r1;r1=r2;r2=k;
    }
    unordered_map<ll,ll>map;

    ll ans=0;
    for(int i=0;i<999999;i+=t1){
        ll p=0,temp=0;
        for(int j=i+l1;j<=i+r1;j++){
            ll a=j%t1;
            ll b=j%t2;
            if(a>=l1&&a<=r1)a=-1;
            if(b>=l2&&b<=r2)b=-1;
            if(a==-1&&b==-1){
                temp++;
                if(j==i+r1){
                    if(map[j%t1]==j%t2&&ans!=0){
                    cout<<ans;return 0;
                }
                    map[j%t1]=j%t2;
                if(ans<temp){
                    ans=temp;
                }
                }
            }
            else if(a!=-1||b!=-1){
                if(map[(j-1)%t1]==(j-1)%t2&&ans!=0){
                    cout<<ans;return 0;
                }
                if(temp!=0){
                    map[(j-1)%t1]=(j-1)%t2;
                }
                if(ans<temp){
                    ans=temp;
                }

                temp=0;
            }
        }
        }
    cout<<ans;
}


#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
long long bef, dif;
int Query(long long x){
    dif = abs(x-bef);
    printf("? %lld\n",x);
    fflush(stdout);
    int ck;
    scanf("%d",&ck);
    bef=x;
    return ck;
}
void Answer(long long a){
    printf("= %lld\n",a);
    fflush(stdout);
}
void Solve(){
    long long n;
    scanf("%lld",&n);
    if(n<=10){
        long long res;
        for(int i=0;;i++){
            int ck;
            if(i%2==0)ck = Query(i/2+1);
            if(i%2==1)ck = Query(n-i/2);
            if(i && !ck){
                res = dif+1;
                break;
            }
            if(i==n-1){
                res=1;break;
            }
        }
        Answer(res);
        return;
    }
    long long K = n-1;
    int i, m=0;
    for(i=0;;i++){
        long long t = (1ll<<(i+2))-1;
        if(t > K)break;
    }
    m = i-1;
    vector<long long>V;
    V.push_back((1ll<<m));
    K-=(1ll<<m);
    for(i=m;i>=0;i--){
        V.push_back((1ll<<i));
        K-=(1ll<<i);
    }
    long long b=1,e;
    for(i=0;i<V.size();i+=2)b+=V[i];
    int last = 0;
    long long ans = n, U = 0;
    Query(b);
    e = b+K;
    last = Query(e);
    if(last){
        last = Query((b+e+1)/2);
        e = (b+e+1)/2;
        long long bb = 1, ee = K, mid;
        if(last)ee=dif;
        else bb=dif+1;
        int ck=0;
        while(bb<ee){
            mid = (bb+ee)/2;
            if(!ck){
                b=e-mid;
                last = Query(b);
            }
            else{
                e=b+mid;
                last = Query(e);
            }
            if(last) ee = mid;
            else bb = mid + 1;
            ck = !ck;
        }
        Answer(bb);
        return;
    }
    int chk=0;
    for(i=0;;i++){
        long long tp;
        if(!chk){
            if(i==V.size())break;
            tp = V[i];
        }
        else{
            U/=2;
            if(!U)break;
            tp=U;
        }
        if(i%2==1){
            e+=tp * (1-last*2);
            last = Query(e);
        }
        else{
            b-=tp * (1-last*2);
            last = Query(b);
        }
        if(last){
            ans = dif;
            U=tp;
            chk=1;
        }
    }
    Answer(ans);
}
int main(){
    int TC;
    scanf("%d",&TC);
    while(TC--){
        Solve();
    }
}


#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <deque>
#include <set>
#include <cmath>
#include <fstream>
#include <string>
#include <algorithm>
#include <iomanip>
typedef long long ll;
typedef long double ld;
const int N = int(1e6) + 7;
const ll INF = ll(1e18) + 111;
const ld EPS = 1e-7;
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define x first
#define y second
using namespace std;
template<typename T> inline istream &operator >> (istream &in, vector<T> &v) { for (auto &i : v) { in >> i; } return in; }
template<typename T> inline ostream &operator<< (ostream &out, const vector<T> &v) { for (auto &it : v) { out << it << " "; } return out; }
string s[6];
void print() {
	for (int i = 0; i < 6; i++) {
		cout << s[i] << endl;
	}
}
int main() {
	//ifstream cin("input.txt");
	ios::sync_with_stdio(0);
	cin.tie(0);

	for (int i = 0; i < 6; i++) {
		cin >> s[i];
	}
	if (s[0][3] == '.') {
		s[0][3] = 'P';
		print();
	}
	else if (s[0][4] == '.') {
		s[0][4] = 'P';
		print();
	}
	else if (s[1][3] == '.') {
		s[1][3] = 'P';
		print();
	}
	else if (s[1][4] == '.') {
		s[1][4] = 'P';
		print();
	}
	else if (s[0][0] == '.') {
		s[0][0] = 'P';
		print();
	}
	else if (s[0][1] == '.') {
		s[0][1] = 'P';
		print();
	}
	else if (s[0][6] == '.') {
		s[0][6] = 'P';
		print();
	}
	else if (s[0][7] == '.') {
		s[0][7] = 'P';
		print();
	}
	else if (s[1][0] == '.') {
		s[1][0] = 'P';
		print();
	}
	else if (s[1][1] == '.') {
		s[1][1] = 'P';
		print();
	}
	else if (s[1][6] == '.') {
		s[1][6] = 'P';
		print();
	}
	else if (s[1][7] == '.') {
		s[1][7] = 'P';
		print();
	}
	else if (s[3][3] == '.') {
		s[3][3] = 'P';
		print();
	}
	else if (s[3][4] == '.') {
		s[3][4] = 'P';
		print();
	}
	else if (s[4][3] == '.') {
		s[4][3] = 'P';
		print();
	}
	else if (s[4][4] == '.') {
		s[4][4] = 'P';
		print();
	}
	else if (s[5][3] == '.') {
		s[5][3] = 'P';
		print();
	}
	else if (s[5][4] == '.') {
		s[5][4] = 'P';
		print();
	}
	else if (s[6][3] == '.') {
		s[6][3] = 'P';
		print();
	}
	else if (s[6][4] == '.') {
		s[6][4] = 'P';
		print();
	}
	else if (s[3][0] == '.') {
		s[3][0] = 'P';
		print();
	}
	else if (s[3][1] == '.') {
		s[3][1] = 'P';
		print();
	}
	else if (s[3][6] == '.') {
		s[3][6] = 'P';
		print();
	}
	else if (s[3][7] == '.') {
		s[3][7] = 'P';
		print();
	}
	else if (s[4][0] == '.') {
		s[4][0] = 'P';
		print();
	}
	else if (s[4][1] == '.') {
		s[4][1] = 'P';
		print();
	}
	else if (s[4][6] == '.') {
		s[4][6] = 'P';
		print();
	}
	else if (s[4][7] == '.') {
		s[4][7] = 'P';
		print();
	}
	else if (s[5][0] == '.') {
		s[5][0] = 'P';
		print();
	}
	else if (s[5][1] == '.') {
		s[5][1] = 'P';
		print();
	}
	else if (s[5][6] == '.') {
		s[5][6] = 'P';
		print();
	}
	else if (s[5][7] == '.') {
		s[5][7] = 'P';
		print();
	}
	else if (s[6][0] == '.') {
		s[6][0] = 'P';
		print();
	}
	else if (s[6][1] == '.') {
		s[6][1] = 'P';
		print();
	}
	else if (s[6][6] == '.') {
		s[6][6] = 'P';
		print();
	}
	else if (s[6][7] == '.') {
		s[6][7] = 'P';
		print();
	}

	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define allr(x) (x.rbegin()),(x.rend())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif

const long long mod = 1e9 + 7;
ll a,b;
void test_case(){
	cin >> a >> b;
	ll l = b+1,r = 1ll * a * b + 1;

	auto f = [&](ll x){
		ll lr = x*l,rr = r*x;
		int modval1 = x - lr%b,modval2 = x - rr%b;
		if(modval1 < 0) modval1 += b;
		if(modval2 < 0) modval2 += b;
		lr += modval1;
		rr += modval2;
		//debug() << owo(lr) owo(rr) owo(x);
		ll n = (rr - lr)/(b*x) + 1;
		assert(n>=0);
		ll res = (n*(lr + rr))/2;
		return res;
	};

	ll ans = 0;
	for(int i = 1;i<b;++i){
		ans = (ans%mod + f(i)%mod)%mod;
	}
	cout << ans << endl;
	return;
}

int main(){
	FAST_IO;
	int tt;
	//cin >> tt;
	tt = 1;

	for(int i = 0;i<tt;++i){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

typedef long long ll;

const int MAX_N = 100030;     // Change as necessary
const ll  MODD  = 1000000009; //

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

  n = (720+n)%360;
  ll m = n;

  ll best = min(n,360-n),ctr = 0,best_ctr = 0;
  while(ctr == 0 || m != n){
    n = (n+270)%360;
    ctr++;
    if(best > min(n,360-n)){
      best = min(n,360-n);
      best_ctr = ctr;
    }
  }
  cout << best_ctr << endl;
}

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

  do_case();

  return 0;
}


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

int main(){
    int n,zero=0,one=0,i,j;
    string s;
    cin>>n;
    cin>>s;
    //for(i=0;i<89;i++)s+='1';
    for(i=0;i<n;){
        if(s[i]=='0'){
            if(one>0){
                cout<<one;
                zero++;
            }
            else{
                cout<<0;
                zero++;
            }
            one=0;
            i++;
        }
        if(s[i]=='1')one++,i++;
    }
    if(zero!=1){
        if(one>0)cout<<one;
        else cout<<0;
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

signed main() {
	ll n, m, k;
	cin >> n >> m >> k;
	ll l = 0, r = m + 1;
	while (r - l > 1) {
		ll mid = (l + r) / 2, L, R;
		if (mid >= k)
			L = (k - 1) * (mid - 1 + mid - (k - 1)) / 2;
		else
			L = (mid - 1) * mid / 2 + k - mid;
		if (mid - 1 >= n - k)
			R = (n - k) * (mid - 1 + mid - (n - k)) / 2;
		else
			R = (mid - 1) * mid / 2 + n - k - (mid - 1);
		//cout << mid << ' ' << L << ' ' << R << endl;
		if (L + R + mid <= m) {
			l = mid;
		}
		else {
			r = mid;
		}
	}
	cout << l;
	system("pause");
	return 0;
}


#include<cstdio>
#include<vector>

int main(){
	int n;
	scanf("%d", &n);
	std::vector<int> a(1 + n);
	int sum = 0;

	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		sum += a[i];
	}

	int sum1 = 0;
	int l = 1;
	int r = 0;
	for(int i = 1; i <= n; i++){
		sum1 += a[i];
		r = i;
		if(sum - sum1 != 0){
			printf("YES\n");
			printf("2\n");
			printf("%d %d\n", l, r);
			printf("%d %d", r + 1, n);
			return 0;
		}
	}
	printf("NO");
	return 0;
}


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

using namespace std;

struct state
{
    string a , b , c ;
    int n;
    state() {};
    state(int _n , string _a , string _b , string _c) : n(_n) , a(_a) , b(_b) , c(_c) {};
};

int n;
string card[60];

set <pair<int , pair<string , pair<string , string> > > > was;

int main()
{
scanf("%d",&n);
for (int i = 1 ; i <= n ; i ++ )
    cin >> card[i];
queue <state> q;
q.push(state(n , card[n - 2] , card[n - 1] , card[n]) );
while ( !q.empty() )
{
    state v = q.front();
    q.pop();
    if ( was.find(make_pair(v.n , make_pair(v.a , make_pair(v.b , v.c)))) != was.end() )
        continue;
    was.insert(make_pair(v.n , make_pair(v.a , make_pair(v.b , v.c))));
    if ( v.n == 1 )
    {
        printf("YES\n");
        return 0;
    };
    if ( v.n - 3 > 0 && (card[v.n - 3][0] == v.c[0] || card[v.n - 3][1] == v.c[1]) )
        q.push(state(v.n - 1 , v.c , v.a , v.b) );
    if ( v.b[0] == v.c[0] || v.b[1] == v.c[1] )
    {
        if ( v.n > 3 )
            q.push(state(v.n - 1 , card[v.n - 3] , v.a , v.c) );
        if ( v.n == 3 )
            q.push(state(v.n - 1 , "aa" , v.a , v.c) );
        if ( v.n == 2 )
            q.push(state(v.n - 1 , "aa" , "aa" , v.c) );
    };
};
printf("NO\n");
return 0;
}


#include <stdio.h>
#include <string.h>
 #include<malloc.h>
 #include<iostream>
 #include<algorithm>
 #include<cassert>
 #include<vector>
 #include<cmath>
 #include<stdlib.h>

using namespace std;

int main(){
    int a,b,j,i,c1=0,c2=0,c3=0,mid=0;
    cin>>a>>b;
    mid=(a+b)/2;
    if((2*mid)==(a+b)) c2=1;
    i=mid;
    j=mid;
    if(c2) {i--;j++;}
    else j++;

    while(i-->0) c1++;
    while(j++<7) c3++;

   if(a<=b) cout<<c1<<" "<<c2<<" "<<c3;
   else  cout<<c3<<" "<<c2<<" "<<c1;

  //system("pause");
   return 0;
}


#include <bits/stdc++.h>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000009
#define PI 3.1415926535897932384626433832795
#define oo 1e9
#define pb push_back

using namespace std;

struct point {
    double x, y, z;

    point() {
        x, y, z = 0;
    }

    point(double x, double y, double z) {
        this->x = x;
        this->y = y;
        this->z = z;
    }

    point(point &p) {
        x = p.x;
        y = p.y;
        z = p.z;
    }

    double &operator[](int i) {
        switch (i) {
            case 0:
                return x;
            case 1:
                return y;
            case 2:
                return z;
        }
    }

    void toString() {
//        printf("(%.2f, %.2f, %.2f)", x, y, z);
    }

};

//struct line {
//    point p1, p2;
//
//    line() {}
//
//    line(point p1, point p2) {
//        this->p1 = p1;
//        this->p2 = p2;
//    }
//
//};
//
//struct side {
//
//    line l1, l2;
//    ll n;
//
//    side() {}
//
//    side(line l1, line l2) {
//        this->l1 = l1;
//        this->l2 = l2;
//    }
//};

point a, b;
//side box[6];
//
//void createSide(int d1, int d2, int d3, int n, side &s) {
//    point p1, p2, p3, p4;
//    p2[d1] = b[d1];
//    p2[d2] = b[d2];
//    p3[d1] = b[d1];
//    p4[d2] = b[d2];
//    if (d3 != -1) {
//        p1[d3] = b[d3];
//        p2[d3] = b[d3];
//        p3[d3] = b[d3];
//        p4[d3] = b[d3];
//    }
//    line l1(p1, p2), l2(p3, p4);
//    side ss(l1, l2);
//    s = ss;
//    s.n = n;
//}

point arr[6];
int m[6];

pair<int, int> planeEquation[6];
point mn[6];
point mx[6];

int f(point p1, point p2, int ii) {

    double x= p2.x;

//    cout<<ii<<" : ";p1.toString();
    p2.x -= p1.x;
    p2.y -= p1.y;
    p2.z -= p1.z;
    double tt = (x-p1.x)/(double)p2.x;
//    cout<<" + t* "; p2.toString();cout<<endl;
    // r(t) = p1 + p2 * t

    for (int i = 0; i < 6; i++) {
        if (i != ii) {
            pair<int, int> pe = planeEquation[i];
            if(p2[pe.first]==0){
                return 0;
            }
            double t = (pe.second - p1[pe.first]) / (double) p2[pe.first];
            point p(p1.x + (t * p2.x), p1.y + (t * p2.y), p1.z + (t * p2.z));
            p[pe.first] = pe.second;
//            cout<<"\t"<<i<<" :\n";
//            cout<<"\tt : "<<t<<" ";p.toString();
//            cout<<endl<<"\t";
//            mn[i].toString(); cout<<" "; mx[i].toString(); cout<<endl;
            if (p.x >= mn[i].x && p.x <= mx[i].x &&
                p.y >= mn[i].y && p.y <= mx[i].y &&
                p.z >= mn[i].z && p.z <= mx[i].z) {
                if(t<tt){
                    return 0;
                }
            }
        }
    }
    return m[ii];
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    cin >> a.x >> a.y >> a.z;
    cin >> b.x >> b.y >> b.z;

    planeEquation[0] = {1, 0};
    planeEquation[1] = {1, b.y};
    planeEquation[2] = {2, 0};
    planeEquation[3] = {2, b.z};
    planeEquation[4] = {0, 0};
    planeEquation[5] = {0, b.x};

    mn[0] = point(0, 0, 0);
    mn[2] = point(0, 0, 0);
    mn[4] = point(0, 0, 0);
    mx[0] = point(b.x, 0, b.z);
    mx[2] = point(b.x, b.y, 0);
    mx[4] = point(0, b.y, b.z);

    mn[1] = point(0, b.y, 0);
    mn[3] = point(0, 0, b.z);
    mn[5] = point(b.x, 0, 0);
    mx[1] = b;
    mx[3] = b;
    mx[5] = b;

    arr[0].x = b.x / 2.0;
    arr[0].y = 0;
    arr[0].z = b.z / 2.0;

    arr[1].x = b.x / 2.0;
    arr[1].y = b.y;
    arr[1].z = b.z / 2.0;

    arr[2].x = b.x / 2.0;
    arr[2].y = b.y / 2.0;
    arr[2].z = 0;

    arr[3].x = b.x / 2.0;
    arr[3].y = b.y / 2.0;
    arr[3].z = b.z;

    arr[4].x = 0;
    arr[4].y = b.y / 2.0;
    arr[4].z = b.z / 2.0;

    arr[5].x = b.x;
    arr[5].y = b.y / 2.0;
    arr[5].z = b.z / 2.0;

    for (int i = 0; i < 6; i++) {
        cin >> m[i];
        //   arr[i].toString();
    }

    int res = 0;

    for (int i = 0; i < 6; i++) {
        res += f(a, arr[i], i);
//        cout<<res<<endl;
    }

    cout << res << endl;

//    createSide(0, 2, -1, m[0], box[0]);
//    createSide(0, 2, 1, m[1], box[1]);
//    createSide(0, 1, -1, m[2], box[2]);
//    createSide(0, 1, 2, m[3], box[3]);
//    createSide(1, 2, -1, m[4], box[4]);
//    createSide(1, 2, 1, m[5], box[5]);
//
//    for (int i = 0; i < 6; i++) {
//        cout << "side " << i << " :\n";
//        cout << "\tline 1: \n";
//        cout << "\t\tp1: ";
//        box[i].l1.p1.toString();
//        cout << endl;
//        cout << "\t\tp2: ";
//        box[i].l1.p2.toString();
//        cout << endl;
//        cout << "\tline 2: \n";
//        cout << "\t\tp1: ";
//        box[i].l2.p1.toString();
//        cout << endl;
//        cout << "\t\tp2: ";
//        box[i].l2.p2.toString();
//        cout << endl;
//        cout << "\n";
//    }

    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define fr first
#define sc second
using namespace std;
int main()
{
    ///freopen("input.txt" , "r" , stdin );
    ///freopen("output.txt", "w" , stdout );
    ///Murtazoev_2007
    speed ;
    ///Autor of the greatest code :: Ahmadjon Murtazoev
    system("color a") ;
    ll a , b , z ;
    cin >> a >> b ;
    z = b ;
    while (z -- )
    {
        if (a%b == 0)
        {
            break ;
        }
        cout << a/b << " " ;
        a -= a/b ;
        b -- ;
    }
    for (ll i = 0 ; i<b ; i ++ )
    {
        cout << a/b << " " ;
    }
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std;
typedef __int64 LL;
int main()
{
    LL a,s=1e18;
    scanf("%I64d",&a);
    LL mov=a-(9*((s*9)%a))%a;
    printf("%I64d %I64d\n",mov,s+mov-1);
}


#include<bits/stdc++.h>
#define inf 1000000007
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
using namespace std;
int n1,n2,x,y;

int bns()
{
	int s = 0,e = inf,tmp,t1;
	while(s<e){
		tmp = (s+e)/2;
		t1 = tmp-tmp/(x*y);
		if((tmp-tmp/x)<n1||(tmp-tmp/y)<n2){
			if(tmp==s)
				return e;
			s = tmp;
		}
		else if(t1>(n1+n2)){
			e = tmp;
		}
		else if(t1<(n1+n2)){
			if(tmp==s)
				return e;
			s = tmp;
		}
		else
			return tmp;
		//cout<<s<<e<<endl;
	}
	return e;
}

int main()
{
	//freopen("file.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
	int t=1,ty = 1;
	//cin>>t;
	while(t--){
		cin>>n1>>n2>>x>>y;
		cout<<bns()<<endl;
	}
	return 0;
}


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

int main() {
    int n,m,a,b;
    double ra,rb;
    long long mon=0;
    scanf("%d%d%d%d",&n,&m,&a,&b);
    if(m>n){
        if(n*a<=b){
            mon=n*a;
            n=-1;
        }
        else{
            mon=b;
        }

    }
    else{
    if(b<=a*m && n>0){
        n-=m;
        mon+=b;
        while(n>=m){
        n-=m;
        mon+=b;
        }

    }
    if(n>0){
        if(b>n*a)
        mon+=(n*a);
        else
        mon+=b;
    }

    }
    cout<<mon<<endl;

    return 0;
}


#include<iostream>
using namespace std;

int main()
{
	int number;
	int kNumber;
	while ( cin >> number )
	{
		cin>>kNumber;
		cout<<(3 * number - kNumber)<<endl;
	}
	return 1;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define sp ' '
#define nl '\n'
void sc(){}template<class T,class...A>void sc(T&t,A&...a){cin>>t,sc(a...);}
void pr(){}template<class T,class...A>void pr(T t,A...a){cout<<t,pr(a...);}
#define ms(x, y) memset(x, y, sizeof(x))
#define sz(x) (int)(x.size())
#define af(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
const int mod = 1e9 + 7, base = 131;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int n, ans;
string s;
queue<string> q;
int main(){
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
	sc(n, s);
	q.push(s);
	while(sz(q)){
		string p = q.front(); q.pop();
		ans = max(ans, n - sz(p));
		if (sz(p) == 1) continue;
		for (int i = 0; i < sz(p); i++){
			bool flag = 0;
			if (i){
				if (p[i] - 1 == p[i - 1]) flag = 1;
			}
			if (i < sz(p) - 1){
				if (p[i] - 1 == p[i + 1]) flag = 1;
			}
			if (flag) q.push(p.substr(0, i) + p.substr(i + 1, sz(p) - i));
		}
	}
	pr(ans);
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std;
int main()
{
FASTIO
input_from_file
int n;
cin>>n;
int v[n];
std::vector<int> a;
for(int i=0;i<n;i++)
{
  cin>>v[i];
}
for(int i=0;i<(n-1);i++)
{
if((v[i]==2 && v[i+1]==3)||(v[i]==3)&&(v[i]==2))
{
  a.pb(1);
}
else if(v[i]==v[i+1])
{
  a.pb(1);
}
else
{
  a.pb(0);
}
}
sort(a.rbegin(),a.rend());
if(v[0]==1)
{
  std::cout << "Infinite" << '\n';
}
else
{
  std::cout << "Finite"<< '\n';
int cnt=0;
for(int i=0;i<(n-1);i++)
{
  if((v[i]==1)&&(v[i+1]==2)||(v[i]==2)&&(v[i+1]==1))
  {
    cnt=cnt+3;
  }
  else if((v[i]==1)&&(v[i+1]==3)||(v[i]==3)&&(v[i+1]==1))
  {
    cnt=cnt+4;
  }
  if((i-1)>=0 && v[i]==1 && v[i+1]==2 && v[i-1]==3)
  {
    cnt--;
  }
}
cout<<cnt;
}
}


#include<iostream>

using namespace std;
int main()
{
    int a,b,dif,A,B;
    cin >> a >> b;
    if(a+b>0)
    {
      while(1)
      {
        A = a*2;
        B = b*2-1;
        if(a>b)
        {
            a = a*2;
            b = b*2-1;
            dif = a-b+1;
            if(dif==4) cout << "YES";
            if(dif!=4) cout << "NO";
            break;
        }
        if(a==b)
        {
            cout << "YES";
            break;
        }
        if(A<B-1)
        {
            dif = B-A+1;
            if(dif==4) cout << "YES";
            if(dif!=4) cout << "NO";
            break;
        }
        a--;
        b--;
        if(a==0&&b-1==0)
        {
            cout << "YES";
            break;
        }
        if(a==0&&b-1!=0)
        {
            cout << "NO";
            break;
        }
      }
    }
    else cout << "NO";

    return 0;
}


#include <stdio.h>

void main() {
    freopen("INPUT.TXT", "r", stdin);
    freopen("OUTPUT.TXT", "w", stdout);
	int x = 0;
	int y = 0;
	int res = 0;
	scanf("%d %d", &x,&y);
	if(((x > 0) & (y > 0))|((x < 0) & (y < 0))) {
		if(x < 0) {
			x *= -1;
		}
		if(y < 0) {
			y *= -1;
		}
		res = x + y;
		if(res/2 == 0) {
			printf("white");
		}else{
			printf("black");
		}
		return;
	}
	if(((x < 0) & (y > 0))|((x > 0) & (y < 0))) {
		if(x < 0){
			x *= -1;
		}
		if(y < 0){
			y *= -1;
		}
		res = x + y;
		if(res/2 == 1) {
			printf("white");
		}else{
			printf("black");
		}
		return;
	}
}


#include<iostream>
using namespace std;
int main()
{
	int n,p,k;

	cout << "insert n, p, k " << endl;
	////n
	cin >> n;
	/*while (n < 3 || n > 100)
	{
		cout << "wrong n ";
		cin >> n;
	}
	cout << n << endl;*/
	///p
	cin >> p;
	/*while (1 > p || p > n)
	{
		cout << "wrong p ";
		cin >> p;
	}
	cout << p << endl;
	///k*/
	cin >> k;
	/*while (1 > k || k > n)
	{
		cout << "wrong k ";
		cin >> k;
	}
	cout<<k<<endl;*/
	///

	if (p - k > 1)cout << "<< ";
	/*for (int i = p - k; i <= p + k && i < n; i++)
	{
		if (i == p) cout << "(" << p << ") ";
		else if (i > 1) cout << i << " ";
	}*/
	int i = p - k;
	while (i <= p + k )
	{
		if (i == p) cout << "(" << p << ") ";
		else if (i > 1) cout << i << " ";
		i++;
	}
	if (p + k < n) cout << " >>";
	system("pause");
	return 0;
}


//author ----> noobiesAG

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

#define int                long long
#define double             long double
#define pb                 push_back
#define mp                 make_pair
#define ld                 long double
#define vi                 vector<int>
#define vvi                vector<vector<int>>
#define vpii               vector<pair<int,int>>
#define pii                pair<int,int>
#define mii                map<int,int>
#define umap               unordered_map
#define all(c)             c.begin(),c.end()
#define si(c)              (int)c.size()
#define lb                 lower_bound
#define ub                 upper_bound
#define gi                 greater<int>
#define rev                reverse
#define ff                 first
#define ss                 second
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define ayes               cout << "Yes" << endl
#define ano                cout << "No" << endl
#define nl                 cout << endl
#define hello              cerr << "hello" << endl
#define sp(x)              fixed << setprecision(x)
#define re                 return
#define p_q                priority_queue
#define FAST               ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>ordered_multiset;
//find_by_order(k)  --> value at kth index (iterator)
//order_of_key(k)   --> index of value k

void dbg_out(){cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const double pi = 3.14159265359;
const int mod = 1000000007;
const int modc = 998244353;
const int inf = LLONG_MAX;
const int neg_inf = LLONG_MIN;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //use rng() instead of rand() //shuffle(all(a),rng)

int inline power(int a, int b, int p){
    a %= p;
    int ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

int mod_inv(int n, int p){
    return power(n,p-2, p);
}

bool inline isPrime(int n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
template<typename... T>
void W(T&&... args)
{
	((cout << sp(17) <<  args << " "), ...);
	nl;
}
template<typename... T>
void R(T&&... args)
{
	((cin >> args), ...);
}
int ston(string s)
{
	int a = 0;
	reverse(s.begin(),s.end());
	int pow = 1;
	for(int i=0;i<s.size();i++)
	{
		a += pow*(s[i]-'0');
		pow*=10;
	}
	return a;
}
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	if(si(binaryNum) == 0)
		binaryNum.pb('0');
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
int bton(string &s, int base)
{
	int ans = 0;
	int pow  = 1;
	rev(all(s));
	for(auto x : s)
	{
		if(x >= 'a' && x <= 'z')
			ans += (x - 'a' + 10)*pow;
		else
			ans += (x-'0')*pow;
		pow *= base;
	}
	return ans;
}
template<class T>
void wv(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
template<class T>
void rv(T &v)
{
	for(int i=0;i<si(v);i++)
		cin >> v[i];
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
const int M = 5e5;
/*
int fact[M];
int ncr(int n, int r)
{
	int ans = fact[n];
	int denom = (fact[r]*fact[n-r])%mod;
	ans = (ans * mod_inv(denom,mod))%mod;
	return ans;
}
*/
//vector<int>v[M];

void solve()
{
	int i,j,sum = 0,prod = 1,maxl = neg_inf, minl = inf;
	int n;
	cin >> n;
	vector<char>v;
	for(i=0;i<n/2;i++)
		v.pb('a' + i);
	map<string,int>m;
	int cnt = 0;
	do
	{
		string temp;
		for(auto x : v)
			if(x != 'a')
				temp.pb(x);
		if(m[temp] == 0)
		{
			cnt++;
			m[temp] = 1;
		}
	}while(next_permutation(all(v)));
	//ncr
	int numerator = 1;
	int denominator = 1;
	for(i=1;i<=n;i++)
	{
		numerator *= i;
		if(i <= n/2)
			denominator *= i*i;
	}
	cnt *= cnt;
	cnt *= numerator/denominator;
	cout << cnt/2 << endl;
}
int32_t main()
{
	FAST;
	int t = 1;
	/*
	fact[0] = 1;
	for(int i = 1;i<M;i++)
		fact[i] = (i * fact[i-1])%mod;
		*/
	int test = 1;
	while(t--)
	{
	//	cout << "Case #" << test << ": ";
		solve();
		test++;
	}
}


#include <iostream>
#include <cstring>
using namespace std;
int a[113444523];
int main(){
    string e;
    cin>>e;
    int b;
    for(b=0;b<e.length();b++){
        if('A'<=e[b]<='Z') e[b]=e[b]-'A';
        else if('a'<=e[b]<='z') e[b]-='a';
        if('A'<=e[b]<='Z'||'a'<=e[b]<='z')a[int(e[b])-32]++;
    }
    for(b=0;b<26;b++){
        if(a[b]<1) {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


/*
理理思路：
我们假设
gcd(a,v)=X,lcm(b,v)=Y;
假设a=X*k1,v=X*k2,b*k3=Y,v*k4=Y
满足(k1,k2)=1,(k3,k4)=1
那么X*k2*k4=Y
C=k2*k4
那么先求出C的质因子，然后对于每个x1[],x2[]中的元素，求出一个集合表示他有几个C中的质因子，
那么如果两个数集合为全集那么不行，然后开个桶存状态，表示这种集合有几个数，那么前缀和枚举即可
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,X,Y,C,ans,xx;
vector<ll>x1,x2,a;
ll c[2][1000010];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>X>>Y;
	if(Y%X)
	{
		cout<<0<<endl;
		return 0;
	}
	C=Y/X;
	for(ll i=2;i*i<=min(1000000000000,C);++i)
	{
		if(C%i)continue;
		a.push_back(i);
		while(C%i==0)C/=i;
	}
	// for(ll i=0;i<a.size();++i)cout<<a[i]<<" ";cout<<endl;
	for(ll i=1,a;i<=n;++i)
	{
		cin>>a;
		xx=__gcd(xx,a);
		if(a%X==0)x1.push_back(a/X);
		if(Y%a==0)x2.push_back(Y/a);
	}
	if(C!=1)
	{
		if(xx!=1)a.push_back(xx);
		C/=xx;
		if(C!=1)a.push_back(C);
	}
	// for(ll i=0;i<x2.size();++i)cout<<x2[i]<<" ";cout<<endl;
	for(ll i=0;i<(ll)x1.size();++i)
	{
		ll o=0;
		for(ll j=0;j<(ll)a.size();++j)
			if(x1[i]%a[j]==0)o|=(1<<j);
		c[0][o]++;
	}
	for(ll i=0;i<(ll)x2.size();++i)
	{
		ll o=0;
		for(ll j=0;j<(ll)a.size();++j)
			if(x2[i]%a[j]==0)o|=(1<<j);
		c[1][o]++;
	}
	// for(ll i=0;i<(1<<a.size());++i)cout<<c[0][i]<<" ";cout<<endl;
	// for(ll i=0;i<(1<<a.size());++i)cout<<c[1][i]<<" ";cout<<endl;
	for(ll i=0;i<a.size();++i)
		for(ll s=0;s<(1<<(ll)a.size());++s)if((1<<i)&s)
			c[0][s]+=c[0][s^(1<<i)];
	for(ll s=0;s<(1<<(ll)a.size());++s)
		ans+=c[0][s]*c[1][((1<<(ll)a.size())-1)^s];
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <conio.h>
using    namespace std;

long long X1,X2;
long long WR1,WR2;
long long T1,T2,T0;
double best=1000005;

void Solve(void)
{
  for(long long i=0 ; i<=X1 ; i++)
  {
    long long l=0,r=X2,mid=X2/2;
    while(i+mid && l<=r)
    {
      long long tmp=(long long)T1*i+T2*mid;
      double t=(double)tmp/(i+mid);
      if(t>=T0 && t<best)                            { best=t; WR1=i; WR2=mid; }
      else if(t>=T0 && t==best && i+mid > WR1+WR2)   { WR1=i;  WR2=mid; }
      if(t<=T0) { l=mid+1; mid=(l+r)/2; }
      else      { r=mid-1; mid=(l+r)/2; }
    }
  }
}

int main()
{
  cin >> T1 >> T2 >> X1 >> X2 >> T0;
  Solve();
  cout << WR1 << ' ' << WR2 << endl;
  getch();
}


#include<bits/stdc++.h>
using namespace std;
typedef pair < int , int > Point;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    Point A;
    int i , steps ;
    cin>>A.first>>A.second;
    Point O{0,0};
    string S;
    cin>>S;

    for(i=0;i<S.length();++i)
    {
        if(S[i]=='D')
            O = {O.first,O.second-1};
        if(S[i]=='U')
            O = {O.first,O.second+1};
        if(S[i]=='R')
            O = {O.first+1,O.second};
        if(S[i]=='L')
            O = {O.first-1,O.second};
    }

    if(O.first * A.first<0)
        steps = O.second!=0?A.second/O.second:0;
    else if(O.first!=0)
        steps =  A.first / O.first;
    else
        steps =O.second!=0? A.second/O.second:0;

    Point P = O;
    for(int x=-200000;x<=200000;++x)
    {
        if(steps+x<0)continue;
        O = P ;
        O = { (steps+x) * O.first , (steps+x) * O.second };
        map < Point , bool > M;
        M[O]=1;
        for(i=0;i<S.length();++i)
        {
            if(S[i]=='D')
                O = {O.first,O.second-1};
            if(S[i]=='U')
                O = {O.first,O.second+1};
            if(S[i]=='R')
                O = {O.first+1,O.second};
            if(S[i]=='L')
                O = {O.first-1,O.second};
            M[O]=1;
        }
        if(M[A])
        {
            cout<<"Yes";
            return 0;
        }
    }

    cout<<"No";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    while(1)
    {
        int tp=0;
    string ss[5]={"Danil", "Olya", "Slava", "Ann", "Nikita"},s;
    cin>>s;
    for(int i=0;i<5;i++)
    {
        int p=s.find(ss[i]);
        if(p>=0)
        {
            tp++;
            s[p]='x';
            for(int j=0;j<5;j++)
            {
                int p=s.find(ss[j]);
                if((p>=0)||tp>1){cout<<"NO"<<endl;return 0;}
            }
        }
    }
    (tp)?cout<<"YES"<<endl:cout<<"NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000000;
map<pair<int, int>, int> cache;
map<pair<int, int>, bool> is_cached;
int query(int x, int y){
    if(is_cached[{x, y}]) return cache[{x, y}];
    printf("0 %d %d\n", x, y);
    fflush(stdout);
    int d;
    scanf("%d", &d);
    is_cached[{x, y}] = true;
    cache[{x, y}] = d;
    return d;
}
vector<int> queries;
void solve(int lo, int hi){
    //printf("Solving %d - %d\n", lo, hi);
    int md = (lo + hi) / 2;
    int q = query(md, md);
    if(q == (md - lo)){
        if(md + q < hi){
            int p = query(md + q, md + q);
            if(p == 0) {
                //printf("Inserting %d\n", p);
                queries.push_back(p);
            }
        }
        return;
    }
    int pos1 = md - q;
    int p = query(pos1, pos1);
    int found = pos1;
    if(p) found = md + q;
    //printf("Inserting %d\n", found);
    queries.push_back(found);
    solve(lo, found);
    solve(found, hi);
}
int find_none(vector<int> a){
    if(a[0] != -MAX) return -MAX;
    int i = 1;
    for(; i < a.size(); i++){
        if(a[i] != a[i - 1] + 1) break;
    }
    return a[i - 1] + 1;
}
vector<int> vertical, horizontal;
void resolve(vector<int> pts){
    int none = find_none(pts);
    for(auto p : pts){
        int q1 = query(none, p);
        if(q1 == 0) horizontal.push_back(p);
        int q2 = query(p, none);
        if(q2 == 0) vertical.push_back(p);
    }
    printf("1 %d %d\n", vertical.size(), horizontal.size());
    for(auto x : vertical) printf("%d ", x); printf("\n");
    for(auto y : horizontal) printf("%d ", y); printf("\n");
}
int main(){
    int lo = query(-MAX, -MAX) - MAX;
    int hi = MAX - query(MAX, MAX);
    queries.push_back(lo);
    queries.push_back(hi);
    solve(lo, hi);
    sort(queries.begin(), queries.end());
    queries.resize(unique(queries.begin(), queries.end()) - queries.begin());
    resolve(queries);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[100100],n,ans,temp,k,res,temp1;
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>temp1;
        ans+=temp1;
    }
    cout<<(2*k-1)*n-2*ans<<endl;
return 0;
}


#include <cstdio>
#include <vector>

int main()
{
    int x, y, i;
    std::vector <int>a;
    scanf("%d %d", &x, &y);
    if (x>y) i=1; else i=-1;
    while (x!=y) {
        int j;
        if (x>y) {
            j=x/y;
            x%=y;
            if (x==0) { x++; j--; }
        } else {
            j=y/x;
            y%=x;
            if (y==0) { y++; j--; }
        }
        a.push_back(j);
    }
    if (x!=1) printf ("Impossible");
    else for (int j=0; j<a.size(); j++) {
        if (i==1) printf ("%dA", a[j]);
        else printf ("%dB", a[j]);
        i=-i;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int dp[510][510][40];
int bl(int l,int r)
{
 if (l>r) return 0;
 int mi=1e9;
 for (int i=0;i<26;i++)
  mi=min(mi,dp[l][r][i]);
 return mi;
}
int main()
{
 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout);
 ios_base::sync_with_stdio(0);
 int n;string st,s="";
 cin>>n;
 cin>>st;
 s+='1';
 s+=st[0];
 for (int i=1;i<st.size();i++)
   if (st[i]!=st[i-1]) s+=st[i];
   n=s.size()-1;
 for (int i=1;i<=501;i++)
  for (int j=1;j<=501;j++)
   for (int bu=0;bu<30;bu++)
   dp[i][j][bu]=1e9;
 for (int i=n;i>=1;i--)
  {
   dp[i][i][s[i]-'a']=1;
   //cout<<i<<' '<<s[i]<<endl;
   for (int j=i+1;j<=n;j++)
    {
     for (int bu=0;bu<26;bu++)
       { int tecsum=0,l=i,r=i+1,fl=0;
        for (int tec=i;tec<=j;tec++)
         {
         if ((s[tec]-'a')==bu) {fl=1;
            if (tec!=i) tecsum+=bl(l,r-1);
            //cout<<i<<' '<<j<<' '<<bu<<' '<<tec<<' '<<tecsum<<' '<<bl(tec+1,n)<<' '<<l<<' '<<r<<endl;
            dp[i][j][bu]=min(dp[i][j][bu],tecsum+bl(tec+1,n)+1);
            l=tec+1;r=tec+1;
         }  else{
            r++;
         }
        }
       //cout<<l<<' '<<r<<endl;
       if (fl==1){
       if (r-1<=j)tecsum+=bl(l,r-1);
       dp[i][j][bu]=min(dp[i][j][bu],tecsum+1);
       }
       //cout<<i<<' '<<j<<' '<<bu<<' '<<dp[i][j][bu]<<endl;
       //cout<<i<<' '<<j<<' '<<bu<<' '<<dp[i][j][bu]<<endl;
      }
    }
  }
 cout<<bl(1,n);
}


/*****************************************************
*#*##################################################*                                                  *
*#****************************************************                                                  *
*#*       URI:          sabujbd,                   *#*
*#*       UVA:          sabuj_coder.               *#*
*#*       LIGHTOJ:      return_SS,                 *#*
*#*       DEVSKILL:     return_SS                  *#*
*#*       CODEFORCES:   return_SS                  *#*
*#*       TIMUS:        return_SS                  *#*
*#*       CODEMARSHAL:  return_SS                  *#*
*#*       HACKERRANK    return_SSP                 *#*
*#*                                                *#*
*#*                                                *#*
*#*          Sabuj sarker                          *#*
*#*          def: CSE;                             *#*
*#*    Daffodil International University           *#*
*#*                                                *#*
*#*                                                *#*
*****************************************************
*####################################################
*****************************************************/
#include<bits/stdc++.h>
using namespace std;
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
typedef      string                  S;
typedef      long long               ll;
typedef      long long int           lli;
typedef      unsigned int            ui ;
typedef      unsigned long long int  ulli;
typedef      double                  D;
typedef      float                   f;
typedef      int                     I;
#define      Clear(a) memset( a, 0, sizeof(a))
#define      sc     scanf
#define      pf     printf
#define      cn     cin
#define      ct     cout
#define      en     endl
#define      pb     push_back
#define      pp     pop_back
#define      t_r     true
#define      f_r     false
#define      PI    a(cos)
#define      FOR(i , x, y ) for(  i = (x); i<=(y); i++ )
#define      ROR(i , x, y ) for(  i = (x); i>=(y); i-- )
#define      N 100000
int prime[N];

int fibonacci( int n )
{
    if(n<=1)return n;
    else return fibonacci(n-1)+fibonacci(n-2);
}
int GCD( int a, int b){
    if(b==0) return a;else return GCD(b,a%b);
}
int LCM( int a, int b)
{
    return b = (a*b)/GCD(a,b);
}
void  permutation(string ss)
{sort(ss.begin(),ss.end());
    do{cout<<ss<<endl;}while(next_permutation(ss.begin(),ss.end()));}

I Bigmod( I b , lli p, I m )
{if( p== 0 ){return 1;}
    if( p % 2 == 0 )
    {lli re = Bigmod( b, p/2, m );return ( re*re )%m;}
    else if( p%2 == 1 ){lli p1 = b%m;lli p2 = Bigmod( b, p-1, m );return ( p1 * p2 )%m;}}

void Sieve_of_Eratosthenes()
{   for( int i = 2; i<=N; i++){prime[i] = 1;}
    prime[0] = prime[1] = 0;
    int root = sqrt(N);
    for( int i = 2; i<=root; i++ ){
    for( int j = i*i; j<=N; j+=i ){if(prime[j]){prime[j] = 0;}}}}

 bool  perfect_squre_check( long long  number)
 {
     if( number ==1 || number ==-1 ){return false;}
     else{bool flag = false;bool flag2 = false;
     if( number < 0 ){number = (-1)*number;flag = true;}
     for( long long  i = 1; i<= sqrt(number); i++ ){
          if( i*i == number ){flag2 = true;break;}if( i*i > number ){break;}}
     if( flag == true ){if( flag2 == true ){return true;}else{return false;}}
     else{if(flag2 == true){return true;}
        else{return false;}}}
 }
 int nCr_recurtion( int n , int r )
 {
     if( r==0||r==n)return 1;
     else return nCr_recurtion(n-1,r-1)+nCr_recurtion(n-1,r);
 }
 int nCr_n_complex( int n , int r)
{
    int nr = (n-r);
    int a_n[n],a_r[r],a_nr[nr];
    for( int i = 1; i<=n; i++ )  a_n[i] = i;
    for( int j = 1; j<=r; j++ )  a_r[j] = j;
    for( int k = 1; k<=nr;k++ )  a_nr[k] = k;
    for( int i = 2; i<=nr; i++ ){
        for( int j = 2; j<=n; j++ ){
            if( a_n[j]%a_nr[i]== 0 && (a_n[j]!=1 && a_nr[i]!=1) ){
                if(a_n[j] == a_nr[i]){a_n[j] = 1;a_nr[i] = 1;}
                else{a_n[j] = a_n[j]/a_nr[i];a_nr[i] = 1;}}}}
   for( int i = 2; i<=r; i++ ){
        for( int j = 2; j<=n; j++ ){
            if( a_n[j]%a_r[i]== 0 && (a_n[j]!=1 && a_r[i]!=1) ){
                    if(a_n[j] == a_r[i]){a_n[j] = 1;a_r[i] = 1;
                }
                else{a_n[j] = a_n[j]/a_r[i];a_r[i] = 1;}}}}
    int mul1 = 1;int mul2 = 1;int mul3 = 1;
    for( int i = 2; i<=n; i++ )mul1 = mul1*a_n[i];
    for( int j = 2; j<=nr; j++ )mul2 = mul2*a_nr[j];
    for( int k = 2; k<=r; k++ )mul3 = mul3*a_r[k];
    return mul1*mul2*mul3;

}
int  main()
{
    stack<char>ch;
    int t_c;
    string s;
    cin>>t_c;
    cin>>s;
    string gg = "";
    for( int i = 0; i<s.size(); i++ ){
        if( s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y'){
            if(ch.empty()){
                    char xx = s[i];
                    gg += xx;
                ch.push(xx);
            }
        }
        else{
            gg += s[i];
        }

    }
    cout<<gg<<endl;
    main();
    return 0;
}


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

int n;
int a[2100];
int ans=0;
int len;

int fac(int n)
{
    if(n==0) return 1;
    else return n*fac(n-1);
}

int main()
{
    cin>>n;
    len=1;
    for(int i=1;i<n;i++)
    {
        ans+=len*fac(n-i)/fac(n-i-1);
        len++;
    }
    cout<<ans+n<<endl;
    return 0;
}


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

#define ll long long
#define debug(x) cerr << fixed << #x << " is " << x << endl;

int hist[10];
ll dp[20][2][524290][2];
vector<int> dig;

pair<bool, int> isok(int mask, int digit)
{
	int cnt = 0;
	for(int i = 0; i < 10; i++)
	{
		for(int j = 0; j < hist[i]; j++)
		{
			if(i == digit && (mask & (1 << cnt)))
				return {true, mask & (~(1 << cnt))};
			cnt++;
		}
		if(i == digit)
			return {false, 0};
	}
	return {false, 0};
}

ll solved(int mask)
{
	int cnt = 0;
	bool ok2 = true;
	for(int i = 0; i < 10; i++)
	{
		bool ok = 0;
		for(int j = 0; j < hist[i]; j++)
		{
			ok |= (mask & (1 << cnt)) == 0;
			cnt++;
		}
		if(hist[i] != 0)
			ok2 &= ok;
	}
	return (ll) ok2;
}

ll dp_solve(int idx, bool lim, int mask, bool zero)
{
	if(idx == -1)
		return solved(mask);

	if(dp[idx][lim][mask][zero] != -1)
		return dp[idx][lim][mask][zero];

	ll ans = 0;
	int limit = lim ? 9 : dig[idx];
	for(int i = 0; i <= limit; i++)
	{
		auto x = isok(mask, i);
		if(i == 0 && zero == true)
			ans += dp_solve(idx-1, lim || i < dig[idx], mask, true);
		else if(x.first)
			ans += dp_solve(idx-1, lim || i < dig[idx], x.second, false);
	}

	return dp[idx][lim][mask][zero] = ans;
}

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

	ll n;
	cin >> n;
	while(n)
	{
		hist[n % 10]++;
		n /= 10;
	}
	for(int i = 0; i < 20; i++)
		dig.push_back(9);
	int cnt = 0, mask = 0;
	for(int i = 0; i < 10; i++)
		for(int j = 0; j < hist[i]; j++)
		{
			mask |= 1 << cnt;
			cnt++;
		}

	memset(dp, -1, sizeof dp);
	cout << dp_solve((int) dig.size()-1, 0, mask, 1) << endl;

	return 0;
}
//0228
//1111 -> 1011 (11 = 1+2+8)


#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define INF 0x3f3f3f3f
#define Mn 510
#define Mm 2000005
#define mod 1000000007
#define CLR(a,b) memset((a),(b),sizeof((a)))
#define CLRS(a,b,Size) memset((a),(b),sizeof((a[0]))*(Size+1))
#define CPY(a,b) memcpy ((a), (b), sizeof((a)))
#pragma comment(linker, "/STACK:102400000,102400000")
#define ul u<<1
#define ur (u<<1)|1
using namespace std;
typedef long long ll;
int g[Mn][Mn];
int numb[Mn][Mn];
int num[Mn*Mn];
int cnt=0,n;
int mini,minj;
int maxi,maxj;
int way[4][2]={0,1,1,0,-1,0,0,-1};
int vis[Mn*Mn];
void dfs(int x,int y) {
    g[x][y]=cnt;
    num[cnt]++;
    mini=min(mini,x); minj=min(minj,y);
    maxi=max(maxi,x);maxj=max(maxj,y);
    for(int i=0;i<4;i++) {
        int a=x+way[i][0];
        int b=y+way[i][1];
        if(a<1||b<1||a>n||b>n||g[a][b]!=-1) continue;
        dfs(a,b);
    }
}
int main() {
    int k;
    char s[510];
    scanf("%d%d",&n,&k);
    getchar();
    for(int i=1;i<=n;i++) {
        scanf("%s",s);
        for(int j=1;j<=n;j++) {
            if(s[j-1]=='.') g[i][j]=-1;
            else {
                g[i][j]=0;
                numb[i][j]+=1;numb[i+k][j]-=1;
                numb[i][j+k]-=1;numb[i+k][j+k]+=1;
            }
        }
    }
    cnt=0;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) {
            if(g[i][j]==-1) {
                cnt++;mini=i,minj=j,maxi=i,maxj=j;
                dfs(i,j);
                if(maxi-mini+1<=k&&maxj-minj+1<=k) {
                    numb[maxi][maxj]+=num[cnt];numb[maxi][minj+k]-=num[cnt];
                    numb[mini+k][maxj]-=num[cnt];numb[mini+k][minj+k]+=num[cnt];
                }
            }
        }
    }
     for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) {
            numb[i][j]+=numb[i-1][j]+numb[i][j-1]-numb[i-1][j-1];
            //cout<<numb[i][j]<<" ";
        }
       //cout<<endl;
    }
    int ans=0;
    int xi,xj;
    for(int i=k;i<=n;i++) {
        for(int j=k;j<=n;j++) {
            int re=0;
            for(int p=j-k+1;p<=j;p++)  {
                if(!vis[g[i-k][p]])vis[g[i-k][p]]=1,re+=num[g[i-k][p]];
                if(!vis[g[i+1][p]])vis[g[i+1][p]]=1,re+=num[g[i+1][p]];
            }
            for(int p=i-k+1;p<=i;p++) {
                if(!vis[g[p][j-k]]) vis[g[p][j-k]]=1,re+=num[g[p][j-k]];
                if(!vis[g[p][j+1]]) vis[g[p][j+1]]=1,re+=num[g[p][j+1]];
            }
            ans=max(ans,re+numb[i][j]);
            for(int p=j-k+1;p<=j;p++)vis[g[i-k][p]]=0,vis[g[i+1][p]]=0;
            for(int p=i-k+1;p<=i;p++)vis[g[p][j-k]]=0,vis[g[p][j+1]]=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
int kkksc03,x,mmax;
int AK,IOI,NOIP=-1000;
int main() {
	cin>>AK;
	while(AK!=0) {
		cin>>IOI;
		NOIP=max(NOIP,IOI);
	}
	if (mmax<25) {
		cout<<"0"<<endl;
		return 0;
	}
	cout<<NOIP-25;
	return 0;
}


#include <iostream>
using namespace std;
bool check1(char a[8][8], int i);
bool check2(char a[8][8], int i);
int main()
{
    char a[8][8];
    int i=0,j=0,boo=0;
    for (i=0;i<8;i++)
        for (j=0;j<8;j++) cin>>a[i][j];
    i=0;j=0;
    while (i<8)
    {
        if (check1(a,i)==false||check2(a,i)==false)
        {
            boo=1;
            break;
        }
        else i++;
    }
    if (boo==1) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

bool check1 (char a[8][8] , int i)
{
    int j=0;
    while (j<8)
        {if (a[i][0]!=a[i][j]) return false;
            else j=j+2;
            }
    return true;
}

bool check2 (char a[8][8] , int i)
{
    int j=1;
    while (j<8)
        {
            if (a[i][1]!=a[i][j]) return false;
            else j=j+2;
        }
    return true;
}


#include <bits/stdc++.h>
#define ff first
#define ss second

using namespace std ;

long double PI = 3.14159265 ;
const int N = 2e6 + 1000 ;
long long int mn=N , ans , ans1 , cnt , fin;
long long int n , m , h , k , x , t1 , t2;
pair <long long int , long long int> p[N];
long long int a[N] ;
long long int b[N] ;
long long int c[N] ;
vector <int> v[N] ;
string s[N] , t ;
bool bb , vis[N] ;
char cc ;

int main (){
	ios::sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	cin >> n >> k >> m ;
	for(int i =1 - k ; i <= 0 ; i++){
		a[i + k] = i ;
	}
	for(int i =  1 ; i <= k ; i++){
		a[i] += m ;
	}
	for(int i = 1 ; i <= k ; i++){
		if(a[i] > 0 && a[i] <= n){
			ans++ ;
		}
	}
	cout << ans ;
	return 0 ;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
	int A, B, C, N;
	scanf("%d%d%d%d", &A, &B, &C, &N);
	int x = N-(A+B-C);
	if (C > A || C > B || x <= 0) {
		printf("-1");
		return 0;
	}
	printf("%d", x);
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>>

#include <vector>
#include <string>
#include <set>
#include <map>

#include <queue>
#include <stack>

using namespace std;

#define ABS(a) (((a) < (0)) ? (-(a)) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))

#define PI 3.14159265

#define INF 1000000000

typedef long long int lint;

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

	int n;
	cin >> n;
	cout << (n + 5) / 10 << '0';

	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <limits>
#include <iomanip>
#include <queue>
#include <locale>
#include <deque>
#include <cmath>
#include <stack>
#include <sstream>
#include <iterator>
#include <fstream>
#include <cstdlib>

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;

long long ans;

long long sobr(vector<int> x){
    long long ans = 0;
    for(int i = 0; i < x.size(); i++){
        ans *= 10;
        ans += x[i];
    }
    return ans;
}

vector<int> razl(long long x){
    vector<int > v;
    while(x > 0){
        v.push_back(x % 10);
        x /= 10;
    }
    return v;
}

void per(int p, vector<int> v){
    if(p == v.size()){
        if(!v.empty() && v[0] == 0)
            return;
        long long x = sobr(v);
        if(razl(x).size() == v.size()){
            ans = min(ans, x);
        }
        return;
    }
    per(p+1, v);
    v[p] = 9-v[p];
    per(p+1, v);
}

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

    long long x;
    cin >> x;
    ans = x;

    vector<int> v = razl(x);

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

    for(int i = 0; i < v.size(); i++){
        int inv = 9-v[i];
        if(inv == 0 && (i == 0 || v[i-1] == 0)) continue;
        if(inv < v[i])
            v[i] = inv;
    }

    for(int i = 0; i < v.size(); i++){
        cout << v[i];
    }

}


    // In the name of Allah
    // There is no power but from God the Almighty
   // No God except Allah
   #include <bits/stdc++.h>
   #define mp make_pair
   #define f1 first
   #define f2 second
   #define pb push_back
   #define pii pair<int ,int>
   #define ios  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   #define int long long
   using namespace std;
   const int mox=5e3+9;
    int dp[mox][mox];
    int td[mox*mox];
    int mod=1e9+7;
   int32_t main()
   {
         ios
         int n,k;
         cin>>n>>k;
         td[0]=1;
         for(int i=1 ; i<=(n*n) ; i++)
         {
           td[i]=(td[i-1]*2)%mod;
         }
         for(int i=0 ; i<=n ; i++)
         {
             dp[i][0]=1;
         }
         for(int i=1 ; i<=n ; i++)
         {
           for(int j=1 ; j<=k ; j++)
           {
               for(int w=1 ; w<=i ; w++)
               {
             int x=(td[(w*(i-w+1))]-(td[((w-1)*(i-w+1))])+mod)%mod;
                  x=(x*dp[w-1][j-1])%mod;
                   dp[i][j]=(dp[i][j]+x)%mod;
               }
           }
         }
         cout<<dp[n][k];
   }


#include <bits/stdc++.h>
using namespace std;
long long n,k;
long long dp(long long cur){
    if (cur>n) return 0;
    long long ans=1;
    ans+=dp(cur*2);
    if (cur%2==0) ans+=dp(cur+1);
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    long long maxi=1;
    while (maxi<n) maxi*=2;
    while (dp(maxi/2)<k){
        maxi/=2;
    }
    while (dp(maxi)<k) maxi--;
    cout<<maxi;
}


#include<stdio.h>
#include<stdlib.h>
int main(void)
{
    int n, a[1000] = {0}, b[1000] = {0};
    int i, k, count, check = 1;

    scanf("%d", &n);
    for ( i = 0, k = 1, count = 1; check == 1; i++, count++ ){
        a[(i+k)%n] = 1;
        k += i+1;
        if ( count % n == 0 ){
            b[i]++;
            if ( b[i] >= 2 )
                break;
        }
    }
    for ( i = 0; i < n; i++ )
        if ( a[i] == 0 )
            check = 0;

    if ( check == 1 )
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}


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

typedef long long ll;

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

int main()
{

	ll a,b,x,y;

	cin >> a >> b >> x >> y;

	ll g = gcd(x, y);
	x /= g; y /= g;

	ll ans = min(a / x, b / y);

	cout << ans;

	return 0;

}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,l,s;
    cin>>m>>n;
    int k=1;
    while(k)
    {
    if(m%2!=0)
    {
       l=m/2;
       s=(l*n)+n/2;
       cout<<s;
       k=0;
    }
    if(n%2!=0)
    {
        l=n/2;
        s=(l*m)+m/2;
        cout<<s;
        k=0;
    }
    }
    return 0;
    }


#include <iostream>
#include <algorithm>
#include <conio.h>
#include <cmath>
using namespace std;

int main ()
 { long int n,i,a[7],s=0,k;
   cin>>n;
   for (i=0;i<7;i++) {cin>>a[i]; s+=a[i];}
      n=n%s;
      if (n==0) {for (i=6;i>=0;i--) if  (a[i]>0) {cout<<i+1; break;}}
      else {
   for (i=0;i<7;i++) {n-=a[i];k=i; if (n<0) break;}
    cout<<k+1;}
    getch();
    return 0;
         }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1000000007, ai[105], bi[105], ci[105], di[105], n, m;
ll memo[14][2010][2010];
ll fac(ll n)
{
	ll i, prod=1;
	for(i=1;i<=n;i++)
		prod=((i%mod)*(prod%mod))%mod;
	return prod;
}
ll power(ll x, ll y, ll p)
{
	ll res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res*x) % p;
		y = y>>1; // y = y/2
		x = (x*x) % p;
	}
	return res;
}
ll gcd(ll a, ll b)
{
	if (a == 0 || b == 0)
		return 0;
	if (a == b)
		return a;
	if (a > b)
		return gcd(a-b, b);
	return gcd(a, b-a);
}
ll dp(ll i, ll tempdo, ll tempstuf)
{
	//printf("i:%lld and tempdo:%lld and tempstuf:%lld\n",i,tempdo,tempstuf);
	if(i>m+1)
		return 0;
	if(tempdo>=n)
		return 0;

	if(tempstuf+bi[i]<=ai[i] && tempdo+ci[i]<=n)
	{
		if(memo[i+1][tempdo][0]==-57)
			memo[i+1][tempdo][0]=dp(i+1,tempdo,0);
		if(memo[i][tempdo+ci[i]][tempstuf+bi[i]]==-57)
			memo[i][tempdo+ci[i]][tempstuf+bi[i]]=dp(i,tempdo+ci[i],tempstuf+bi[i]);
		memo[i][tempdo][tempstuf]=max(memo[i+1][tempdo][0],di[i]+memo[i][tempdo+ci[i]][tempstuf+bi[i]]);
		//return max(dp(i+1,tempdo,0),di[i]+dp(i,tempdo+ci[i],tempstuf+bi[i]));
	}
	else
	{
		if(memo[i+1][tempdo][0]==-57)
			memo[i+1][tempdo][0]=dp(i+1,tempdo,0);
		memo[i][tempdo][tempstuf]=memo[i+1][tempdo][0];
	//	return dp(i+1,tempdo,0);
	}
	return memo[i][tempdo][tempstuf];
}
int main()
{
	ll x, y, i, j, k, num, temp, fn, cnt=0, d, l, r, flag=0, sum1=0, a, b, len1=0, t, c0, d0;
	cin >> n >> m >> c0 >> d0;
	for(i=1;i<=m;i++)
		cin >> ai[i] >> bi[i] >> ci[i] >> di[i];
	ai[i]=n;bi[i]=0;ci[i]=c0;di[i]=d0;
	for(i=0;i<14;i++)
		for(j=0;j<2010;j++)
			for(l=0;l<2010;l++)
				memo[i][j][l]=-57;
	printf("%lld\n",dp(1,0,0));
	return 0;
}


#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long llint;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

struct Position {
  llint t, x, q, p;
  friend bool operator < (const Position &a, const Position &b) {
    return a.q < b.q;
  }
};

int parity(llint x) {
  return abs(x) % 2;
}

llint ceil(llint a, llint b);
llint floor(llint a, llint b);

llint floor(llint a, llint b) {
  assert(b > 0);
  if (a < 0) return -ceil(-a, b);
  return a/b;
}

llint ceil(llint a, llint b) {
  assert(b > 0);
  if (a < 0) return -floor(-a, b);
  return (a+b-1) / b;
}

void no_solution() {
  puts("NO");
  exit(0);
}

void solve(vector<Position> &v, int m, vector<int> &ans) {
  sort(v.begin(), v.end());
  v.insert(v.begin(), {0, 0, 0, 0});
  v.push_back({-m, 0LL, m, -1});

  llint lo = -m, hi = +m;
  for (int i = 1; i < (int)v.size(); ++i) {
    llint d = v[i].q - v[i - 1].q;
    llint k = v[i].p - v[i - 1].p;
    llint x = v[i].x - v[i - 1].x;

    if (parity(x - k*(m%2)) != parity(d)) no_solution();

    if (k == 0) {
      if (abs(x) > d) no_solution();
      continue;
    }

    if (k > 0) {
      lo = max(lo, ceil(x-d, k));
      hi = min(hi, floor(x+d, k));
    } else {
      lo = max(lo, ceil(-d-x, -k));
      hi = min(hi, floor(d-x, -k));
    }
  }

  if (parity(lo) != parity(m)) lo++;
  if (parity(hi) != parity(m)) hi--;

  if (lo > hi) no_solution();

  llint bal = lo;

  for (int i = 1; i < (int)v.size(); ++i) {
    llint d = v[i].q - v[i - 1].q;
    llint k = v[i].p - v[i - 1].p;
    llint x = v[i].x - v[i - 1].x;

    llint sum = x - k * bal;
    assert(parity(sum) == parity(d));
    assert(abs(sum) <= d);

    while (sum) {
      if (sum > 0) ans.push_back(+1), sum--; else
	ans.push_back(-1), sum++;
      d--;
    }

    assert(d%2 == 0);
    while (d > 0) {
      ans.push_back(+1);
      ans.push_back(-1);
    }
  }

  assert((int)ans.size() == m);
}

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

  static vector<Position> px, py;
  REP(i, n) {
    llint t, x, y;
    scanf("%lld %lld %lld", &t, &x, &y);
    px.push_back({t, x + y, t % m, t / m});
    py.push_back({t, x - y, t % m, t / m});
  }

  static vector<int> ansx, ansy;
  solve(px, m, ansx);
  solve(py, m, ansy);

  REP(i, m) {
    int dx = (ansx[i] + ansy[i]) / 2;
    int dy = (ansx[i] - ansy[i]) / 2;

    if (dx == +1 && dy == 0) putchar('R'); else
      if (dx == -1 && dy == 0) putchar('L'); else
	if (dx == 0 && dy == -1) putchar('D'); else
	  if (dx == 0 && dy == +1) putchar('U'); else
	    assert(false);
  }
  putchar('\n');
  return 0;
}


#include <bits/stdc++.h>
#define ll             long long
#define f(i,a,b)       for(int i=(a);i<(b);i++)
#define fd(i,a,b)      for(ll i=(a);i>(b);i--)
#define x              first
#define y              second
#define si(a)          scanf("%d",&a)
#define sii(a,b)       scanf("%d %d",&a,&b)
#define siii(a,b,c)    scanf("%d %d %d",&a,&b,&c)
#define sl(a)          scanf("%I64d",&a)
#define sll(a,b)       scanf("%I64d %I64d",&a,&b)
#define slll(a,b,c)    scanf("%I64d %I64d %I64d",&a,&b,&c);
#define pfci(n,ans)    printf("Case %I64d: %d\n",n,ans)
#define pfcl(n,ans)    printf("Case %I64d: %I64d\n",n,ans)
#define pfcd(n,ans)    printf("Case %I64d: %lf\n",n,ans)
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define MOD 1000000009
#define ld long double
#define mp make_pair
using namespace std;
#define INF 1e12
#define EPS 1e-12
//#define double long double
#define PI 3.141592653589

ll n,m,k;
vector<int>pwt;

bool check( ll X)
{
    if((X*k)>n) return false;
    ll rem = n- (X*k);
    ll cnt = X*k + (rem/k)*(k-1) +(rem%k);
    if(cnt<m) return false;

    return true;
}

void pw(ll xx)
{
    pwt.pb(1);
    ll base =1;
    for(ll i=1;i<=xx;i++)
    {
        base*=2;
        //cout<<base<<" ";
        base=base%MOD;
        pwt.pb(base);
    }

}

int main()
{
    cin>>n>>m>>k;
    ll l=0;
    ll h=(m/k);
    pw(m/k+1);
    ll ans= k*(pwt[m/k])+(m%k);
    while(l<=h)
    {
        ll mid=(l+h)/2;
        if(check(mid))
        {
            ans = (pwt[mid+1] -2)*k + m-(mid*k);

            h=mid-1;
        }
        else l=mid+1;
    }
    ans = ans % MOD;
    cout<<ans<<endl;

}


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

int main() {
     freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int g,d,max=0;
    cin >> g >> d;
    if (d>=g) {
        for ( int  i=1; i<=d; i++) {
            if (d%i==0&&g%i==0) {
                max =i;
            }

        }
    } else {
        for ( int y=1; y<=g; y++) {
            if (d%y==0&&g%y==0) {
                max =y;
            }

        }
    }
    cout << max;
    return 0;
}


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

void main(){
	long long t, s, x;
	cin >> t >> s >> x;
	vector<long long>v;

	if (x == t){
		cout << "YES";
		return;
	}
	int i = 1;
	while (true){
		v.push_back(t + i*s);
		v.push_back( t + i*s + 1);

		if (x <= t+i*s){

			break;
		}
		i++;
	}

	for (int i = 0; i < v.size(); i++){
		if (x == v.at(i)){
			cout << "YES";
			return;
		}
	}

	cout << "NO";
}


#include<iostream>
#include<conio.h>
#include<cctype>
using namespace std;

unsigned long long ncr(int n,int r)
{
	unsigned long long tmp=1;

	if(r==0)return 1;

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

	return tmp;
}

int main()
{
	int n,m,t;

	cin>>n>>m>>t;

	unsigned long long res=ncr(n,4)*m*ncr(n+m-5,t-5);

	cout<<res;

	getch();
	return 0;
}