#include<stdio.h>
#include<stdlib.h>
#include<string.h>
long long arr[2000001],brr[2000001],mod=1000000000+7;
char str[2000001],s1[2000001];
int func(const void *a, const void *b)
{
	return (*(int*)a-*(int*)b);
}
long long max(long long a, long long b)
{
	return (a>b)?a:b;
}
long long min(long long a, long long b)
{
	return (a>b)?b:a;
}
long long power(long long  x, long long  int y, long long p)
{
	long long int 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;
}
long long bs(long long l, long long r, long long n, long long m)
{
	long long mid=l+((r-l)/2);
	if(l>=r)
	{
		if((mid+1)*2+(mid*(mid+1))/2>=(n-m-1))
			return mid;
		else
			return mid+1;
	}
	if((mid+1)*2 + (mid*(mid+1))/2==(n-m-1))
		return mid;
	if((mid+1)*2 + (mid*(mid+1))/2>(n-m-1))
			return bs(l,mid-1,n,m);
	if((mid+1)*2 + (mid*(mid+1))/2 < (n-m-1))
		return bs(mid+1,r,n,m);
}

int main()
{
	long long int sum=0,a,b,x,y,n, m,temp,flag=0,index,len, i, j, k, count=0, ans=0;
	scanf("%lld %lld", &n, &m);
	if(n==1)
	{printf("1\n");return 0;}
	if(m+1>=n)
	{printf("%lld\n",n);return 0;}
	printf("%lld\n",m+1+bs(0,4000000005,n,m)+1);
	return 0;
}


#include <stdio.h>

#define N	50
#define T	2500
#define MD	1000000007

int dp[N + 1][N + 1][N + 1], dq[N + 1][N + 1][N + 1][3];

void init(int na, int nb, int nc) {
	int ma, mb, mc, x0, x1, x2;

	for (ma = 0; ma <= na; ma++)
		for (mb = 0; mb <= nb; mb++)
			for (mc = 0; mc <= nc; mc++) {
				x0 = ma > 0 ? (long long) dq[ma - 1][mb][mc][0] * ma % MD : 0;
				x1 = mb > 0 ? (long long) dq[ma][mb - 1][mc][1] * mb % MD : 0;
				x2 = mc > 0 ? (long long) dq[ma][mb][mc - 1][2] * mc % MD : 0;
				if (ma == 0 && mb == 0 && mc == 0) {
					dp[ma][mb][mc] = 1;
					dq[ma][mb][mc][0] = dq[ma][mb][mc][1] = dq[ma][mb][mc][2] = 1;
				} else {
					dp[ma][mb][mc] = ((long long) x0 + x1 + x2) % MD;
					dq[ma][mb][mc][0] = (x1 + x2) % MD;
					dq[ma][mb][mc][1] = (x0 + x2) % MD;
					dq[ma][mb][mc][2] = (x0 + x1) % MD;
				}
			}
}

void solve1(int *aa, int t, int n, int da[][N + 1]) {
	int i, s, m, a;

	for (s = 0; s <= t; s++)
		for (m = 0; m <= n; m++)
			da[0][0] = 0;
	da[0][0] = 1;
	for (i = 0; i < n; i++) {
		a = aa[i];
		for (s = t; s >= a; s--)
			for (m = 1; m <= n; m++)
				da[s][m] = (da[s][m] + da[s - a][m - 1]) % MD;
	}
}

void solve2(int *aa, int *bb, int t, int na, int nb, int dab[][N + 1][N + 1]) {
	static int da[T + 1][N + 1];
	int i, b, s, ma, mb;

	solve1(aa, t, na, da);
	for (s = 0; s <= t; s++)
		for (ma = 0; ma <= na; ma++) {
			dab[s][ma][0] = da[s][ma];
			for (mb = 1; mb <= nb; mb++)
				dab[s][ma][mb] = 0;
		}
	for (i = 0; i < nb; i++) {
		b = bb[i];
		for (s = t; s >= b; s--)
			for (ma = 0; ma <= na; ma++)
				for (mb = 1; mb <= nb; mb++)
					dab[s][ma][mb] = (dab[s][ma][mb] + dab[s - b][ma][mb - 1]) % MD;
	}
}

int main() {
	static int aa[N], bb[N], cc[N], dab[T + 1][N + 1][N + 1], dc[T + 1][N + 1];
	int n, na, nb, nc, t, tab, tc, ma, mb, mc, xab, xc, ans;

	scanf("%d%d", &n, &t);
	na = nb = nc = 0;
	while (n--) {
		int a, g;

		scanf("%d%d", &a, &g);
		if (g == 1)
			aa[na++] = a;
		else if (g == 2)
			bb[nb++] = a;
		else
			cc[nc++] = a;
	}
	init(na, nb, nc);
	solve1(cc, t, nc, dc);
	solve2(aa, bb, t, na, nb, dab);
	ans = 0;
	for (tab = 0; tab <= t; tab++) {
		tc = t - tab;
		for (ma = 0; ma <= na; ma++)
			for (mb = 0; mb <= nb; mb++)
				if ((xab = dab[tab][ma][mb]))
					for (mc = 0; mc <= nc; mc++)
						if ((xc = dc[tc][mc]))
							ans = (ans + (long long) xab * xc % MD * dp[ma][mb][mc]) % MD;
	}
	printf("%d\n", ans);
	return 0;
}


#define __USE_MINGW_ANSI_STDIO 0
#include <stdio.h>

// MODULAR NCR
// DEPENDENCIES:

// nCr % mod function
// Using Fermat's Little theorem: a^(p-2) = a^(-1) (mod p)

#define maxN 200000
#define MOD 1000000007
//#define MOD 998244353

// Build factorial array
long long fac[maxN + 1];
void __attribute__((constructor))
initFacs() {
	fac[0] = 1;
    for (int i = 1; i <= maxN; i++) fac[i] = fac[i - 1] * i % MOD;
}

// Calculate base ^ pow % mod
long long mPow(long long base, int pow) {
    long long res = 1;
    base %= MOD;
    // constantly decompose base ^ pow = (base ^ 2) ^ (pow / 2)
    while (pow > 0) {
        // make sure if it is odd, then base ^ pow = base ^ (pow - 1) * base
        if (pow % 2 == 1) res = res * base % MOD;
        pow /= 2;
        base = (base * base) % MOD;
    }
    return res;
}

// a ^ (p - 2) = a ^ (-1) (mod p)
long long mInv(long long n) {
    return mPow(n, MOD - 2);
}

// nCr = n! / r! / (n - r)!
// nCr = n! * inv(r!) * inv((n - r)!)
long long mnCr(long long n, int r) {
    // Base cases
    if (n < r) return 0;
    if (r == 0) return 1;

    return fac[n] * mInv(fac[r]) % MOD
           * mInv(fac[n - r]) % MOD;
}
// END MODULAR NCR

long long _T[maxN + 1];
long long _2n[maxN + 1];

void testcase() {
	int n, k;
	scanf("%d%d", &n, &k);
	long long T;
	long long ans;
	if (n % 2 == 1) {
		// n odd
		T = 1;
		for (int i = 0; i <= (n - 1) / 2; ++i) {
			T += mnCr(n, i);
			T %= MOD;
		}
		ans = 1;
		for (int i = 0; i < k; ++i) {
			ans *= T;
			ans %= MOD;
		}
	} else {
		// n even
		T = 0;
		for (int i = 0; i < n; i += 2) {
			T += mnCr(n, i);
			T %= MOD;
		}
		_T[0] = 1;
		long long base = mPow(2, n);
		_2n[0] = 1;
		for (int i = 1; i <= k; ++i) {
			_T[i] = _T[i - 1] * T % MOD;
			_2n[i] = _2n[i - 1] * base % MOD;
		}
		ans = _T[k] * _2n[0] % MOD;
		for (int i = k - 1; i >= 0; --i) {
			ans += _T[i] * _2n[k - 1 - i] % MOD;
			ans %= MOD;
		}
	}
	printf("%lld\n", ans);
    return;
}

int main() {
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; ++i) testcase();
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

#define N	200000
#define M	200000

void init_rand() {
	struct timeval tv;

	gettimeofday(&tv, NULL);
	srand(tv.tv_usec ^ tv.tv_sec);
}

int rand_(int n) {
	return (rand() * 45677LL + rand()) % n;
}

int kk[N], ll[N], tt[M], ii[M], jj[M];

int check(int n, int m, int t) {
	static int tt_[N];
	int i, j, b, x, t_;

	for (i = 0; i < n; i++) {
		ll[i] = kk[i];
		tt_[i] = -1;
	}
	for (j = 0; j < m && (t_ = tt[jj[j]]) <= t; j++)
		tt_[ii[jj[j]]] = t_;
	b = 0;
	for (j = 0; j < m && (t_ = tt[jj[j]]) <= t; j++)
		if (tt_[i = ii[jj[j]]] == t_) {
			x = ll[i] < t_ - b ? ll[i] : t_ - b;
			b += x, ll[i] -= x;
		}
	for (i = 0; i < n; i++)
		b += ll[i] * 2;
	return b <= t;
}

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return tt[i] - tt[j];
}

int main() {
	int n, m, i, j, lower, upper, t, tmp;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%d", &kk[i]);
	for (j = 0; j < m; j++) {
		scanf("%d%d", &tt[j], &ii[j]), ii[j]--;
		jj[j] = j;
	}
	init_rand();
	for (j = m - 1; j >= 0; j--) {
		i = rand_(j + 1);
		tmp = jj[i], jj[i] = jj[j], jj[j] = tmp;
	}
	qsort(jj, m, sizeof *jj, compare);
	lower = 0, upper = 200000 * 2;
	while (upper - lower > 1) {
		t = (lower + upper) / 2;
		if (check(n, m, t))
			upper = t;
		else
			lower = t;
	}
	printf("%d\n", upper);
	return 0;
}


#include <stdio.h>
#include <string.h>
void gogo(char a[], int j, int s, int r)
{
    for (int k = 0; k < r; k++)
        for (int i = j; i < s; i++)
        {
            a[i] = a[i + 1];
        }
}
int main(void)
{
    int s, counts = 0;
    char a[105] = {0};
    scanf("%d", &s);
    for (int i = 0; i < s; i++)
    {
        scanf(" %c", &a[i]);
    }
    for (int i = 'z'; i >= 'a'; i--)
    {
        for (int j = 0; j < strlen(a); j++)
        {
            int num = 0;
            if (a[j] == i)
            {
                if (a[j - 1] == i + 1)
                {
                    for (int k = j - 1; k >= 0; k--)
                    {
                        if (a[k] == a[j - 1])
                        {
                            num++;
                        }
                        else
                            break;
                    }
                    gogo(a, j - num, strlen(a), num);
                    counts += num;
                    if (num != 0)
                    {
                        j = 0;
                        num = 0;
                    }
                }
                if (a[j + 1] == i + 1)
                {
                    for (int k = j + 1; k < strlen(a); k++)
                    {
                        if (a[k] == a[j + 1])
                        {
                            num++;
                        }
                        else
                            break;
                    }
                    gogo(a, j + 1, strlen(a), num);
                    counts += num;
                    if (num != 0)
                    {
                        j = 0;
                        num = 0;
                    }
                }
            }
        }
    }
    printf("%d\n", counts);
}


n;
int main()
{
    while(~scanf("%d",&n))
    {
        puts((n&1)?"black":"white\n1 2");
    }
    return 0;
}


#include <stdio.h>

#define MAX 1000010

int p, primes[78777], flag[MAX];

void Sieve(){
    int i, j, d;

    flag[2] = 1;
    for (i = 3; i < MAX; i++, i++) flag[i] = 1;
    for (i = 3; i < 1001;){
        d = i << 1;
        for (j = (i * i); j < MAX; j += d) flag[j] = 0;
        do{
            i++;
        }while (!flag[++i]);
    }

    for (i = 0; i < MAX; i++){
        if (flag[i]) primes[p++] = i;
    }
}

int isPrime(long long x){
    int i;
    for (i = 0; ; i++){
        long long y = primes[i];
        if ((y * y) > x) return 1;
        if ((x % y) == 0) return 0;
    }
}

int F(int i, long long a){
    if (a == 1) return 1;
    long long y = primes[i];
    if ((y + 1) > a) return 0;

    if (((y * y) + 1) > a){
        if (isPrime(a - 1)) return 1;
        return 0;
    }

    long long x = 1;
    int res = F(i + 1, a);

    for (; ;){
        x *= y;
        if ((x + 1) > a) break;

        if ((a % (x + 1)) == 0) res = res + F(i + 1, a / (x + 1));
    }
    return res;
}

int Solve(long long a){
    if (a < 5) return (a != 2);
    return F(0, a);
}

int main(){
    Sieve();
    long long a;
    while (scanf("%I64d", &a) != EOF) printf("%d\n", Solve(a));
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define MAX 5010
#define MOD 1000000007
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

char S[MAX], T[MAX];
short next[MAX][MAX];
bool visited[MAX][MAX];
int n, m, dp[MAX][MAX];

int F(int i, int j){
    if (i >= n || j >= m) return 0;
    if (visited[i][j]) return dp[i][j];

    unsigned int res = 0;
    if (next[i][j] != -1){
        res = res + F(i + 1, next[i][j] + 1) + 1;
        if (res >= MOD) res -= MOD;
        res = res + F(i, next[i][j] + 1);
        if (res >= MOD) res -= MOD;
    }

    visited[i][j] = true;
    return (dp[i][j] = res);
}

int main(){
    int i, j, k;

    while (scanf("%s %s", S, T) != EOF){
        clr(visited);
        n = strlen(S), m = strlen(T);
        for (i = 0; i < n; i++){
            for (j = m - 1; j >= 0; j--){
                next[i][j] = -1;
                if (S[i] == T[j]) next[i][j] = j;
                else if ((j + 1) != m) next[i][j] = next[i][j + 1];
            }
        }

        long long res = 0;
        for (i = 0; i < n; i++){
            for (j = 0; j < m; j++){
                if (S[i] == T[j]){
                    res = res + F(i + 1, j + 1) + 1;
                }
            }
        }
        printf("%lld\n", res % MOD);
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i, j, n, m, x1, y1, x2, y2;

    scanf("%d %d %d %d %d %d", &n, &m, &x1, &y1, &x2, &y2);

    i = abs(x1 - x2);
    j = abs(y1 - y2);

    if (i > j) {
        int aux = i;
        i = j;
        j = aux;
    }

    if ((i <= 2 && j <= 4) || (i == 3 && j == 3)) {
        puts("First");
    } else {
        puts("Second");
    }

    return 0;
}


#include <stdio.h>

#define MD	1000000007
#define L	50
#define K	10000

long long dp[L + 1][L + 1];

void init(int k) {
	static long long dq[L + 1][L + 1];
	static int inv[L + 2];
	int i1, i2, i, j;

	for (i = 1; i <= L + 1; i++) {
		long long x = 1;

		while (x % i != 0)
			x += MD;
		inv[i] = x / i % MD;
	}
	for (i = 0; i <= L; i++)
		dp[i][i] = dq[i][i] = 1;
	for (i1 = 0; i1 <= L; i1++)
		for (i2 = i1 + 1; i2 <= L; i2++)
			dq[i1][i2] = (dq[i1][i2] + dq[i1][i2 - 1]) % MD;
	for (j = 1; j <= k; j++)
		for (i1 = 0; i1 <= L; i1++)
			for (i2 = i1; i2 <= L; i2++) {
				dq[i1][i2] = dp[i1][i2] = dq[i1][i2] * inv[i2 + 1] % MD;
				if (i2 > i1)
					dq[i1][i2] = (dq[i1][i2] + dq[i1][i2 - 1]) % MD;
			}
}

int solve(long long a, int cnt) {
	int i, sum;
	long long p;

	a %= MD;
	p = 1;
	sum = 0;
	for (i = 0; i <= cnt; i++) {
		sum = (sum + p * dp[i][cnt]) % MD;
		p = p * a % MD;
	}
	return sum;
}

int main() {
	long long n, ans;
	int k, a;

	scanf("%lld%d", &n, &k);
	init(k);
	ans = 1;
	for (a = 2; a <= n / a; a++)
		if (n % a == 0) {
			int cnt = 0;

			while (n % a == 0) {
				n /= a;
				cnt++;
			}
			ans = ans * solve(a, cnt) % MD;
		}
	if (n > 1)
		ans = ans * solve(n, 1) % MD;
	printf("%lld\n", ans);
	return 0;
}


#include <stdio.h>

const int di[] = {-1, -1, 0, 1, 1, 0, -1, 0};
const int dj[] = {0, 1, 1, 1, -1, -1, -1, 0};

char board[8][9];

int dfs(int i, int j, int turn) {
    int k;

    if (i == 0 && j == 7)
        return 1;

    for (k = 0; k < 8; k++) {
        int ni = i + di[k], nj = j + dj[k];

        if (ni >= 0 && ni < 8 && nj >= 0 && nj < 8 && (ni - turn < 0 || board[ni - turn][nj] != 'S' && (ni - turn - 1 < 0 || board[ni - turn - 1][nj] != 'S')))
            if (dfs(ni, nj, turn + 1))
                return 1;
    }

    return 0;
}

int main(void) {
    int i;

    for (i = 0; i < 8; i++)
        scanf("%s", board[i]);

    puts(dfs(7, 0, 0) ? "WIN" : "LOSE");

    return 0;
}


#include <stdio.h>
#include <inttypes.h>
#include <assert.h>

uint64_t fib[51];

void findperm(uint64_t n, uint64_t k, uint64_t offset){
  assert( k <= fib[n]);
  if (n == 0){
    puts("");
    return;
  }
  if (n == 1){
    printf("%llu\n", offset);
    return;
  }
  if ( k <= fib[n-1]){
    printf("%llu ", offset);
    findperm(n-1, k, offset+1);
  }
  else{
    printf("%llu %llu ", offset+1, offset);
    findperm(n-2, k -fib[n-1], offset+2);
  }
}

int main(void){
  uint64_t n, k;
  fib[0] = 1;
  fib[1] = 1;
  for (size_t k = 2; k <= 50; k++)
    fib[k] = fib[k-1]+fib[k-2];

  scanf("%llu %llu", &n, &k);
  findperm(n, k, 1);
  return 0;
}


#include <stdlib.h>
#include <stdio.h>

int main() {
	int n, m, d;
	scanf("%d%d", &n, &m);
	int dn = 1, dm = 1;
	for(int k = 7 ; k < n ; k *= 7) dn++;
	for(int k = 7 ; k < m ; k *= 7) dm++;
	d = dn + dm;
	if(d > 7) {
		printf("0\n");
		return 0;
	}
	int r = 0;
	for(int i=0 ; i<n ; i++) {
		for(int j=0 ; j<m ; j++) {
			int u[7] = {0};
			int a = i, b = j;
			for(int k=0 ; k<dn ; k++) {
				u[a%7]++;
				a /= 7;
			}
			for(int k=0 ; k<dm ; k++) {
				u[b%7]++;
				b /= 7;
			}
			r++;
			for(int k=0 ; k<7 ; k++) {
				if(u[k] > 1) {
					r--;
					break;
				}
			}
		}
	}
	printf("%d\n", r);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int n, m, a[11], b[11], c[11], d[11], A[1001][11];

int max (int i, int j) {
    if (i > j)
       return i;
    return j;
}

int vai (int massa, int posi) {
  int pode = 80000;
  int i, valor;

  if (posi <= m) {
     if (A[massa][posi] != -1) {
        return A[massa][posi];
     } else {
    if (posi != 0)
      pode =  a[posi] / b[posi];
    if (massa / c[posi] < pode)
      pode = massa / c[posi];

    valor = 0;
    for (i = 0; i <= pode; i++){
               valor = max (valor, vai (massa - i * c[posi], posi +1) + d[posi] * i);
    }
    A[massa][posi] = valor;
    return valor;
    }
  }
  else
    return 0;
}

int main () {

  int valor, i, j;

  for(i = 0; i < 1001; i++)
        for(j = 0; j < 11; j++)
              A[i][j] = -1;

  scanf("%d%d%d%d", &n, &m, &c[0], &d[0]);
  a[0] = 0;
  b[0] = 0;

  for(i = 1; i <= m; i++) {
    scanf("%d", &a[i]);
    scanf("%d", &b[i]);
    scanf("%d", &c[i]);
    scanf("%d", &d[i]);
  }

  valor = vai(n,0);

  printf("%d", valor);

  scanf("%d",i);

  return 0;

}


#include <stdio.h>

long long int GCD(long long int a,long long int b){
	if(b==0)return a;
	if(a==0)return b;
	if(a<b)return(GCD(a,b%a));
	else return(GCD(b,a%b));
}

long long int LCM(long long int a,long long int b){
	long long int c=GCD(a,b);
	return((a/c)*(b/c)*c);
}

int bfs(int i,int visited[],int count,int index,int A[]){
	if(i==index){
		if(count%2)return count;
		else return(count/2);
	}
	if(visited[i]==0){
		visited[i]=1;
		return(bfs(A[i],visited,count+1,index,A));
	}
	return(-1);
}

int main(){
	int i,n,A[105],cycle,visited[105];
	long long int ans;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
		A[i]--;
	}
	for(i=0;i<n;i++)visited[i]=0;
	ans=1;
	for(i=0;i<n;i++){
		if(visited[i]==0){
			visited[i]=1;
			cycle=bfs(A[i],visited,1,i,A);
			if(cycle==-1){
				ans=-1;
				break;
			}
			else ans=LCM(ans,(long long int)cycle);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


/* practice with Dukkha */
#include <stdio.h>

int max(int a, int b) { return a > b ? a : b; }

int count(int x1, int x2, int b) {
	if (x1 > x2)
		return count(x2, x1, b);
	if (x1 > 0)
		return x2 / b - x1 / b;
	if (x2 < 0)
		return -x1 / b - -x2 / b;
	return -x1 / b + x2 / b + 1;
}

int main() {
	int a, b, x1, y1, x2, y2, x, y;

	scanf("%d%d%d%d%d%d", &a, &b, &x1, &y1, &x2, &y2), a *= 2, b *= 2;
	x = x1 - y1, y = x1 + y1; x1 = x; y1 = y;
	x = x2 - y2, y = x2 + y2; x2 = x; y2 = y;
	printf("%d\n", max(count(x1, x2, b), count(y1, y2, a)));
	return 0;
}


#include<stdio.h>
int arr[101],no[101],l[100];
int main()
{
	int n,m,source,desti,temp,flag,k,i;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
	scanf("%d",&l[i]);
	for(i=0;i<=n;i++)
	{
		arr[i]=0;
		no[i]=0;
	}
	flag=0;
	for(i=0;i<(m-1);i++)
	{
		source=l[i];
		desti=l[i+1];
		if(desti<=source)
		desti=desti+n;
		temp=desti-source;
		if(arr[l[i]]==0)
		{
			if(no[temp]==1)
			{
				flag=1;
				break;
			}
			else
			{
				arr[l[i]]=temp;
				no[temp]=1;
			}
		}
		else if(arr[l[i]]==temp);
		else
		{
			flag=1;
			break;
		}
	}
	k=1;
	if(flag==1)
	printf("-1");
	else
	{
		for(i=1;i<=n;i++)
		{
			if(arr[i]==0)
			{
				while(no[k]==1)
				k++;
				arr[i]=k;
				no[k]=1;
				k++;
			}
		}
		for(i=1;i<=n;i++)
		printf("%d ",arr[i]);
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int a,x,y;
  scanf("%d%d%d", &a,&x,&y);
  int t = y/a;
  //printf("t' = %d\n", t);
  if(y<0){
        printf("-1\n");
      	//system("PAUSE");
        return 0;
  }
  if(y%a!=0){
      	t++;
        }else{
                printf("-1\n");
                //system("PAUSE");
        return 0;
        }
        //printf("t = %d\n", t);
        if(t==1){
                if(abs(x)<(float)a/2){
                        printf("1\n");
                        //system("PAUSE");
                return 0;
                }else{
                        printf("-1\n");
                        //system("PAUSE");
                return 0;
                }
        }
        if(t%2==0){
                //printf("12\n");
                if(abs(x)<(float)a/2){
                        printf("%d\n", (t/2)-1+t);
                        //system("PAUSE");
                				return 0;
                }else{
                        printf("-1\n");
                        //system("PAUSE");
                return 0;
                }
        }else{
                //printf("13\n");
                if(abs(x)<a){
                        if(x==0){
                                printf("-1\n");
                                //system("PAUSE");
                        return 0;
                        }
                        if(x>0){
                                printf("%d\n", ((t/2)-1)+t+1);
                                //system("PAUSE");
                        return 0;
                        }else{
                                printf("%d\n", ((t/2)-1)+t);
                                //system("PAUSE");
                        return 0;
                        }
                }else{
                        printf("-1\n");
                }
        }
  //system("PAUSE");
  return 0;
}


#include <stdio.h>

long int pow2[220];
const long int mod = 1000000007L;
char s[110];

int main() {
	long int ans;
	int i, n;
	pow2[0] = 1L;
	for(i = 1; i <= 220; i++) pow2[i] = (pow2[i-1]<<1)%mod;
	scanf("%s", s);
	n = strlen(s);
	if(s[n-1] == '0') ans = 0;
	else ans = 1;
	for(i = n-2; i >= 0; i--) {
		ans = (ans<<1)%mod;
		//printf("... %ld\n", ans);
		if(s[i] == '1') ans = (ans+pow2[(n-i-1)*2])%mod;
	}
	printf("%ld\n", ans);
	return 0;
}


#include <stdlib.h>
#include <string.h>
#include <stdio.h>

int x_digit[10], d_digit[10], count;

void find_digits(int *digit, int num) {
	int i;
	for (i = 0; i < 10; i++)
		digit[i] = 0;
	while (num > 0) {
		digit[num%10] = 1;
		num /= 10;
	}
}

void check(int d) {
	int i;
	find_digits(d_digit, d);
	for (i = 0; i < 10; i++)
		if (x_digit[i] && d_digit[i]) {
			count++;
			break;
		}
}

int main() {
	int x, d;
	scanf(" %d", &x);
	find_digits(x_digit, x);
	for (d = 1; d*d <= x; d++) {
		if (x%d > 0)
			continue;
		check(d);
		if (x/d != d)
			check(x/d);
	}
	printf("%d\n", count);
	return 0;
}


/* https://csacademy.com/contest/archive/task/superstition/ (rainboy) */
#include <stdio.h>
#include <string.h>

#define N	8
#define L	5
#define N_	(1 + N * L)
#define N1	(N_ * 2)
#define A	26
#define MD	998244353

int tt[1 + N_][A]; char word[1 + N_];

void dfs(int coef[][L + 1], int s1, int s2, int l) {
	int a;

	if (s1 == 0 || s2 == 0)
		return;
	if (l > 0) {
		if (word[s1])
			coef[s2 - 1 << 1 | 0][l]++;
		if (word[s2])
			coef[s1 - 1 << 1 | 1][l]++;
		if (word[s1] && word[s2])
			coef[0][l]++;
	}
	for (a = 0; a < A; a++)
		dfs(coef, tt[s1][a], tt[s2][a], l + 1);
}

int coef[N1][N1][L + 1];

void apply(int aa[][N1][L], int n) {
	static int bb[N1][N1];
	int i, j, k, l;

	for (i = 0; i < n; i++)
		memset(bb[i], 0, n * sizeof *bb[i]);
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			for (k = 0; k < n; k++)
				for (l = 1; l <= L; l++)
					bb[i][k] = (bb[i][k] + (long long) aa[i][j][l - 1] * coef[j][k][l]) % MD;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			for (l = L - 1; l >= 0; l--)
				aa[i][j][l] = l == 0 ? bb[i][j] : aa[i][j][l - 1];
}

void mult(int aa[][N1][L], int bb[][N1][L], int cc[][N1][L], int n) {
	static int aa_[N1][N1][L], bb_[N1][N1][L + L];
	int i, j, k, l, l1, l2;

	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			memcpy(aa_[i][j], aa[i][j], L * sizeof *aa[i][j]);
	for (l = 0; l < L; l++)
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				for (k = 0; k < n; k++)
					for (l1 = 1; l + l1 < L; l1++)
						aa_[i][k][l] = (aa_[i][k][l] - (long long) aa_[i][j][l + l1] * coef[j][k][l1]) % MD;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++) {
			memset(bb_[i][j], 0, L * sizeof *bb_[i][j]);
			memcpy(bb_[i][j] + L, bb[i][j], L * sizeof *bb[i][j]);
		}
	for (l = L - 1; l >= 0; l--)
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				for (k = 0; k < n; k++)
					for (l1 = 1; l1 <= L; l1++)
						bb_[i][k][l] = (bb_[i][k][l] + (long long) coef[i][j][l1] * bb_[j][k][l + l1]) % MD;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			memset(cc[i][j], 0, L * sizeof *cc[i][j]);
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			for (k = 0; k < n; k++)
				for (l1 = 0; l1 < L; l1++)
					for (l2 = L - l1; l1 + l2 - L < L; l2++)
						cc[i][k][l1 + l2 - L] = (cc[i][k][l1 + l2 - L] + (long long) aa_[i][j][l1] * bb_[j][k][l2]) % MD;
}

void power(int pp[][N1][L], int tt[][N1][L], int n, int k) {
	int i, j, l;

	if (k == 0) {
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				for (l = 0; l < L; l++)
					pp[i][j][l] = i == j && l == 0;
		return;
	}
	power(tt, pp, n, k / 2);
	mult(tt, tt, pp, n);
	if (k & 1)
		apply(pp, n);
}

int main() {
	static int pp[N1][N1][L], tt_[N1][N1][L];
	int n, n_, k, i, s;

	scanf("%d%d", &n, &k);
	n_ = 1;
	for (i = 0; i < n; i++) {
		static char cc[L + 1];
		int l, h;

		scanf("%s", cc), l = strlen(cc);
		for (h = 0, s = 1; h < l; h++) {
			int a = cc[h] - 'a';

			if (!tt[s][a])
				tt[s][a] = ++n_;
			s = tt[s][a];
		}
		word[s] = 1;
	}
	for (s = 0; s < n_; s++) {
		dfs(coef[s << 1 | 0], 1, s + 1, 0);
		if (s != 0)
			dfs(coef[s << 1 | 1], s + 1, 1, 0);
	}
	power(pp, tt_, n_ * 2, k);
	if (pp[0][0][0] < 0)
		pp[0][0][0] += MD;
	printf("%d\n", pp[0][0][0]);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int n,m,i,j,s=0;
    scanf("%d%d",&n,&m);
    if(m<n)
    {
        j=n;
        n=m;
        m=j;
    }
    if(n==1)
    {
        printf("%d",m);
    }
    else if(n==2)
    {
        s=m/4*4;
        if(m%4==1)
        {
            s+=2;
        }
        else if(m%4>1)
        {
            s+=4;
        }
        printf("%d",s);
    }
    else
    {
        s=n*m/2+((m*n)%2);
    printf("%d",s);
    }

    return 0;
}


#include<stdio.h>
int gcd(int a,int b){
	int t;
	while(b>0){
		t=a%b;
		a=b;
		b=t;
	}
	return a;
}
int main()
{
	long long a,b;
	scanf("%I64d %I64d",&a,&b);
	long long t;
	if(a>b){
		t=a;
		a=b;
		b=t;
	}
	t=b-a;
	long long k=0;
	long long k1;
	long long min=a/gcd(a,b)*b;
	for(long long i=1;i*i<=t;i++){
		k1=i-b%i;
		if((a+k1)*(b+k1)<min*gcd(a+k1,b+k1)){
			min=(a+k1)/gcd(a+k1,b+k1)*(b+k1);
			k=k1;
		}
		k1=(t/i)-b%(t/i);
		if((a+k1)/gcd(a+k1,b+k1)*(b+k1)<min){
			min=(a+k1)/gcd(a+k1,b+k1)*(b+k1);
			k=k1;
		}
	}
	printf("%I64d\n",k);
	return 0;
}


#include <stdio.h>
int main()
{
    long long a , b , w , x , c , times = 0 , m[10000] = {0} ;
    scanf("%lld %lld %lld %lld %lld", &a, &b, &w, &x, &c);
    while( b > x)
    {
        if(c <= a)break;
        b -= x ;
        c--;
        times++;
    }
    if(c <= a)
    {
        printf("%lld\n", times);
        return 0;
    }
    long long st = 0 , aj = 0 , l ;
    l = b ;
    while(m[l]==0)
    {
        m[l] = 1 ;
        st++;
        if(l >= x) l -= x ;
        else
        {
            aj++;
            l = w -( x - l);
        }
    }
    long long ns = 0 ;
    if( c - a - aj  > 0)
        ns = (c - a - aj) / (st - aj);
    times += ns*st;
    c = c - st*ns;
    a = a - ns*aj;
    while(c > a)
    {
        if(b >= x)
        {
            b -= x;
            c--;
            times++;
        }
        else
        {
            b = w - (x - b);
            a--;c--;
            times++;
        }
    }
    printf("%lld\n", times);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int n, m;
double binomial[1010][1010];

void Pregenerate(){
    int i, j;
    for (i = 0; i < 1010; i++){
        for (j = 0; j <= i; j++){
            if (i == j || j == 0) binomial[i][j] = 1;
            else binomial[i][j] = (binomial[i - 1][j] + binomial[i - 1][j - 1]);
        }
    }
}

int main(){
    Pregenerate();
    int i, j, k, l;

    while (scanf("%d %d", &n, &m) != EOF){
        int r = (n * m);

        double res = 0.0;
        for (i = 1; i <= n; i++){
            double x = (1.0 * i) / (1.0 * n);
            double p = (x * x);

            k = m, l = r;
            for (j = 1; j <= i; j++, k--, l--){
                double y = (1.0 * k) / (1.0 * l);
                p *= y;
            }

            p *= binomial[n][i];

            k = r - m;
            for (j = i + 1; j <= n; j++, k--, l--){
                double y = (1.0 * k) / (1.0 * l);
                p *= y;
            }
            res += p;
        }
        res = res * n;

        res += 1e-12;
        printf("%0.9lf\n", res);
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int i,n,k;
    scanf("%lld %lld",&n,&k);
    for(i=2;i<=k;i++)
    {
        if((n%i)==(i-1))
            continue;
        else {printf("No");return 0;}
    }

    printf("Yes");
    return 0;
}


#include<stdio.h>

long long m=1000000007;

long long big(long long a,long long n)
{
    long long x=1;
    while(n)
    {
        if(n%2) x = (x*a)%m;
        a = (a*a)%m;
        n = n/2;
    }
    return x%m;
}

long long inv(long long a,long long n)
{
    long long p,q,r,s;
    if(a==1)    return (n%m);
    else
    {
        p = big(a,n)%m;
        q = p-1;
        r = big(a-1,m-2)%m;
        s = (q*r)%m;
        return s;
    }
}

int main()
{
    long long a,b,n,x,p,q,r;
    scanf("%lld %lld %lld %lld",&a,&b,&n,&x);
    p = (big(a,n)*(x%m))%m;
    q = (inv(a,n)*b)%m;
    r = (p+q)%m;
    printf("%lld\n",r);
    return 0;
}


#include<stdio.h>
int maxdig(int n)
{
int a,max=0;
while(n>0)
{
a=n%10;
if(max<a)
{
max=a;
}
n=n/10;
}
return max;
}
int main()
{
int n,o=0;
scanf("%d",&n);
while(n>0)
{
o++;
n=n-maxdig(n);
}
printf("%d",o);
return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N	15
#define K	200000
#define L	19	/* L = ceil(log2(K * 2 + 1)) */
#define N_	(1 << L)
#define MD	998244353

long long power(long long a, int k) {
	long long p = 1;

	while (k) {
		if (k & 1)
			p = p * a % MD;
		a = a * a % MD;
		k >>= 1;
	}
	return p;
}

int vv_[L + 1], *wwu[L + 1], *wwv[L + 1];

void init() {
	int i, l, u, v;

	u = power(3, MD - 1 >> L), v = power(u, MD - 2);
	for (l = L; l > 0; l--) {
		int n = 1 << l, m = n >> 1;

		vv_[l] = power(1 << l, MD - 2);
		wwu[l] = (int *) malloc(m * sizeof *wwu[l]);
		wwv[l] = (int *) malloc(m * sizeof *wwv[l]);
		wwu[l][0] = wwv[l][0] = 1;
		for (i = 1; i < m; i++) {
			wwu[l][i] = (long long) wwu[l][i - 1] * u % MD;
			wwv[l][i] = (long long) wwv[l][i - 1] * v % MD;
		}
		u = (long long) u * u % MD;
		v = (long long) v * v % MD;
	}
	vv_[0] = 1;
}

void ntt_(int *aa, int l, int inverse) {
	if (l) {
		int n = 1 << l, m = n >> 1, *ww = inverse ? wwv[l] : wwu[l], i, j;

		ntt_(aa, l - 1, inverse), ntt_(aa + m, l - 1, inverse);
		for (i = 0; (j = i + m) < n; i++) {
			int a = aa[i], b = (long long) aa[j] * ww[i] % MD;

			if ((aa[i] = a + b) >= MD)
				aa[i] -= MD;
			if ((aa[j] = a - b) < 0)
				aa[j] += MD;
		}
	}
}

void ntt(int *aa, int l, int inverse) {
	int n = 1 << l, i, j;

	for (i = 0, j = 1; j < n; j++) {
		int b = n >> 1, tmp;

		while ((i ^= b) < b)
			b >>= 1;
		if (i < j)
			tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
	}
	ntt_(aa, l, inverse);
}

void multiply(int *aa, int *bb, int *cc, int n, int m) {
	static int aa_[N_], bb_[N_];
	int n_, l, i;

	l = 0;
	while (1 << l < n + m - 1)
		l++;
	n_ = 1 << l;
	for (i = 0; i < n_; i++) {
		aa_[i] = i < n ? aa[i] : 0;
		bb_[i] = i < m ? bb[i] : 0;
	}
	ntt(aa_, l, 0);
	ntt(bb_, l, 0);
	for (i = 0; i < n_; i++)
		aa_[i] = (long long) aa_[i] * bb_[i] % MD;
	ntt(aa_, l, 1);
	for (i = 0; i < n + m - 1; i++)
		cc[i] = (long long) aa_[i] * vv_[l] % MD;
}

int main() {
	static int dp[N][K + 1], dq[K * 2 + 1];
	int n, c_, k, i, c, x;

	init();
	scanf("%d%d%d", &n, &k, &c_);
	for (c = 0; c <= k; c++)
		dp[0][c] = 1;
	for (i = 0; i < n; i++) {
		multiply(dp[i], dp[i], dq, k + 1, k + 1);
		if (i + 1 == n)
			printf("%d\n", dq[c_]);
		else {
			x = 0;
			for (c = k + 1; c <= k * 2; c++)
				x = (x + dq[c]) % MD;
			for (c = k; c >= 0; c--) {
				x = (x + dq[c]) % MD;
				dp[i + 1][c] = (x + (long long) dq[c] * (k - c)) % MD;
			}
		}
	}
	return 0;
}


#include <stdio.h>

int main()
{
     int n, m, k, i;

     scanf("%d %d %d", &n, &m, &k);

     if (n % 2 == 0) {
	  puts("Marsel");
     } else {
	  for (i = 2; i * i <= m; i++) {
	       if (m % i == 0) {
		    if (m / i >= k) break;
	       }
	  }

	  if (i * i <= m || (k == 1 && m > 1)) {
	       puts("Timur");
	  } else {
	       puts("Marsel");
	  }
     }

     return 0;
}


#include <stdio.h>

int r() { int x; scanf("%d",&x); return x; }

int main()
{
    int y,z; long long u=r(),v=r(),w=r(),x=r(),t=r(),a=t-u,b=v-t,p=1,q=0,g=w+x,f=u*w+v*x-t*g;

    for(;w>=0;--w,--g,f+=a)
        for (;x>=0&&f>=0;--x,--g,f-=b)
            if (q*f<p*g)
                p=f,q=g,y=w,z=x;

    printf("%d %d",y,z);
}


#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int64_t i64;
typedef int32_t i32;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

#define POS(i, j) ((i) * (n + 1) + (j))

void run (void) {
  i32 n = read_int();
  char *s = (char *) calloc (n + 1, sizeof (char));
  scanf ("%s", s);
  i32 *dp = (i32 *) calloc ((n + 1) * (n + 1), sizeof (i32));
  for (i32 len = 1; len <= n; ++len) {
    for (i32 l = 0; l + len <= n; ++l) {
      i32 r = l + len;
      i32 min = 1 + dp[POS(l + 1, r)];
      for (i32 i = l + 1; i < r; ++i) {
        if (s[l] != s[i]) continue;
        i32 d = dp[POS(l + 1, i)] + dp[POS(i, r)];
        min = min > d ? d : min;
      }
      dp[POS(l, r)] = min;
    }
  }
  print_int (dp[POS(0, n)]);
  puts ("");
}

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


#include <stdio.h>
#include <string.h>

int low[7][7], high[7][7];
int cost[7][7];
int n;
int flow[7][7];
int inFlow[7];
int outFlow[7];
int minFlow = 100, maxCost = -1;

int rec(int v, int to) {
    if(v == n - 1) {
        int isValid = 1;
        int i, j;
        int total = inFlow[n - 1];
        int ccost = 0;
        for(i = 0; i < n; i++) {
            for(j = i + 1; j < n; j++) {
                if(flow[i][j] < low[i][j] || flow[i][j] > high[i][j])
                    isValid = 0;
                if(flow[i][j] > 0)
                    ccost += flow[i][j] * flow[i][j] + cost[i][j];
            }
        }
        if(isValid) {
            if(minFlow == total) {
                if(ccost > maxCost)
                    maxCost = ccost;
            } else if(minFlow > total) {
                minFlow = total;
                maxCost = ccost;
            }
        }
    } else if(to == n) {
        if(v > 0 && inFlow[v] != outFlow[v])
            return;
        if(inFlow[n - 1] > minFlow)
            return;
        rec(v + 1, v + 2);
    } else {
        int i;
        for(i = low[v][to]; i <= high[v][to]; i++) {
            inFlow[to] += i;
            outFlow[v] += i;
            flow[v][to] = i;
            rec(v, to + 1);
            inFlow[to] -= i;
            outFlow[v] -= i;
        }
    }
}

int main() {
    scanf("%d", &n);
    int i, from, to, j;
    for(i = 0; i < n * (n - 1) / 2; i++) {
        scanf("%d %d", &from, &to);
        from--;
        to--;
        scanf("%d %d %d", &low[from][to], &high[from][to], &cost[from][to]);
    }
    rec(0, 1);
    if(minFlow == 100)
        puts("-1 -1");
    else
        printf("%d %d\n", minFlow, maxCost);
    return 0;
}


#include<stdio.h>
int minfac(int y){
	int i;
	for(i=2;i*i<=y;i++){
		if(!(y%i)) return i;
	}
	return y;
}
int main(){
	int p,y,i,j=0;
	scanf("%d%d",&p,&y);
	while(j<=300){
		i=minfac(y);
		if(i>p){
			printf("%d\n",y);
			return 0;
		}
		j++;
		y--;
	}
	printf("-1\n");
	return 0;
}


#include<stdio.h>
double prob[2005][2005];
int main()
{
      int n,t,i,j;
      double p,cp;
      double tmp;
      scanf("%d",&n);
      scanf("%lf",&p);
      scanf("%d",&t);
      cp = 1.0-p;
      prob[0][0] = 1.0;
      for(i=1;i<=t;i++)
      prob[0][i] = 0.0;
      for(i=1;i<=t;i++)
      prob[i][0] = prob[i-1][0]*(cp);
      for(i=1;i<=t;i++)
      {
           for(j=1;j<=t;j++)
           {
                 if(j>i||j>n)
                 tmp = 0.0;
                 else if(j+1<=n)
                 tmp = cp*prob[i-1][j] + prob[i-1][j-1]*p;
                 else
                 tmp = prob[i-1][j] + prob[i-1][j-1]*p;
                 prob[i][j] = tmp;
           }
      }
      double res = 0;
      for(i=0;i<=t;i++)
      {
           res+=i*prob[t][i];
      }
      printf("%lf\n",res);
      return 0;
}


#include <stdio.h>

int tran(int a, int b){
   int t;
   int res = 0;
   int pow = 1;
   do {
      t = a/b;
      res += pow *(a-(a/b)*b);
      a = t;
      pow*=10;
   } while(t>=b);
   res +=pow*t;
   return res;
}

int main(){
   int b,i,j;
   scanf("%d",&b);
   for(i = 1; i<b; i++){
      for(j = 1; j<b; j++){
	 printf("%d ",tran(i*j,b));
      }
      printf("\n");
   }
   return 0;
}


#include <stdio.h>
#include <string.h>

#define INF	((long long) 1e18)

int main() {
	static char s[128];
	static long long dp[128][128];
	int n, h, i, j, l;
	long long min;

	scanf("%d", &n);
	scanf("%s", s);
	l = strlen(s);
	for (i = 0; i <= l; i++)
		for (j = 0; j <= l; j++)
			dp[i][j] = INF;
	dp[0][0] = 0;
	for (i = 0; i < l; i++)
		for (j = 0; j < l; j++)
			if (dp[i][j] < INF) {
				long long x = dp[i][j];

				if (s[i] == '0') {
					if ((double) x * n <= INF)
						if (dp[i + 1][j + 1] > x * n)
							dp[i + 1][j + 1] = x * n;
				} else {
					long long y = 0;

					for (h = i; h < l; h++) {
						y = y * 10 + (s[h] - '0');
						if (y >= n)
							break;
						if ((double) x * n + y <= INF)
							if (dp[h + 1][j + 1] > x * n + y)
								dp[h + 1][j + 1] = x * n + y;
					}
				}
			}
	min = INF;
	for (j = 0; j <= l; j++)
		if (min > dp[l][j])
			min = dp[l][j];
	printf("%lld\n", min);
	return 0;
}


#include <stdio.h>

int main(){
	long long int i,n;
	scanf("%lld",&n);
	long long int temp=n*2;
	temp/=10;
	long long int m=0;
	long long int m10=1;
	while(temp>0){
		temp/=10;
		m++;
		m10*=10;
	}
	if(m==0){
		printf("%lld\n",(n*(n-1))/2);
		return 0;
	}
	long long int ans=0,val=0;
	for(i=1;i<=9;i++){
		if(i*m10>2*n)break;
		if(n>=i*m10-1){
			ans+=((i*m10/2)-1);
//			val=((i*m10/2)-1);
//			printf("%d=%d\n",i,val);
		}
		else{
			ans+=(n+1-(i*m10/2));
//			val=(n+1-(i*m10/2));
//			printf("%d=%d\n",i,val);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include<stdio.h>
#include<string.h>
#define INF (unsigned long long)1000000000000000001
int q, n, flen, slen, e;
unsigned long long k, f[100001];
char s1[200] = "What are you doing at the end of the world? Are you busy? Will you save us?";
char s2[200] = "What are you doing while sending xx? Are you busy? Will you send xx?";
char s3[200] = "What are you doing while sending x";
char s4[200] = "x? Are you busy? Will you send x";
char s5[200] = "x?";
void find(int d, long long jump){
	if (d == 0){
		printf("%c", s1[jump]);
		e = 1;
		return;
	}
	if (flen > jump){
		if (s3[jump] == 'x')printf("\"");
		else printf("%c", s3[jump]);
		e = 1;
	}
	else if (flen + f[d - 1] > jump){
		find(d - 1, jump - flen);

	}
	else if (flen + f[d - 1] + slen > jump){
		jump -= (flen + f[d - 1]);
		if (s4[jump] == 'x')printf("\"");
		else printf("%c", s4[jump]);
		e = 1;
	}
	else if (flen + f[d - 1] + slen + f[d - 1] > jump){
		find(d - 1, jump - flen - f[d - 1] - slen);
	}
	else{
		jump -= (flen + f[d - 1] + slen + f[d - 1]);
		if (s5[jump] == 'x')printf("\"");
		else printf("%c", s5[jump]);
		e = 1;
	}
	if (e)return;
}

int main()
{
	scanf("%d", &q);
	int len = strlen(s1);
	int len2 = strlen(s2);
	flen = strlen(s3);
	slen = strlen(s4);
	f[0] = len;
	for (int i = 1; i <= 100000; i++){
		if (f[i - 1] == INF)f[i] = INF;
		f[i] = f[i - 1] * 2 + len2;
		if (f[i] >= INF)f[i] = INF;
	}
	while (q--){
		scanf("%d%lld", &n, &k);
		k--;
		e = 0;
		if (f[n] <= k)printf(".");
		else find(n, k);
	}
	printf("\n");
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define LEN 78777
#define MAX 1000010
#define MOD 1000000007
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define chkbit(ar, i) (((ar[(i) >> 6]) & (1 << (((i) >> 1) & 31))))
#define setbit(ar, i) (((ar[(i) >> 6]) |= (1 << (((i) >> 1) & 31))))
#define isprime(x) (( (x) && ((x)&1) && (!chkbit(ar, (x)))) || ((x) == 2))

int p, x, y, prime[LEN];
unsigned int ar[(MAX >> 6) + 5] = {0};

void sieve(){
    int i, j, k;
    setbit(ar, 0), setbit(ar, 1);

    for (i = 3; (i * i) < MAX; i += 2){
        if (!chkbit(ar, i)){
            k = i << 1;
            for (j = (i * i); j < MAX; j += k) setbit(ar, j);
        }
    }

    p = 0;
    prime[p++] = 2;
    for (i = 3; i < MAX; i += 2){
        if (isprime(i)) prime[p++] = i;
    }
}

int expo(int a, int b){
    int res = 1;

    while (b){
        if (b & 1) res = (long long)res * a % MOD;
        a = (long long)a * a % MOD;
        b >>= 1;
    }
    return res;
}

int mobius(int n){
    if (n == 1) return 1;

    int i, j, x, counter = 0;
    for (i = 0; i < p; i++){
        if (prime[i] * prime[i] > n) break;
        for (j = 0; (n % prime[i]) == 0; j++, n /= prime[i]) {}
        if (j > 1) return 0;
        counter += (j == 1);
    }

    return (counter & 1) ? 1 : -1;
}

int count(int n, int d){
    return (mobius(d) * expo(2, (n / d) - 1) + MOD) % MOD;
}

int solve(int x, int y){
    int d, n, res = 0;
    if ((y % x) != 0) return 0;

    n = y / x;
    for (d = 1; d * d <= n; d++){
        if (n % d == 0){
            res = (res + count(n, d)) % MOD;
            if ((n / d) != d) res = (res + count(n, n / d)) % MOD;
        }
    }

    return res;
}

int main(){
    sieve();
    scanf("%d %d", &x, &y);
    printf("%d\n", solve(x, y));
    return 0;
}


#include <stdio.h>

/* http://codeforces.com/contest/894/submission/34556698 (Dukkha) */

#define MD	1000000007

int power(int a, int b) {
	int p;

	if (b == 0)
		return 1;
	p = power(a, b / 2);
	p = (long long) p * p % MD;
	if (b % 2 == 1)
		p = (long long) p * a % MD;
	return p;
}

int main() {
	long long n, m, k;

	scanf("%lld%lld%lld", &n, &m, &k);
	printf("%d\n", k == -1 && n % 2 != m % 2 ? 0 : power(2, (long long) ((n - 1) % (MD - 1)) * ((m - 1) % (MD - 1)) % (MD - 1)));
	return 0;
}


#include <stdio.h>
long long n,dep,d[70];
void devide(long long k){
	while (k){
		dep++;
		d[dep]=k%2;
		k/=2;
	}
}
long long get(long long i){
	long long m=(1LL<<(dep))-1,c=0,k=i;
	while (k)
	{
		m>>=1;
		c++;
		if (k==m+1)
			break;
		if (k>m+1)
			k-=m+1;
	}
//	printf("%lld",d[c]);
	return c;
}
int main(void){
	long long x,y,i,sum=0;
	scanf("%llu%llu%llu",&n,&x,&y);
	devide(n);
	for (i=x;i<=y;i++)
		sum+=d[get(i)];
	printf("%llu\n",sum);
	return 0;
}


/* https://codeforces.com/contest/747/submission/23206377 (Dukkha) */
#include <stdio.h>
#include <string.h>

#define D	16
#define L	9
#define MIN(a, b)	((a) < (b) ? (a) : (b))

int ff[] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880 };

long long dp[D][L + 1];

void solve(int *bb, int l) {
	int k, d, i, e, j;

	memset(dp, 0, sizeof dp);
	k = MIN(l, bb[0]);
	for (i = 0; i <= k; i++)
		dp[0][i] = 1;
	for (d = 0; d < D - 1; d++)
		for (i = 0; i < l; i++)
			if (dp[d][i] > 0)
				for (e = d + 1; e < D; e++) {
					k = MIN(l, i + bb[e]);
					for (j = i + 1; j <= k; j++)
						dp[e][j] += dp[d][i] * (ff[j] / ff[i] / ff[j - i]);
				}
}

int main() {
	static int bb[D];
	static char cc[L + 1];
	int k, t, l, i, d, d_;
	long long cnt;

	scanf("%d%d", &k, &t);
	for (i = 0; i < D; i++)
		bb[i] = t;
	l = L;
	solve(bb, l);
	for (i = 1; i <= l; i++) {
		cnt = 0;
		for (d = 0; d < 16; d++)
			cnt += dp[d][i];
		cnt = cnt / 16 * 15;
		if (k > cnt)
			k -= cnt;
		else {
			l = i;
			break;
		}
	}
	for (i = 1; i <= l; i++)
		for (d_ = i == 1 ? 1 : 0; d_ < 16; d_++)
			if (bb[d_] > 0) {
				bb[d_]--;
				solve(bb, l - i);
				cnt = 0;
				for (d = 0; d < 16; d++)
					cnt += dp[d][l - i];
				if (k > cnt)
					k -= cnt;
				else {
					cc[i - 1] = d_ < 10 ? '0' + d_ : 'a' + d_ - 10;
					break;
				}
				bb[d_]++;
			}
	printf("%s\n", cc);
	return 0;
}


#include<stdio.h>
main()
{
    long long i=1000000007;
    long long n,k,j;
    scanf("%lld%lld",&n,&k);
    long long x=n-k,m=1,y=1;
    for(j=1;j<=x;j++)
        m=(m*x)%i;
    for(j=1;j<k;j++)
      y=(y*k)%i;
      m=(m*y)%i;
    printf("%I64d",m);
    return 0;
}


#include<stdio.h>
long long f[23],n,s,sum,inv[25];
int c[23];
int function(){
	int i,t1,j=0;
	i=1;

	while(1){
		if(c[i]==0){
			c[i]=1;
			break;
		}else{
			c[i]=0;
			i++;
		}
	}
}

long long power(long long a, long long b, long long MOD) {
long long x = 1, y = a;
    while(b > 0) {
        if(b%2 == 1) {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;

    }
    return x;
}

long long modInverse(long long a,long long m) {
if(inv[a]==0)
     inv[a]=power(a,m-2,m);
     return inv[a];
}

long long binomialCoeff(long long n, long long k)
{
    long long i,res = 1;
    if (k >( n - k))
        k = n - k;
    for ( i = 0; i < k; ++i)
    {
        res =(res* ((n - i)%1000000007))%1000000007;
        res =(res* modInverse((i + 1),1000000007))%1000000007;
    }

    return res;
}
void recursion(int i,long long pow,int fac){
	int j;
	i=0;
	while(1){
		fac=1;
		j=0;
		pow=0;
		for(i=1;i<=n;i++){
			pow=pow+c[i]*(f[i]+1);
			if(c[i]==1){	fac=fac*-1;
				j++;
			}
		}
		if(pow<=s){
			sum=(sum+fac*binomialCoeff(n+s-pow-1,s-pow))%1000000007;
		}
		if(j==n)	break;
		function();
	}
}

int main(){
	long long i,j,k,l;
	scanf("%lld %lld",&n,&s);
	for(i=1;i<=n;i++)	scanf("%lld",&f[i]);
	recursion(1,0,1);
	sum=(sum+1000000007)%1000000007;
	printf("%lld\n",sum);
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    unsigned long long k;
    int i,j;
    scanf("%llu",&k);
    unsigned long long a=1;
    unsigned long long asn;
    int ten=0;
    int q[10];
    char p[11]="codeforces";
    int put=0;
    for(i=0;i<10;i++)
    {
        q[i]=1;
    }
    while(1)
    {
        asn=1;
        for(i=0;i<10;i++)
        {
            asn*=q[i];
        }
        if(asn>=k)
        {
            break;
        }
        if(ten==10)
        {
            ten=0;
        }
        q[ten]++;
        ten++;
    }
    for(i=0;i<10;i++)
    {
        for(j=0;j<q[i];j++)
        {
            printf("%c",p[i]);
        }
    }
}


#include <assert.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#define rep(E, F) for (E = 0; E < (F); E++)
#define INF 1000000000

int mabs(int a) { if (a > 0) { return a; } return -a; }
int min(int a, int b) { if (a > b) { return b; } return a; }
int max(int a, int b) { if (a < b) { return b; } return a; }
int get_int();
double get_double();
int get_string(char* b, char t);
int n;
int d[2][100][100][100], a[100];
int chi(int a, int b) { return a == b ? 0 : 1; }

int foo(int b, int x, int y, int z)
{
	//printf(">> %d %d %d %d\n", b, x, y, z);
	if (z < 0 || y < 0) return INF;
	if (x == n) return 0;
	if (d[b][x][y][z] != -1) return d[b][x][y][z];
	if (a[x] != -1) return d[b][x][y][z] = chi(a[x], b) + foo(a[x], x + 1, y, z);
	return d[b][x][y][z] = min(chi(0, b) + foo(0, x + 1, y - 1, z), chi(1, b) + foo(1, x + 1, y, z - 1));
}

int main()
{
	int i, j, k;
	n = get_int();
	rep(i, n) rep(j, n) rep(k, n) d[0][i][j][k] = d[1][i][j][k] = -1;
	int d[2] = {n/2, (n + 1)/2};
	rep(i, n) a[i] = get_int();
	rep(i, n) { rep(j, n) if (a[j] == i + 1) break; if (j < n) d[(i + 1)%2]--; }
	rep(i, n) if (a[i] == 0) a[i] = -1; else a[i] %= 2;
	int r = min(foo(0, 0, d[0], d[1]), foo(1, 0, d[0], d[1]));
	assert(r < INF);
	printf("%d\n", r);
	return 0;
}

int get_string(char* b, char t)
{
	int i = 0; b[i++] = getchar();
	while (b[i - 1] != t) b[i++] = getchar();
	b[i - 1] = '\0';
	return i - 1;
}

int get_int()
{
	int sgn = 1, ret = 0;
	char c  = getchar();
	while (1)
	{
		if (c == EOF) return EOF;
		if (c >= '0' && c <= '9') break;
		if (c == '-')
		{
			c = getchar();
			if (c < '0' || c > '9') continue;
			sgn = -1;
			break;
		}
		c = getchar();
	}

	while (1)
	{
		ret = ret*10 + c - '0';
		c = getchar();
		if (c < '0' || c > '9') return sgn*ret;
	}
}

double get_double()
{
	double ret = 0;
	char c     = getchar();
	int sgn;

	while (1)
	{
		if (c == EOF)
		{
			return EOF;
		}
		if (c >= '0' && c <= '9')
		{
			sgn = 1;
			break;
		}
		if (c == '-')
		{
			c = getchar();

			if (c < '0' || c > '9')
			{
				continue;
			}

			sgn = -1;
			break;
		}
		c = getchar();
	}

	while (1)
	{
		ret = ret*10 + c - '0';

		c = getchar();

		if (c == '.')
		{
			double pos = 0.1;

			c = getchar();
			while (c >= '0' && c <= '9')
			{
				ret += pos*(c - '0');
				pos /= 10;
				c = getchar();
			}

			return sgn*ret;
		}
		else if (c < '0' || c > '9')
		{
			return sgn*ret;
		}
	}
}


/* practice with Dukkha */
#include <stdio.h>
#include <string.h>

#define K	8
#define L	840

long long min(long long a, long long b) { return a < b ? a : b; }
long long max(long long a, long long b) { return a > b ? a : b; }

int main() {
	static long long aa[K + 1], dp[L * K], dq[L * K];
	long long w, ans, a, p;
	int i, y, y_, q, q_;

	scanf("%lld", &w);
	for (i = 1; i <= K; i++)
		scanf("%lld", &aa[i]);
	memset(dp, -1, L * K * sizeof *dp);
	dp[0] = 0;
	for (i = 1; i <= K; i++) {
		a = aa[i];
		for (y = 0; y < L * K; y++)
			dq[y] = -1;
		for (y = 0; y < L * K; y++) {
			if (dp[y] < 0)
				continue;
			q_ = L / i;
			for (q = 0; q < q_ && q <= a; q++) {
				p = (a - q) / q_;
				y_ = y + q * i;
				dq[y_] = max(dq[y_], dp[y] + p);
			}
		}
		for (y = 0; y < L * K; y++)
			dp[y] = dq[y];
	}
	ans = 0;
	for (y = 0; y < L * K && y <= w; y++)
		ans = max(ans, min((w - y) / L, dp[y]) * L + y);
	printf("%lld\n", ans);
	return 0;
}


#include <stdio.h>

long long fac[250005];

int main()
{
    int n, m;
    long long ans = 0;
    scanf("%d%d", &n, &m);

    fac[0] = 1;
    for(int i = 1; i <= n; i++){
        fac[i] = (fac[i - 1] * i) % m;
    }

    for(int i = 0; i < n; i++){
        ans += (fac[i + 1] * fac[n - i]) % m;
        ans %= m;
    }

    ans = (ans * (n + 1)) % m;
    if(ans % 2 == 1) ans = (ans + m) / 2;
    else ans /= 2;

    printf("%I64d", ans);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
char str[101];
int i=1,chk=0;
scanf("%s",&str);
printf("%c",str[0]);
while(i!=strlen(str))
 {
   if(str[i]=='a')
    {
     if(chk==0)
     {
      if((str[i+1]=='t')&&((i+1)!=strlen(str)-1))
      {
       printf("@");
       i++;
       chk=1;
      }
     }
    else
     printf("%c",str[i]);
    }
  else if(str[i]=='d')
     {
      if((str[i+1]=='o')&&(str[i+2]=='t')&&((i+2)!=strlen(str)-1))
        {
         printf(".");
         i+=2;
        }
     else
       printf("%c",str[i]);
     goto xy;
     }
  else
   {
    printf("%c",str[i]);
    goto xy ;
   }
if(chk==0)
 printf("%c",str[i]);
xy : i++;
 }
return 0;
}


#include <stdlib.h>

char board[10][10] = { 0 };
char* pattern1 = { ".XXXX" };
char* pattern2 = { "X.XXX" };
char* pattern3 = { "XX.XX" };
char* pattern4 = { "XXX.X" };
char* pattern5 = { "XXXX." };

char temp;
int result;

int checkHorizontal()
{
	int i, j;
	int result = 0;

	for (j = 0; j < 10; j++)
	{
		if (result == 1)
			break;

		for (i = 0; i <= 5; i++)
		{
			if (board[j][i] == pattern1[0] && board[j][i + 1] == pattern1[1] &&
				board[j][i + 2] == pattern1[2] && board[j][i + 3] == pattern1[3] &&
				board[j][i + 4] == pattern1[4])
			{
				result = 1;
				break;
			}
			else if (board[j][i] == pattern2[0] && board[j][i + 1] == pattern2[1] &&
				board[j][i + 2] == pattern2[2] && board[j][i + 3] == pattern2[3] &&
				board[j][i + 4] == pattern2[4])
			{
				result = 1;
				break;
			}
			else if (board[j][i] == pattern3[0] && board[j][i + 1] == pattern3[1] &&
				board[j][i + 2] == pattern3[2] && board[j][i + 3] == pattern3[3] &&
				board[j][i + 4] == pattern3[4])
			{
				result = 1;
				break;
			}
			else if (board[j][i] == pattern4[0] && board[j][i + 1] == pattern4[1] &&
				board[j][i + 2] == pattern4[2] && board[j][i + 3] == pattern4[3] &&
				board[j][i + 4] == pattern4[4])
			{
				result = 1;
				break;
			}
			else if (board[j][i] == pattern5[0] && board[j][i + 1] == pattern5[1] &&
				board[j][i + 2] == pattern5[2] && board[j][i + 3] == pattern5[3] &&
				board[j][i + 4] == pattern5[4])
			{
				result = 1;
				break;
			}
		}
	}

	return result;
}

int checkVertical()
{
	int i, j;
	int result = 0;

	for (j = 0; j < 10; j++)
	{
		if (result == 1)
			break;

		for (i = 0; i <= 5; i++)
		{
			if (board[i][j] == pattern1[0] && board[i + 1][j] == pattern1[1] &&
				board[i + 2][j] == pattern1[2] && board[i + 3][j] == pattern1[3] &&
				board[i + 4][j] == pattern1[4])
			{
				result = 1;
				break;
			}
			else if (board[i][j] == pattern2[0] && board[i + 1][j] == pattern2[1] &&
				board[i + 2][j] == pattern2[2] && board[i + 3][j] == pattern2[3] &&
				board[i + 4][j] == pattern2[4])
			{
				result = 1;
				break;
			}
			else if (board[i][j] == pattern3[0] && board[i + 1][j] == pattern3[1] &&
				board[i + 2][j] == pattern3[2] && board[i + 3][j] == pattern3[3] &&
				board[i + 4][j] == pattern3[4])
			{
				result = 1;
				break;
			}
			else if (board[i][j] == pattern4[i] && board[i + 1][j] == pattern4[1] &&
				board[i + 2][j] == pattern4[2] && board[i + 3][j] == pattern4[3] &&
				board[i + 4][j] == pattern4[4])
			{
				result = 1;
				break;
			}
			else if (board[i][j] == pattern5[0] && board[i + 1][j] == pattern5[1] &&
				board[i + 2][j] == pattern5[2] && board[i + 3][j] == pattern5[3] &&
				board[i + 4][j] == pattern5[4])
			{
				result = 1;
				break;
			}
		}
	}

	return result;
}

int checkdiagonal()
{
	int result = 0;
	int i, j;

	for (j = 0; j <= 5; j++)
	{
		if (result == 1)
			break;

		for (i = 0; i <= 5; i++)
		{
			if (board[j][i] == pattern1[0] &&
				board[j + 1][i + 1] == pattern1[1] &&
				board[j + 2][i + 2] == pattern1[2] &&
				board[j + 3][i + 3] == pattern1[3] &&
				board[j + 4][i + 4] == pattern1[4])
			{
				result = 1;
				break;
			}
			else if (board[j][i] == pattern2[0] &&
				board[j + 1][i + 1] == pattern2[1] &&
				board[j + 2][i + 2] == pattern2[2] &&
				board[j + 3][i + 3] == pattern2[3] &&
				board[j + 4][i + 4] == pattern2[4])
			{
				result = 1;
				break;
			}
			else if (board[j][i] == pattern3[0] &&
				board[j + 1][i + 1] == pattern3[1] &&
				board[j + 2][i + 2] == pattern3[2] &&
				board[j + 3][i + 3] == pattern3[3] &&
				board[j + 4][i + 4] == pattern3[4])
			{
				result = 1;
				break;
			}
			else if (board[j][i] == pattern4[0] &&
				board[j + 1][i + 1] == pattern4[1] &&
				board[j + 2][i + 2] == pattern4[2] &&
				board[j + 3][i + 3] == pattern4[3] &&
				board[j + 4][i + 4] == pattern4[4])
			{
				result = 1;
				break;
			}
			else if (board[j][i] == pattern5[0] &&
				board[j + 1][i + 1] == pattern5[1] &&
				board[j + 2][i + 2] == pattern5[2] &&
				board[j + 3][i + 3] == pattern5[3] &&
				board[j + 4][i + 4] == pattern5[4])
			{
				result = 1;
				break;
			}
		}
	}

	for (j = 9; j >= 4; j--)
	{
		if (result == 1)
			break;

		for (i = 0; i <= 5; i++)
		{
			if (board[j][i] == pattern1[0] &&
				board[j - 1][i + 1] == pattern1[1] &&
				board[j - 2][i + 2] == pattern1[2] &&
				board[j - 3][i + 3] == pattern1[3] &&
				board[j - 4][i + 4] == pattern1[4])
			{
				result = 1;
				break;
			}
			else if (board[j][i] == pattern2[0] &&
				board[j - 1][i + 1] == pattern2[1] &&
				board[j - 2][i + 2] == pattern2[2] &&
				board[j - 3][i + 3] == pattern2[3] &&
				board[j - 4][i + 4] == pattern2[4])
			{
				result = 1;
				break;
			}
			else if (board[j][i] == pattern3[0] &&
				board[j - 1][i + 1] == pattern3[1] &&
				board[j - 2][i + 2] == pattern3[2] &&
				board[j - 3][i + 3] == pattern3[3] &&
				board[j - 4][i + 4] == pattern3[4])
			{
				result = 1;
				break;
			}
			else if (board[j][i] == pattern4[0] &&
				board[j - 1][i + 1] == pattern4[1] &&
				board[j - 2][i + 2] == pattern4[2] &&
				board[j - 3][i + 3] == pattern4[3] &&
				board[j - 4][i + 4] == pattern4[4])
			{
				result = 1;
				break;
			}
			else if (board[j][i] == pattern5[0] &&
				board[j - 1][i + 1] == pattern5[1] &&
				board[j - 2][i + 2] == pattern5[2] &&
				board[j - 3][i + 3] == pattern5[3] &&
				board[j - 4][i + 4] == pattern5[4])
			{
				result = 1;
				break;
			}
		}
	}

	return result;
}

int main()
{
	int i, j;
	int result = 0;

	for (i = 0; i < 10; i++)
	{
		for (j = 0; j < 10; j++)
			scanf("%c", &board[i][j]);
		scanf("%c", &temp);
	}

	if (checkHorizontal())
		result = 1;

	if (checkVertical())
		result = 1;

	if (checkdiagonal())
		result = 1;

	printf("%s\n", result ? "YES" : "NO");
	return 0;
}

/* 1511793420122 */


#include <stdio.h>

#define M	100
#define MD	1000000007

void mult(int aa[][M], int bb[][M], int cc[][M], int m) {
	int i, j, k;

	for (i = 0; i < m; i++) {
		int *ci = cc[i];

		for (j = 0; j < m; j++)
			ci[j] = 0;
		for (k = 0; k < m; k++) {
			int *bk = bb[k], a = aa[i][k];

			for (j = 0; j < m; j++)
				ci[j] = (ci[j] + (long long) a * bk[j]) % MD;
		}
	}
}

void power(int aa[][M], int pp[][M], int tt[][M], int m, long long k) {
	if (k == 0) {
		int i, j;

		for (i = 0; i < m; i++)
			for (j = 0; j < m; j++)
				pp[i][j] = i == j;
		return;
	}
	if (k % 2 == 0) {
		power(aa, tt, pp, m, k / 2);
		mult(tt, tt, pp, m);
	} else {
		power(aa, pp, tt, m, k / 2);
		mult(pp, pp, tt, m);
		mult(tt, aa, pp, m);
	}
}

int main() {
	static int aa[M][M], pp[M][M], tt[M][M];
	long long n;
	int m, i, j, ans;

	scanf("%lld%d", &n, &m);
	if (n < m) {
		printf("1\n");
		return 0;
	}
	for (i = 0; i < m - 1; i++)
		aa[i][i + 1] = 1;
	aa[m - 1][0] = aa[m - 1][m - 1] = 1;
	power(aa, pp, tt, m, n - m + 1);
	ans = 0;
	for (j = 0; j < m; j++)
		ans = (ans + pp[m - 1][j]) % MD;
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
int main()
{
    long long n,a,b,c,i,j,k,diff,min=10000000000,max;
    scanf("%lld",&n);
    for(i=1;i*i*i<=n;i++)
    {
        if(n%i==0)
        {
            for(j=i;j*j<=n/i;j++)
            {
                if(n%j==0)
                k=n/(i*j);
                a=i+1;b=j+2;c=k+2;
                if((a-1)*(b-2)*(c-2)==n)
                diff=(a*b*c)-n;
                if(min>diff)
                min=diff;

        }
        }
    }
    max=9*(n+1)-n;
    printf("%lld %lld",min,max);
    return 0;
}


#include <stdio.h>

const long long int base = 1000000007;

long long int sq(int x, int y) {
  long long int i, a;

  a = 1;
  for (i = 0; i < y; i++) {
    a = (a * x) % base;
  }

  return a;
}

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

  scanf("%d%d%d", &n, &m, &k);

  if (k == 1 || k > n) printf("%I64d", sq(m, n));
  else if (k == n) printf("%I64d", sq(m, (n+1)/2));
  else if (k%2 == 1) printf("%I64d", sq(m, 2));
  else printf("%d", m);

  return 0;
}


#include <stdio.h>

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	int a, b, x, y, g;

	scanf("%d%d%d%d", &a, &b, &x, &y);
	g = gcd(x, y);
	x /= g, y /= g;
	a /= x, b /= y;
	g = a < b ? a : b;
	printf("%d %d\n", g * x, g * y);
	return 0;
}


#include<stdio.h>
long long int prime(long long int x)
{
	if (x < 2)
		return 0;
	if (x % 2 == 0)
		return 2;
	long long int i;
	for (i = 3; i * i <= x; i++)
		if (x % i == 0)
			return i;
	return x;
}
long long int modpow(long long int a, long long int n, long long int p)
{
	if (n < 0)return 0;
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			res = res * a % p;
		n /= 2;
		a = a * a % p;
	}
	return res;
}
int main()
{
	long long int x, n;
	scanf("%lld %lld", &x, &n);
	long long int ans = 1, p = 1000000007;
	long long int q, v;
	while (x > 1)
	{
		q = prime(x);
		while (x % q == 0)
			x /= q;
		v = q;
		while (n / v > 0)
		{
			ans = ans * modpow(q, n / v, p) % p;
			if (n / v < q)break;
			v *= q;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int compare(const void* a, const void* b)
{
    int* x = (int*) a;
    int* y = (int*) b;
    return *x - *y;
}

unsigned min(const unsigned a, const unsigned b)
{
    return (a < b) ? a : b;
}

int main(int argc, const char *argv[])
{
	unsigned a[500000] = {0};
    unsigned x, n, i, j = 0;
	unsigned long long ans = 0;

	scanf("%u", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%u", &x);
		while(j > 1 && a[j - 2] >= a[j - 1] && x >= a[j - 1])
        {
			ans += min(a[j - 2], x);
			j--;
		}
		a[j++] = x;
	}

    qsort(a, j, sizeof(unsigned), compare);

    if (j > 1)
        for(i = 0; i < j - 2; i++)
            ans += a[i];

	printf("%I64d\n", ans);
    return 0;
}


#include <stdio.h>

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

int main(void) {
    int i;
    int c, wr, wb;
    long long hr, hb;
    long long ans;

    scanf("%d %lld %lld %d %d", &c, &hr, &hb, &wr, &wb);

    ans = 0;
    for (i = 0; i <= c / wr && i * i <= c; i++)
        ans = max(ans, hr * i + (c - wr * i) / wb * hb);
    for (i = 0; i <= c / wb && i * i <= c; i++)
        ans = max(ans, hb * i + (c - wb * i) / wr * hr);

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

    return 0;
}


#include <stdio.h>

int main () {
	int n, res;
	scanf ("%d", &n);
	res = sqrt(2) * n;
	res *= 4;
	if (n == 0) {
		res = 1;
	}
	printf ("%d", res);
	return 0;
}


#include<stdio.h>
#include<stdbool.h>

typedef struct{
	int x, y;
} Point;

typedef struct{
	Point n[4];
} Square;

int cross(Point a, Point b, Point c){
	return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y);
}

int abs(int a){return a<0?-a:a;}
int min(int a, int b){return a<b?a:b;}
int max(int a, int b){return a>b?a:b;}

bool contains(Square sq, Point p){
	return abs(cross(sq.n[0], sq.n[1], sq.n[2]))+
		abs(cross(sq.n[2], sq.n[3], sq.n[0]))==
		abs(cross(sq.n[0], sq.n[1], p))+abs(cross(sq.n[1], sq.n[2], p))+
		abs(cross(sq.n[2], sq.n[3], p))+abs(cross(sq.n[3], sq.n[0], p));
}

int sqminx(Square sq){ return min(sq.n[0].x, min(sq.n[1].x, min(sq.n[2].x, sq.n[3].x))); }
int sqmaxx(Square sq){ return max(sq.n[0].x, max(sq.n[1].x, max(sq.n[2].x, sq.n[3].x))); }
int sqminy(Square sq){ return min(sq.n[0].y, min(sq.n[1].y, min(sq.n[2].y, sq.n[3].y))); }
int sqmaxy(Square sq){ return max(sq.n[0].y, max(sq.n[1].y, max(sq.n[2].y, sq.n[3].y))); }

int main(){
	Square squares[2];
	int i, j;
	Point curr;
	for(i=0;i<2;++i) for(j=0;j<4;++j)
			scanf("%d %d", &squares[i].n[j].x, &squares[i].n[j].y);
	for(curr.x=sqminx(squares[0]);curr.x<=sqmaxx(squares[0]);++curr.x){
		for(curr.y=sqminy(squares[0]);curr.y<=sqmaxy(squares[0]);++curr.y){
			if(contains(squares[1], curr)){
			puts("YES");
			return 0;
			}
		}
	}
	puts("NO");
	return 0;
}


#include<stdio.h>
long long int s;
int  check(long long int  x)
{
 long long int sum=0,y=x;
 //printf("%lld\n",y);
 while(y!=0)
 {
   //  printf("hi\n");
  sum+=(y%10);
  y=y/10;
 }
 //printf("%lld",s);
 //printf("%lld\n",x-sum);
 if((x-sum)>=s)
 {
    // printf("hi\n");
  return 1;
 }
 return 0;
}
int main()
{
 long long int n;
 scanf("%lld %lld",&n,&s);

 long long int l,r,m;
 l=0;
 r=n;
 m=(l+r)/2;
 while(l<r)
 {
  //printf("hi\n");
   m=(l+r)/2;
   if(check(m) && check(m-1))
   {
       r=m-1;
      // printf("hi\n");
   }
   else if(check(m))
   r=m;
   else if(!check(m))
   l=m+1;
 }
 if(!check(l))
 {
 printf("0\n");
 //printf("hi\n");
}
 else
 printf("%lld",n-r+1);
 return 0;
}


// sigma0(Prod[pi^ai]) = Prod(ai+1)
// hence to have 4 divisors we need to consider numbers in the form: p^3, pq

#include <stdint.h>
#include <stdbool.h>
#include <assert.h>

#include <stdio.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>

#define IMPL_LOWER_BOUND_VTYPE(T, VT, NAME, CMP)                                                \
    static inline int NAME(int n, const T elem[const static n], VT v) {                         \
        int low = 0, high = n;                      /* start with whole array               */  \
        while(high > low) {                         /* more than one candidate              */  \
            const int mid = low + (high - low) / 2; /* pick middle                          */  \
            if(CMP(elem[mid], v))   low = mid + 1;  /* a[mid] <  v: no need to consider mid */  \
            else                    high = mid;     /* a[mid] >= v: pick first half         */  \
        }                                                                                \
        return low;                                                                             \
    }

#define LESS(a,b) ((a)<(b))
IMPL_LOWER_BOUND_VTYPE(int64_t, int64_t, lower_bound, LESS)

#define SIEVE_MAX_PRIME 99999989
#define SIEVE_PRIME_COUNT 5761455

static bool _sieve_is_composite[SIEVE_MAX_PRIME/2+1] = {}; // 2*i+1
static int64_t _sieve_prime[SIEVE_PRIME_COUNT];

static void generate_primes() {
    // sieve
    _sieve_is_composite[0] = true;
    for(int64_t i = 1, j = 3 ; j*j <= SIEVE_MAX_PRIME ; ++i, j+= 2) {
        if(_sieve_is_composite[i]) continue;
        for(int64_t jj = j*j, ii = (jj-1)/2 ; jj <= SIEVE_MAX_PRIME ; jj += 2*j, ii += j)
            _sieve_is_composite[ii] = true;
    }

    // collect primes
    _sieve_prime[0] = 2;
    for(int64_t i = 0, in = (SIEVE_MAX_PRIME-1)/2, pi = 1 ; i <= in ; ++i) {
        if(_sieve_is_composite[i]) continue;
        assert(pi < SIEVE_PRIME_COUNT); _sieve_prime[pi++] = 2*i+1;
    }
}

static uint64_t isqrt(uint64_t n) {
    uint64_t bit_place = 1ULL << 31;
    while(bit_place > n) bit_place >>= 1;

    uint64_t root = 0; while(bit_place) {
        const uint64_t root_cand = root | bit_place, square_cand = root_cand*root_cand;
        if(square_cand <= n) root = root_cand;
        bit_place >>= 1;
    }
    return root;
}

static uint64_t icbrt(uint64_t n) {
    // modified code from hacker's delight, applying 64-bit specific fixes
    int64_t y = 0;
    for(int s = 63 ; s >= 0 ; s -= 3) {
        y = 2*y;
        int64_t b = 3*y*(y+1) + 1;
        if((n >> s) >= b) {
            n -= (b << s); ++y;
        }
    }
    return y;
}

// we need to memoize only lower levels of the tree
#define LPHI_MEMO_X 100000LL
#define LPHI_MEMO_A 100LL
static int64_t _lphi_memo[LPHI_MEMO_X+1][LPHI_MEMO_A+1] = {};

static int64_t legendre_phi(int64_t x, int64_t a) { assert(a < SIEVE_PRIME_COUNT);
    if(a == 1) return (x+1)/2; // odd numbers

    const bool should_memo = x <= LPHI_MEMO_X && a <= LPHI_MEMO_A;
    if(should_memo && _lphi_memo[x][a]) return _lphi_memo[x][a];

    // do not forget that in math we count primes from 1, but in prime array we count from 0
    const int64_t p = _sieve_prime[a-1];
    const int64_t t1 = legendre_phi(x, a-1);                // not using p[1],...,p[a-1]
    const int64_t t2 = x >= p ? legendre_phi(x/p, a-1) : 0; // not using p[1],...,p[a-1], but uses p[a]
    const int64_t phi = t1 - t2; if(should_memo) _lphi_memo[x][a] = phi;

    return phi;
}

static int64_t prime_pi_lehmer(int64_t N) {
    if(N <= SIEVE_MAX_PRIME) {
        const int idx = lower_bound(SIEVE_PRIME_COUNT, _sieve_prime, N); assert(idx < SIEVE_PRIME_COUNT);
        return idx + (_sieve_prime[idx] == N ? 1 : 0);
    }
    const int64_t N_2 = isqrt(N), a = prime_pi_lehmer(isqrt(N_2)), b = prime_pi_lehmer(N_2), c = prime_pi_lehmer(icbrt(N));
    int64_t ret = legendre_phi(N,a) + ((b+a-2)*(b-a+1)) / 2;
    for(int64_t i = a+1 ; i <= b ; ++i)
        ret -= prime_pi_lehmer(N/_sieve_prime[i-1]);
    for(int64_t i = a+1 ; i <= c ; ++i) {
        const int64_t pi = _sieve_prime[i-1], bi = prime_pi_lehmer(isqrt(N/pi));
        for(int64_t j = i ; j <= bi ; ++j)
            ret -= (prime_pi_lehmer(N/(pi*_sieve_prime[j-1])) - (j-1));
    }
    return ret;
}

int main() {
    generate_primes();

    int64_t N; scanf("%" PRId64 "\n", &N);

    int64_t count = 0;

    for(int i = 0 ; i < SIEVE_PRIME_COUNT ; ++i) {
        const int64_t p = _sieve_prime[i]; if(p*p*p > N) break;
        ++count;
    }

    for(int i = 0 ; i < SIEVE_PRIME_COUNT ; ++i) {
        const int64_t p = _sieve_prime[i]; if(p*p > N) break;
        const int64_t ppi = prime_pi_lehmer(N/p);
        if(ppi <= (i+1)) break;
        count += ppi - (i+1);   // do not forget that in math we count primes from 1, but in prime array we count from 0
    }

    printf("%" PRId64 "\n", count);
    return 0;
}


#include<stdio.h>
int main(){
	int a[10], i, n, max=0;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
		if(max<a[i]) max=a[i];
	}
	printf("%d", max^a[n-1]);
	return 0;
}


#include <stdio.h>
#include <string.h>

#define N 1100000

int a[N];

int max(int x, int y) {
    return x > y ? x : y;
}

int perfect(int x) {
    int i;
    for (i = 0; i < 30; i++) {
        int num = 1 << i;
        if (num == x)
            return 1;
    }
    return 0;
}

int step(int x) {
    int i;
    for (i = 0; i < 30; i++) {
        int num = 1 << i;
        if (num >= x)
            return i;
    }
    return -1;
}

int main(int argc, char** argv) {
    int i, n, m, x, y, z, s;

    memset(a, 0, sizeof a);
    scanf("%d", &n);
    m = n;
    for (i = 2; i < N; i++) {
        while (n % i == 0) {
            n /= i;
            a[i]++;
        }
    }

    x = 1;
    y = 0;
    z = 0;
    s = 1;
    for (i = 2; i < N; i++)
        if (a[i] > 0) {
            x *= i;
            z = max(z, a[i]);
        }
    for (i = 2; i < N; i++)
        if (a[i] > 0 && a[i] != z)
            s = 0;

    if (s == 1 && perfect(z))
        y = step(z);
    else
        y = step(z) + 1;

    if (m == 1)
        puts("1 0");
    else
        printf("%d %d\n", x, y);

    return 0;
}


/* practice with Dukkha */
#include <stdio.h>

#define N	100000
#define S	20

int max(int a, int b) { return a > b ? a : b; }

int aa[N], bb[N];
int x;

int get_next_x() {
	return (x = (x * 37LL + 10007) % 1000000007);
}

void init_AB(int n, int d) {
	int i, j, tmp;

	for (i = 0; i < n; i++)
		aa[i] = i + 1;
	for (i = 0; i < n; i++) {
		j = get_next_x() % (i + 1);
		tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
	}
	for (i = 0; i < n; i++)
		bb[i] = i < d;
	for (i = 0; i < n; i++) {
		j = get_next_x() % (i + 1);
		tmp = bb[i], bb[i] = bb[j], bb[j] = tmp;
	}
}

int main() {
	static int ii[S + 1], jj[N];
	int n, d, h, i, k, c;

	scanf("%d%d%d", &n, &d, &x);
	init_AB(n, d);
	k = 0;
	for (i = 0; i < n; i++) {
		h = i < S ? i : S;
		while (h > 0 && aa[ii[h - 1]] < aa[i]) {
			ii[h] = ii[h - 1];
			h--;
		}
		ii[h] = i;
		if (bb[i])
			jj[k++] = i;
		c = 0;
		for (h = 0; h <= i && h < S; h++)
			if (bb[i - ii[h]]) {
				c = aa[ii[h]];
				break;
			}
		if (c == 0)
			for (h = 0; h < k; h++)
				c = max(c, aa[i - jj[h]]);
		printf("%d\n", c);
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

long long dp[19][49][253];
bool visited[19][49][253] = {false};
int n, ar[20], H[2522], next[2522][10], mod[255][10];

long long F(int i, int m, int r, bool flag){
    if (i == -1) return !(r % m);
    int j, h = H[m], lim = 10;
    if (!flag && visited[i][h][r]) return dp[i][h][r];

    long long res = 0;
    if (flag) lim = ar[i] + 1;
    for (j = 0; j < lim; j++){
        res += F(i - 1, next[m][j], i ? mod[r][j]: (r * 10) + j, flag && (j == ar[i]));
    }
    if (flag) return res;

    visited[i][h][r] = true;
    return (dp[i][h][r] = res);
}

long long Solve(long long val){
    n = 0;
    for (; ;){
        ar[n++] = (val % 10);
        val /= 10;
        if (!val) break;
    }

    return F(n - 1, 1, 0, true);
}

unsigned int gcd(unsigned int u, unsigned int v){
    if (!u) return v;
    if (!v) return u;
    if (u == 1 || v == 1) return 1;

    int shift = __builtin_ctz(u | v);
    u >>= __builtin_ctz(u);
    do{
        v >>= __builtin_ctz(v);
        if (u > v)
            v ^= u ^= v ^= u;
        v = v - u;
    } while (v);

    return u << shift;
}

void Generate(){
    int i, j, k;

    for (i = 1, k = -1; i <= 2520; i++){
        if (!(2520 % i)) k++;
        H[i] = k;
    }

    for (j = 0; j < 10; j++){
        for (i = 1; i <= 2520; i++){
            if (j > 1) next[i][j] = (i * j) / gcd(i, j);
            else next[i][j] = i;
        }

        for (i = 0; i < 252; i++) mod[i][j] = ((i * 10) + j) % 252;
    }
}

int main(){
    Generate();

    int t, i, j;
    long long a, b, res;

    scanf("%d", &t);
    while (t--){
        scanf("%lld %lld", &a, &b);
        res = Solve(b) - Solve(a - 1);
        printf("%lld\n", res);
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <stdbool.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double lld;
#define pr printf
#define sc scanf
#define I 1e18
#define in(x) scanf("%d", &x)
#define out(x) printf("%d\n", x)
#define re(i,a,b) for(int i=a;i<b;i++)
int i, j;
void test();
int power[1000];
void precal()
{
	power[0] = 1;
	for (i = 1; i <= 19; i++)
	{
		power[i] = 2 * power[i - 1];
	}
}
void func(int a[], int len) {
	for (int h = 1743392200; h; h /= 3)
		for (int i = h; i < len; i++) {
			int tmp = a[i], *j = a + i - h;
			while (j >= a && j[0] > tmp)
				j[h] = j[0], j -= h;
			j[h] = tmp;
		}
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
	precal();
	int t = 1;
	while (t--)
	{
		test();
	}
}
void test()
{
	char s[20000];
	sc("%s", s);
	int a[20000];
	int l = strlen(s);
	for (i = 'A'; i <= 'z'; i++)
	{
		a[i] = i - 'A';
	}
	for (i = 2; i < l; i++)
	{
		if (a[s[i]] != (a[s[i - 1]] + a[s[i - 2]]) % 26)
		{
			pr("NO\n");
			return;
		}
	}
	pr("YES\n");

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>

int Input;
int Ans[70000];
int A, B, i, x, y, FAns;
long long int Test;

int QS(int *A, int *B){
    if (*A>*B) return 1;
    if (*A<*B) return -1;
    return 0;
}

int main(){
    while(~scanf("%d", &Input)){
        FAns = 0;

        for (A=0; A<10; A++) for (B=0; B<10; B++) for (i=0; i<1024; i++){
            Test = 0;
            x = i;
            while(x){
                Test *= 10;
                if (x&1) Test += A;
                else Test += B;
                x /= 2;
            }
            if (Test) if (Test<=Input){
                Ans[FAns] = Test;
                FAns++;
            }
        }

        qsort(Ans, FAns, sizeof(Ans[0]), QS);

        if (Input==1000000000){
            Ans[FAns] = Input;
            FAns++;
        }

        if (FAns<=1){
            printf("%d\n", FAns);
            continue;
        }

        for (i=FAns-1; i; i--) if (Ans[i]==Ans[i-1]) FAns--;

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

    return 0;
}


#include <stdio.h>

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

struct dxy
{
	long long d;
	long long x;
	long long y;
};

long long gcd(long long a, long long b)
{
	 return (a*b == 0) ? (a + b) : gcd(b, a%b);
}

struct dxy ext_euc(long long a, long long b)
{
	long long x, y;
	struct dxy ans;
	if (b == 0)
	{
		ans.d = a;
		ans.x = 1;
		ans.y = 0;
		return ans;
	}

	ans = ext_euc(b, a%b);
	x = ans.y;
	y = ans.x - (a/b)*ans.y;

	ans.x = x;
	ans.y = y;
	return ans;
}

long long box(long long numer, long long denom)
{
	if (numer % denom == 0 || (numer >=0 && denom >= 0) || (numer < 0 && denom < 0))
	{
		return numer / denom;
	}

	return (numer / denom) - 1;
}

int main()
{
	long long a1, a2, b1, b2;
	long long L, R;
	long long alpha1, alpha2, r, start, end;
	long long p, p1, q, q1, i, j, ans, base;
	long long hcf;
	struct dxy temp;

	scanf("%lld %lld %lld %lld %lld %lld", &a1, &b1, &a2, &b2, &L, &R);

	hcf = gcd(a1, a2);
	if ((b2 - b1) % hcf != 0)
	{
		printf("%d\n", 0);
		return 0;
	}

	r = box((b2 - b1), hcf);
	alpha1 = box(a1, hcf);
	alpha2 = box(a2, hcf);

	temp = ext_euc(alpha1, -alpha2);
	p = temp.x * r;
	p1 = temp.y * r;
	if (temp.d < 0)
	{
		p = -p;
		p1 = -p1;
	}

	start = box((L-b1), a1) + 1;
	//printf("start = %lld\n", start);
	start -= ((L-b1) % a1) == 0 ? 1 : 0;
	end = box((R-b1), a1);

	q = box((start-p), alpha2) + 1;
	q -= ((start-p) % alpha2) == 0 ? 1 : 0;
	q1 = box((end-p), alpha2);
	//printf("q1 = %lld\n", q1);

	base = box(-p, alpha2) + 1;
	base -= (p % alpha2) == 0 ? 1 : 0;
	q = max(q, base);
	//printf("q = %lld\n", q);

	base = box(-p1, alpha1) + 1;
	base -= (p1 % alpha1) == 0 ? 1 : 0;
	q = max(q, base);
	//printf("q = %lld\n", q);

	ans = q1 - (q - 1);
	//printf("ans = %lld\n", ans);
	if (ans < 0 )
	{
		ans = 0;
	}

	/*
	j = 0;
	for (i = q; i <= box((end-p), alpha2); i++)
	{
		if (p + i*alpha2 >=0 && p1 + i*alpha1 >= 0)
		{
			j++;
		}
	}
	*/
	//printf("start = %lld, end = %lld\n", start, end);
	//printf("p = %lld, p1 = %lld, q = %lld, r = %lld\n", p, p1, q, r);
	//printf("%lld %lld\n", box((end-p), alpha2), box((start-p), alpha2));
	/*
	if (p + q*alpha2 < 0 || p1 + q*alpha1 < 0)
	{
		printf("%d\n", 0);
		return 0;
	}
	*/
	printf("%lld\n", ans);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define N 2000000
#define MOD 1000000007

int maxp[N + 1];
int lcm[N + 1];
int lcm_cnt[N + 1];
int p[200000];
int q[200000], qp;

int max(int x, int y) {
  return x > y ? x : y;
}

int cmp(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main(void) {
  for (int i = 0; i <= N; i++) {
    maxp[i] = i;
  }
  for (int i = 2; i <= N; i++) {
    if (maxp[i] == i) {
      for (int j = i * 2; j <= N; j += i) {
        maxp[j] = i;
      }
    }
  }

  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  qsort(p, n, sizeof(int), cmp);
  int one = 0;
  for (int i = 0; i < n; i++) {
    int x = p[i];
    if (lcm[x] == 0) {
      lcm[x] = 1;
      continue;
    }
    q[qp++] = x;
    x--;
    while (x != 1) {
      int p = maxp[x];
      int e = 0;
      while (x % p == 0) {
        x /= p;
        e++;
      }
      if (lcm[p] < e) {
        lcm[p] = e;
        lcm_cnt[p] = 1;
      } else if (lcm[p] == e) {
        lcm_cnt[p]++;
      }
    }
  }
  for (int i = 0; i < qp; i++) {
    int x = q[i] - 1;
    bool forall = true;
    while (x != 1) {
      int p = maxp[x];
      int e = 0;
      while (x % p == 0) {
        x /= p;
        e++;
      }
      if (lcm[p] == e && lcm_cnt[p] == 1) {
        forall = false;
      }
    }
    if (forall) {
      one = 1;
    }
  }
  long long ans = 1;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j < lcm[i]; j++) {
      ans *= i;
      ans %= MOD;
    }
  }
  ans += one;
  ans %= MOD;
  printf("%lld\n", ans);
  return 0;
}


/* practice with Dukkha */
#include <stdio.h>

#define N	100000
#define MD	1000000007

int ff[N], gg[N];
int d_, x_, y_;

void gcd_(int a, int b) {
	if (b == 0) {
		d_ = a;
		x_ = 1, y_ = 0;
	} else {
		int tmp;

		gcd_(b, a % b);
		tmp = x_ - a / b * y_, x_ = y_, y_ = tmp;
	}
}

int inv(int a, int b) {
	gcd_(a, b);
	return x_;
}

void init(int n) {
	int i, f;

	for (i = 0, f = 1; i < n; i++) {
		gg[i] = inv(ff[i] = f, MD);
		f = (long long) f * (i + 1) % MD;
	}
}

int choose(int n, int k) {
	return n < k ? 0 : (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

int main() {
	static int aa[N + 2], bb[N + 2], cc[N + 2];
	int f, w, h, n, i, j, p, q, ans;

	scanf("%d%d%d", &f, &w, &h);
	if (f == 0) {
		printf("%d\n", w > h);
		return 0;
	}
	if (w == 0) {
		printf("1\n");
		return 0;
	}
	n = f > w ? f : w;
	init(n);
	for (i = 1; i <= f; i++)
		aa[i] = choose(f - 1, i - 1);
	for (j = 1; j <= w; j++)
		bb[j] = choose(w - 1, j - 1);
	for (j = 1; (h + 1) * j <= w; j++)
		cc[j] = choose(w - h * j - 1, j - 1);
	p = q = 0;
	for (i = 1; i <= n; i++) {
		p = (p + aa[i] * (cc[i] * 2LL + cc[i - 1] + cc[i + 1])) % MD;
		q = (q + aa[i] * (bb[i] * 2LL + bb[i - 1] + bb[i + 1])) % MD;
	}
	if (p < 0)
		p += MD;
	if (q < 0)
		q += MD;
	ans = (long long) p * inv(q, MD) % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>

int gcd(int a, int b)
{
    int t;
    while (b!=0) {
        t=a%b;
        a=b;
        b=t;
    }
    return a;
}

int main (void)
{
    int n;
    int res=0;
    int i,j;
    scanf ("%d",&n);

    for (j=1;j <n; j++) {
        for (i=j+1;i*i+j*j <= n;i++) {
            if (gcd(i,j)==1 && ((i-j)&1)==1)
                res += n/(i*i+j*j);
        }
    }
    printf ("%d",res);
    return 0;

}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int is_same(char a[], char b[], int len){
  int i;
  rep(i,len) if(a[i]!=b[i]) return 0;
  return 1;
}

#define M 1000000009

int n, lim;
char in[12][12]; int len[12];

int dp[1011][12][12][12];
char *digit = "ACGT";

int edge1[12][12][12][4];
int edge2[12][12][12][4];
int edge3[12][12][12][4];

void edge_generator(void){
  int i,j,k;
  int word, word_len, ok_len;
  int next_word, next_word_len, next_ok_len;
  int fin, match, ok_chk;
  char now[120]; int now_len;
  int mx;

  rep(word,n) rep(word_len,len[word]) rep(ok_len,word_len+1) rep(k,4){
    fin = 0;

    rep(i,word_len) now[i] = in[word][i];
    now[word_len] = digit[k];
    now_len = word_len+1;

    match = 0;
    rep(i,n) if(now_len >= len[i]) if(ok_len + len[i] >= now_len){
      if(is_same(in[i], now+now_len-len[i], len[i])) match = 1;
    }

    next_word = 0; next_word_len = 0; next_ok_len = 0;
    if(match) fin = 1;

    rep(i,n) REP(j,1,len[i]){
      if(next_word_len >= j) continue;
      if(is_same(in[i],now+now_len-j,j)==0) continue;

      if(match) ok_chk = j;
      else      ok_chk = ok_len - (now_len - j);

      if(ok_chk < 0) continue;

      fin = 1;
      next_word = i;
      next_word_len = j;
      next_ok_len = ok_chk;
    }

    if(fin==0){edge1[word][word_len][ok_len][k] = -1; continue;}
    edge1[word][word_len][ok_len][k] = next_word;
    edge2[word][word_len][ok_len][k] = next_word_len;
    edge3[word][word_len][ok_len][k] = next_ok_len;
  }
}

int solve(int depth, int word, int word_len, int ok_len){
  int i,j,k;
  int next_word, next_word_len, next_ok_len;
  int res = 0;

  if(dp[depth][word][word_len][ok_len] >= 0) return dp[depth][word][word_len][ok_len];
  if(depth==lim){
    if(word_len==ok_len) res++;
    return dp[depth][word][word_len][ok_len] = res;
  }

  rep(k,4){
    if(edge1[word][word_len][ok_len][k] < 0) continue;
    next_word     = edge1[word][word_len][ok_len][k];
    next_word_len = edge2[word][word_len][ok_len][k];
    next_ok_len   = edge3[word][word_len][ok_len][k];

    res += solve(depth+1, next_word, next_word_len, next_ok_len);
    res %= M;
  }

  return dp[depth][word][word_len][ok_len] = res;
}

int main(){
  int i,j,k,l,m,res;

  while(scanf("%d%d",&lim,&n)==2){
    rep(i,n) scanf("%s",in[i]);
    rep(i,n){
      for(j=0;;j++) if(in[i][j]<' ') break;
      len[i] = j;
    }

    rep(i,1011) rep(j,12) rep(k,12) rep(l,12) dp[i][j][k][l] = -1;
    edge_generator();

    res = solve(0,0,0,0);
    printf("%d\n",res);
  }

  return 0;
}


//
//  codeforces3.c
//  SPOJEMC
//
//  Created by Nelson Isao Nauata Junior on 12/7/13.
//  Copyright (c) 2013 Nelson Isao Nauata Junior. All rights reserved.
//

#include <stdio.h>
#include <string.h>

long long int min(long long int *vec){
    int i;
    long long int min;
    min = vec[0];
    for(i = 0; i < 3; i++){
        if(vec[i] < min && vec[i] != 0){
            min = vec[i];
        }
    }
    if(min == 0){
        return -1;
    }
    else{
        return min;
    }
}

int main(){
    char recipe[1000];
    long long int nb, ns, nc, i;
    int pb, ps, pc;
    long long int b, s, c, max;
    long long int inf, sup, r_linha, mid, total, r, ratio, r_b, r_c, r_s, vec[3], NB, NC, NS;

    scanf("%s", recipe);
    scanf("%lld %lld %lld", &nb, &ns, &nc);
    scanf("%d %d %d", &pb, &ps, &pc);
    scanf("%lld", &r);

    b= 0;
    s = 0;
    c = 0;
    for(i = 0; i < strlen(recipe); i++){
        if(recipe[i] == 'B'){
            b++;
        }
        else if(recipe[i] == 'C'){
            c++;
        }
        else{
            s++;
        }
    }

    if(b == 0){
        nb = 0;
        pb = 0;
    }
    if(c == 0){
        nc = 0;
        pc = 0;
    }
    if(s == 0){
        ns = 0;
        ps = 0;
    }
    total = 0;
    //printf("%lld %lld %lld\n", b, s, c);
    while(nb || ns || nc){
        nb -= b;
        ns -= s;
        nc -= c;
        if(nb <= 0){
            r += nb*pb;
            nb = 0;
        }
        if(ns <= 0){
            r += ns*ps;
            ns = 0;
        }
        if(nc <= 0){
            r += nc*pc;
            nc = 0;
        }
        //printf("%lld %lld %lld\n", nb, ns, nc);
        if(r <= 0){
            if(r == 0){
                total++;
            }
            //printf("%lld\n", r);
            break;
        }
        total++;
    }
    total += r/(s*ps + c*pc + b*pb);
    printf("%lld\n", total);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char r[1 << 20];

int box2mask(char b[5][5]) {
	int mask = 0, i, j, k = 0;
	for (i = 0; i < 5; i++)
		for (j = 0; j < 5-abs(2-i); j++) {
			if (b[i][j])
				mask |= 1 << k;
			k++;
		}

	return mask;
}

int go(int mask) {
	if (r[mask] != -1)
		return r[mask];

	// printf("mask = %d\n", mask);

	char b[5][5];
	memset(b, 0, sizeof(b));

	int i, j, k = 0;
	for (i = 0; i < 5; i++)
		for (j = 0; j < 5-abs(2-i); j++) {
			if (mask & (1 << k))
				b[i][j] = 1;
			k++;
		}

	char bb[5][5];
	for (i = 0; i < 5; i++)
		for (j = 0; j < 5-abs(2-i); j++) {
			memcpy(bb, b, sizeof(bb));
			int l;
			for (k = i, l = j; k < 5 && l < 5-abs(2-k) && l >= 0 && bb[k][l]; k++) {
				bb[k][l] = 0;
				if (!go(box2mask(bb)))
					return r[mask] = 1;
				if (k >= 2)
					l--;
			}

			memcpy(bb, b, sizeof(bb));
			for (k = i, l = j; k < 5 && l < 5-abs(2-k) && bb[k][l]; k++) {
				bb[k][l] = 0;
				if (!go(box2mask(bb)))
					return r[mask] = 1;
				if (k < 2)
					l++;
			}

			memcpy(bb, b, sizeof(bb));
			for (k = j; k < 5-abs(2-i) && bb[i][k]; k++) {
				bb[i][k] = 0;
				if (!go(box2mask(bb)))
					return r[mask] = 1;
			}
		}

	return r[mask] = 0;
}

int main() {
	int i, mask = 0, j = 0;
	for (i = 0; i < 5; i++) {
		char s[100];
		gets(s);

		char *t = s;
		while (*t != '\0') {
			if (*t == 'O')
				mask |= (1 << j);
			if (*t == 'O' || *t == '.')
				j++;
			t++;
		}

	}

	if (j != 19)
		exit(1);

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

	if (go(mask))
		puts("Karlsson");
	else
		puts("Lillebror");

	return 0;
}


#include <stdio.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
const ll MOD = 1000000007;

/*nCk (mod MOD) BEGIN*/
//faccal -> n!, k!^(MOD-2)()
//comb -> nCk (mod MOD)
ll mlpow(ll x, ll p) { //(x^p) % MOD
    ll tmp = 1;
    if(p == 0) return 1;
    while(p != 0) {
        if(p & 1) tmp = tmp*x % MOD;
        x = x*x % MOD;
        p = p >> 1;
    }
    return tmp;
}

#define facnum 2000000
ll fac[facnum];     //n! (mod MOD)
ll facM2[facnum];   //(k!)^(MOD-2)
void faccal(ll up) {
    fac[0] = 1;
    facM2[0] = 1;
    for(ll i = 0; i < up + 1; i++){
        fac[i+1] = fac[i] * (i+1) % MOD;
        facM2[i+1] = facM2[i] * mlpow(i+1, MOD-2) % MOD;
    }
}

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

  	faccal(N);
	ll ans = (fac[N] - mlpow(2, N-1) + MOD) % MOD;
    printf("%lld\n", ans);
}


#include<stdio.h>

int main()
{
    long long int i=0,n,count=0,temp,mod,M=1;
    scanf("%lld",&n);
    while(1)
    {
        // printf("%lld\n", i);
        M=M*2;
        mod=n%M;
        temp=n/M;
        // printf("%lld %lld %lld\n",temp , mod,M);
        if(mod>M/2)
            count+=(M/2)*(temp+1);
        else{
                count+=(M/2)*(temp);
            }
        if(temp<=0)
            break;
        i++;
    }
    printf("%lld\n", count);
    return 0;
}


#include <stdio.h>
#include <string.h>

#define N	200100
#define MD	1000000007

int main() {
	static int dp[N + 1], dq[N + 1], tmp[N + 1];
	int a, b, k, t, n, m, i, j, sum;

	scanf("%d%d%d%d", &a, &b, &k, &t);
	n = a + k * 2 * t;
	m = b + k * 2 * t;
	dp[a] = 1;
	dq[b] = 1;
	while (t-- > 0) {
		sum = 0;
		for (i = 0; i <= n; i++) {
			tmp[i] = sum = (sum + dp[i]) % MD;
			if (i >= k * 2)
				sum = (sum - dp[i - k * 2] + MD) % MD;
		}
		memcpy(dp, tmp, (n + 1) * sizeof *tmp);
		sum = 0;
		for (j = 0; j <= m; j++) {
			tmp[j] = sum = (sum + dq[j]) % MD;
			if (j >= k * 2)
				sum = (sum - dq[j - k * 2] + MD) % MD;
		}
		memcpy(dq, tmp, (m + 1) * sizeof *tmp);
	}
	for (j = 1; j <= m; j++)
		dq[j] = (dq[j] + dq[j - 1]) % MD;
	sum = 0;
	for (i = 1; i <= n; i++)
		sum = (sum + (long long) dp[i] * dq[i - 1 < m ? i - 1 : m] % MD) % MD;
	printf("%d\n", sum);
	return 0;
}


#include <stdio.h>

#define MOD	1000000007

int power(int a, int b) {
	int p;

	if (b == 0)
		return 1;
	p = power(a, b / 2);
	p = (long long) p * p % MOD;
	if (b % 2 == 1)
		p = (long long) p * a % MOD;
	return p;
}

int inv(int x) {
	return power(x, MOD - 2);
}

int fact(int n, int is_inv) {
	return n == 0 ? 1
		: (long long) fact(n - 1, is_inv) * (is_inv ? inv(n) : n) % MOD;
}

int choose(int n, int k) {
	return (long long) ((long long) fact(n, 0) * fact(k, 1) % MOD)
		* fact(n - k, 1) % MOD;
}

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

	scanf("%d%d%d", &n, &m, &k);
	printf("%lld\n", n - 1 < 2 * k || m - 1 < 2 * k ? 0
			: (long long) choose(n - 1, 2 * k) * choose(m - 1, 2 * k) % MOD);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int x[12][110][5];
struct sub{
    int p,n;
}y[110];
int cmp(const void *a,const void *b)
{
    return ((struct sub *)a)->p-((struct sub *)b)->p;
}
int main()
{
    int res=0,sum;
    int i,j,t,U;
    int n,m,k,K,L;
    char s[20];
    scanf("%d %d %d",&n,&m,&K);
    for(t=1;t<=n;t++)
    {
        scanf("%s",s);
        for(i=1;i<=m;i++)
            for(j=1;j<=3;j++)
                scanf("%d",&x[t][i][j]);
    }
    res=0;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
        {
            if(j==i)
                continue;
            for(k=1;k<=m;k++)
            {
                y[k].n=x[i][k][3];
                y[k].p=x[j][k][2]-x[i][k][1];
            }
            qsort(y+1,m,sizeof(y[0]),cmp);
            t=m;
            k=K;
            sum=0;
            while(k>0&&t>0&&y[t].p>0)
            {
                if(y[t].n<=k)
                {
                    k-=y[t].n;
                    sum+=y[t].n*y[t].p;
                }
                else if(y[t].n>k)
                {
                    sum+=y[t].p*k;
                    k=0;
                }
                t--;
            }
            if(sum>res)
                res=sum;
        }
    printf("%d\n",res);
    return 0;
}


#include<stdio.h>

int x[100] = {0};
int cmp(const void *a,const void *b)
{
    return *( int *)a - *( int *)b;
}
int main()
{
    int n,i,c=0;
    scanf("%d",&n);
    for(i=0; i<n; i++) scanf("%d",&x[i]);
    for(i=0; i<10e6+11*10e5; i++) qsort(x,n,sizeof(int),cmp);
    for(i=0; i<n; i++) printf("%d ",x[i]);
    if(n==3)
    {
        for(i=0; i<10e6+11*10e5; i++) qsort(x,n,sizeof(int),cmp);
        for(i=0; i<10e6+11*10e5; i++) qsort(x,n,sizeof(int),cmp);

    }

    return 0;
}


#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define cL while (getchar() != '\n')  //clear line
#define fi(x) for (i = 0; i < x; i++)
#define fj(x) for (j = 0; j < x; j++)
#define FOR(a, b, c) for (int(a) = (b); (b) < (c) ? (a) <= (c) : (a) >= (c); (b) < (c) ? (a)++ : (a)--)
#define LL long long
#define min(a, b) (a > b ? b : a)
#define max(a, b) (a < b ? b : a)
#define pf printf
#define sf scanf

int main() {
    LL i, j;
    scanf("%lld%lld", &i, &j);
    char a[2000], b[2000];
    memset(b, 0, sizeof(b));
    memset(a, 0, sizeof(a));
    LL p1 = 0, p2 = 0, k = 0, a1 = i, a2 = j;
    if (i == j) {
        printf("YES");
        return 0;
    }
    if (i == 0 || j % 2 == 0) {
        printf("NO");
        return 0;
    }
    while (i) {
        a[++p1] = i % 2 + 97, k -= i % 2;
        i /= 2;
    }
    while (j) {
        b[++p2] = j % 2 + 97, k += j % 2;
        j /= 2;
    }
    int k1 = strstr(b + 1, a + 1);
    if (k1) {
        if (p2 - p1 == k) {
            printf("YES");
            return 0;
        }
    }
    FOR(i, 1, p1 / 2) {
        char tmp;
        tmp = a[i], a[i] = a[p1 + 1 - i], a[p1 + 1 - i] = tmp;
    }
    k1 = strstr(b + 1, a + 1);
    if (k1) {
        if (p2 - p1 == k) {
            printf("YES");
            return 0;
        }
    }

    p1 = 0, p2 = 0, k = 0;
    i = a1, j = a2;
    memset(b, 0, sizeof(b));
    memset(a, 0, sizeof(a));

    while (i % 2 == 0)
        i /= 2;
    while (i) {
        a[++p1] = i % 2 + 97, k -= i % 2;
        i /= 2;
    }
    while (j) {
        b[++p2] = j % 2 + 97, k += j % 2;
        j /= 2;
    }
    k1 = strstr(b + 1, a + 1);
    if (k1) {
        if (p2 - p1 == k) {
            printf("YES");
            return 0;
        }
    }
    FOR(i, 1, p1 / 2) {
        char tmp;
        tmp = a[i], a[i] = a[p1 + 1 - i], a[p1 + 1 - i] = tmp;
    }
    k1 = strstr(b + 1, a + 1);
    if (k1) {
        if (p2 - p1 == k) {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}


#include<stdio.h>
#include<stdlib.h>

int main()
{
    unsigned long long n, x, y;
    unsigned long nl, xl, yl;

    fscanf(stdin, "%ld %ld %ld", &nl, &xl, &yl);

    n = (unsigned long long)nl;
    x = (unsigned long long)xl;
    y = (unsigned long long)yl;

    unsigned long long* f = malloc(10000001*sizeof(unsigned long long));

    f[1] = x;
    f[2] = x < y? x + f[1] : y + f[1];

    unsigned long long k;

    for (unsigned long long m = 3; m < n+1; m++)
    {
        k = (m+1)/2;
        if (m % 2 == 1)
            f[2*k-1] = f[k]+y+x < f[2*k-2]+x ? f[k]+y+x : f[2*k-2]+x;
        else
            f[2*k] = f[k]+y < f[2*k-2]+2*x ? f[k]+y : f[2*k-2]+2*x;
    }
    unsigned long pref = f[n] / 1000000000Lu;
    unsigned long rest = f[n] % 1000000000Lu;
    int digs = 9;
    int pow10 = 100000000Lu;
    while (digs > 1)
    {
        if (rest >= pow10)
            break;
        pow10 /= 10;
        digs = digs-1;
    }
    if (pref > 0)
    {
        if (9-digs == 0)
            printf("%lu%lu\n", pref, rest);
        else
        {
            char* zeros = malloc((9-digs+1)*sizeof(char));
            for (int i = 0; i < 9-digs; i++) zeros[i] = '0';
            zeros[9-digs] = 0;
            printf("%lu%s%lu\n", pref, zeros, rest);
        }
    }
    else
        printf("%lu\n", rest);
}


#include <stdio.h>
#include <stdlib.h>

int ***sol;
int N, K;
const int kInvalidSol = -10000;
void new_sol() {
	sol = (int***)malloc(sizeof(int**) * (N + 1));
	for (int n = 0; n <= N; ++n) {
		sol[n] = (int**)malloc(sizeof(int*) * (K + 1));
		for (int k = 0; k <= K; ++k) {
			sol[n][k] = (int*)malloc(sizeof(int) * (N + 1));
			for (int i = 0; i <= N; ++i) {
				sol[n][k][i] = kInvalidSol;
			}
		}
	}
}
void free_sol() {
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= K; ++j) {
			free(sol[i][j]);
		}
		free(sol[i]);
	}
	free(sol);
}
void try_update_sol(int n, int k, int i, int value) {
	if (value >= 0 && sol[n][k][i] < value) {
		sol[n][k][i] = value;
	}
}
int imax(int a, int b) {
	return a < b? b: a;
}
int main() {
	char s[201], t[3];
	scanf("%d%d\n%s\n%s", &N, &K, s, t);
	// printf("%s\t%s\n", s, t);
	new_sol();
	if (t[0] == t[1]) {
		int cc = 0;
		for (int i = 0; i < N; ++i) {
			if (s[i] == t[0]) {
				++cc;
			}
		}
		cc += K;
		if (cc > N) {
			cc = N;
		}
		printf("%d\n", cc * (cc - 1) / 2);
	} else {
		{
			int cc = 0;
			sol[0][0][0] = 0;
			for (int n = 1; n <= N; ++n) {
				if (s[n - 1] == t[0]) {
					++cc;
					if (cc == 1) {
						sol[n][0][1] = 0;
					} else {
						try_update_sol(n, 0, cc, sol[n - 1][0][cc - 1]);
					}
				} else if (s[n - 1] == t[1]) {
					try_update_sol(n, 0, cc, sol[n - 1][0][cc] + cc);
				} else {
					try_update_sol(n, 0, cc, sol[n - 1][0][cc]);
				}
				for (int k = cc; k <= K; ++k) {
					try_update_sol(n, k, 0, 0);
				}
			}
		}
		// printf("sol k = 0\n");
		// for (int n = 1; n <= N; ++n) {
		// 	for (int i = 1; i <= n; ++i) {
		// 		printf("%d\t", sol[n][0][i]);
		// 	}
		// 	printf("\n");
		// }
		// for (int k = 1; k <= K; ++k) {
		// 	sol[1][k][1] = 0;
		// 	int cc = s[0] == t[0]? 1: 0;
		// 	for (int n = 2; n <= N; ++n) {
		// 		try_update_sol(n, k, 1, sol[n][k-1][1]);
		// 		if (s[n - 1] == t[0]) {
		// 			++cc;
		// 			try_update_sol(n, k, 1, sol[n - 1][k - 1][1] + 1);
		// 		} else if (s[n - 1] == t[1]) {
		// 			try_update_sol(n, k, 1, sol[n - 1][k][1] + 1);
		// 		} else {
		// 			try_update_sol(n, k, 1, sol[n - 1][k][1]);
		// 			try_update_sol(n, k, 1, sol[n - 1][k - 1][1] + 1);
		// 		}
		// 	}
		// }
		// printf("sol with i = 1\n");
		// for (int n = 1; n <= N; ++n) {
		// 	for (int k = 0; k <= K; ++k) {
		// 		printf("%d\t", sol[n][k][1]);
		// 	}
		// 	printf("\n");
		// }
		for (int k = 1; k <= K; ++k) {
			try_update_sol(1, k, 1, 0);
			for (int n = 2; n <= N; ++n) {
				for (int i = 1; i <= n; ++i) {
					try_update_sol(n, k, i, sol[n][k - 1][i]);
					if (s[n - 1] == t[0]) {
						try_update_sol(n, k, i, sol[n - 1][k][i - 1]);
						try_update_sol(n, k, i, sol[n - 1][k - 1][i] + i);
					} else if (s[n - 1] == t[1]) {
						try_update_sol(n, k, i, sol[n - 1][k][i] + i);
						try_update_sol(n, k, i, sol[n - 1][k - 1][i - 1]);
					} else {
							try_update_sol(n, k, i, sol[n - 1][k - 1][i - 1]);
							try_update_sol(n, k, i, sol[n - 1][k - 1][i] + i);
							try_update_sol(n, k, i, sol[n - 1][k][i]);
					}
				}
			}
			// printf("sol k = %d\n", k);
			// for (int n = 1; n <= N; ++n) {
			// 	for (int i = 1; i <= n; ++i) {
			// 		printf("%d\t", sol[n][k][i]);
			// 	}
			// 	printf("\n");
			// }
		}
		int max = 0;
		for (int i = 1; i <= N; ++i) {
			if (sol[N][K][i] > max) {
				max = sol[N][K][i];
			}
		}
		printf("%d\n", max);
		free_sol();
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int i,j,k,l,m,n;
  int x1, x2, a, b, fg, fgg;
  int mod;
  int stone;

  while(scanf("%d%d%d%d",&x1,&x2,&a,&b)==4){
    stone = x2 - x1;
    fg = 0;
    if(stone < 0) stone *= -1, k = a, a = b, b = k, a *= -1, b *= -1, fg = 1;
    if(b <= 0){ puts("DRAW"); continue; }

    fgg = 0;
    if(a <= 0) fgg = 1, a = 1;
    mod = stone % (a+b);
    if(mod == 0){
      if(fgg) puts("DRAW"); else puts("SECOND");
      continue;
    }
    if(mod < a || mod > b){
      puts("DRAW");
      continue;
    }

    if(stone > b && fgg){
      puts("DRAW");
      continue;
    }

    stone -= mod;
    puts("FIRST");
    if(fg==0) printf("%d\n",x2-stone);
    else      printf("%d\n",x2+stone);
  }

  return 0;
}