#include <stdio.h>

long long ans=0;
long long mini(long long int x ,long long int y){
	if(x > y)
		return x;
	return y;
}
long long hei(long long a,long long b,long long c,long long m)
{
     long long cnt = mini(a-b-c,m);
     if (cnt<0) return 0;
	  else
	  return (cnt+1)*(cnt+2)/2;
}
int main()
{
     long long a,b,c,l;
     cin>>a>>b>>c>>l;
     scanf("%d %d %d %d",a,b,c,l);
     ans+=(l+3)*(l+2)*(l+1)/6;
     for (long long i=0;i<=l;i++) ans-=hei(a+i,b,c,l-i)+hei(b+i,a,c,l-i)+hei(c+i,a,b,l-i);
     printf("%d", ans);
     return 0;
}


#include <stdio.h>

long long ans=0;
long long mini(long long int x ,long long int y){
	if(x > y)
		return y;
	return x;
}
long long hei(long long a,long long b,long long c,long long m)
{
     long long cnt = mini(a-b-c,m);
     if (cnt<0) return 0;
	  else
	  return (cnt+1)*(cnt+2)/2;
}
int main()
{
     long long a,b,c,l;
     long long int i = 0;
     scanf("%d %d %d %d",&a,&b,&c,&l);
     ans+=(l+3)*(l+2)*(l+1)/6;
     for (i=0;i<=l;i++)
	 ans -= (hei(a+i,b,c,l-i) + hei(b+i,a,c,l-i) + hei(c+i,a,b,l-i));
     printf("%d", ans);
     return 0;
}


#include <stdio.h>

long long ans=0;
long long mini(long long int x ,long long int y){
	if(x > y)
		return x;
	return y;
}
long long hei(long long a,long long b,long long c,long long m)
{
     long long cnt = mini(a-b-c,m);
     if (cnt<0) return 0;
	  else
	  return (cnt+1)*(cnt+2)/2;
}
int main()
{
     long long a,b,c,l;
     long long int i = 0;
     scanf("%d %d %d %d",a,b,c,l);
     ans+=(l+3)*(l+2)*(l+1)/6;
     for (i=0;i<=l;i++) ans-=hei(a+i,b,c,l-i)+hei(b+i,a,c,l-i)+hei(c+i,a,b,l-i);
     printf("%d", ans);
     return 0;
}


#include<stdio.h>
int main()
{
	int i,a;
	scanf("%d",&a);
	for(i=2;i<a;i++)
	{
		if(a%i==0)
		{
			a=a/i;
			printf("%d%d",i,a);
			break;
		}
	}
}


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

#define N	50
#define M	(N * (N - 1))
#define N_	(N + 2)
#define M_	(M * 3 + 2)
#define X	100000
#define INF	0x3f3f3f3f

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

int oo[1 + M * 2], oh[1 + M * 2], _ = 1;

int link(int o, int h) {
	oo[_] = o, oh[_] = h;
	return _++;
}

int oo_[1 + M_ * 2], oh_[1 + M_ * 2], __;

int link_(int o, int h) {
	oo_[__] = o, oh_[__] = h;
	return __++;
}

int ae[N], af[N], ae_[N_], dd[N_], n_;
int ii[M], jj[M], ww[M]; char tt[M]; int ij[M_], cc[M_ * 2], m_;
int pq[1 + N], iq[N], cnt;

int less(int u, int v) { return dd[u] < dd[v]; }

int i2(int i) {
	return (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;
}

void pq_up(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_dn(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_add_last(int u) {
	pq[iq[u] = ++cnt] = u;
}

int pq_remove_first() {
	int u = pq[1], v = pq[cnt--];

	if (v != u)
		iq[v] = 1, pq_dn(v);
	iq[u] = 0;
	return u;
}

void dijkstra(int n, int s) {
	memset(dd, 0x3f, n * sizeof *dd);
	dd[s] = 0, pq_add_last(s);
	while (cnt) {
		int i = pq_remove_first(), o;

		for (o = ae[i]; o; o = oo[o]) {
			int h = oh[o];

			if (!tt[h]) {
				int j = jj[h], d = dd[i] + ww[h];

				if (dd[j] > d) {
					if (dd[j] == INF)
						pq_add_last(j);
					dd[j] = d, pq_up(j);
				}
			}
		}
	}
}

void link2(int i, int j, int c) {
	int h = m_++;

	ij[h] = i ^ j, cc[h << 1] = c, cc[h << 1 | 1] = 0;
	ae_[i] = link_(ae_[i], h << 1);
	ae_[j] = link_(ae_[j], h << 1 | 1);
}

int bfs(int s, int t) {
	static int qu[N_];
	int i, head, cnt;

	for (i = 0; i < n_; i++)
		dd[i] = n_;
	head = cnt = 0;
	dd[s] = 0, qu[head + cnt++] = s;
	while (cnt) {
		int d, o;

		i = qu[cnt--, head++], d = dd[i] + 1;
		for (o = ae_[i]; o; o = oo_[o]) {
			int h_ = oh_[o];

			if (cc[h_]) {
				int h = h_ >> 1, j = i ^ ij[h];

				if (dd[j] > d) {
					dd[j] = d;
					if (j == t)
						return 1;
					qu[head + cnt++] = j;
				}
			}
		}
	}
	return 0;
}

int dfs(int i, int t) {
	int d, o;

	if (i == t)
		return 1;
	d = dd[i] + 1;
	for (o = ae_[i]; o; o = oo_[o]) {
		int h_ = oh_[o];

		if (cc[h_]) {
			int h = h_ >> 1, j = i ^ ij[h];

			if (dd[j] == d && dfs(j, t)) {
				cc[h_]--, cc[h_ ^ 1]++;
				return 1;
			}
		}
	}
	dd[i] = n_;
	return 0;
}

void dinic(int s, int t) {
	while (bfs(s, t))
		while (dfs(s, t))
			;
}

char reachable[N];

void dfs_(int j) {
	int o;

	if (reachable[j])
		return;
	reachable[j] = 1;
	for (o = af[j]; o; o = oo[o]) {
		int h = oh[o], i = ii[h];

		dfs_(i);
	}
}

int main() {
	static double ans[X + 1];
	static int dd1[N], dd2[N], xx[M];
	int n, m, q, h, x, s, t;

	scanf("%d%d", &n, &m);
	for (h = 0; h < m; h++) {
		int i, j, w;

		scanf("%d%d%d", &i, &j, &w), i--, j--;
		ii[h] = i, jj[h] = j, ww[h] = w;
		ae[i] = link(ae[i], h);
	}
	n_ = n + 2, s = n, t = n + 1;
	x = 0;
	while (x < X) {
		int k, y, z, d, d_;

		memset(tt, 0, m * sizeof *tt);
		dijkstra(n, 0);
		memcpy(dd1, dd, n * sizeof *dd);
		d = dd1[n - 1];
		memset(ae_, 0, n_ * sizeof *ae_), __ = 1, m_ = 0;
		link2(s, 0, INF);
		link2(n - 1, t, INF);
		for (h = 0; h < m; h++) {
			int i = ii[h], j = jj[h], w = ww[h];

			if (dd1[i] + w == dd1[j]) {
				tt[h] = 1;
				link2(s, j, 1), link2(i, t, 1);
				if (xx[h] == 0)
					link2(j, i, INF);
			}
		}
		dinic(s, t);
		d_ = INF;
		k = 0;
		memset(af, 0, n * sizeof *af), _ = 1 + m;
		for (h = 0; h < m; h++) {
			int i = ii[h], j = jj[h];

			if (tt[h]) {
				if ((dd[i] == n_) == (dd[j] == n_)) {
					tt[h] = 0;
					af[j] = link(af[j], h);
				} else if (dd[i] != n_) {
					tt[h] = 1;
					k++;
				} else {
					tt[h] = 2;
					k--;
					d_ = min(d_, d + xx[h]);
				}
			}
		}
		memset(reachable, 0, n * sizeof *reachable);
		dfs_(n - 1);
		dijkstra(n, 0);
		memcpy(dd2, dd, n * sizeof *dd);
		d_ = min(d_, dd2[n - 1]);
		for (h = 0; h < m; h++)
			if (tt[h] == 2 && dd2[ii[h]] != INF && dd1[jj[h]] != INF && reachable[jj[h]])
				d_ = min(d_, d + dd2[ii[h]] + ww[h] - dd1[jj[h]]);
		y = d_ - d <= (X - x) / k ? x + (d_ - d) * k : X;
		for (z = x; z <= y; z++)
			ans[z] = d + (double) (z - x) / k;
		if (y < X) {
			for (h = 0; h < m; h++)
				if (tt[h] == 1)
					ww[h] += d_ - d, xx[h] += d_ - d;
				else if (tt[h] == 2)
					ww[h] -= d_ - d, xx[h] -= d_ - d;
		}
		x = y;
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &x);
		printf("%f\n", ans[x]);
	}
	return 0;
}


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

#define N	50
#define M	(N * (N - 1))
#define N_	(N + 2)
#define M_	(M * 3 + 2)
#define X	100000
#define INF	0x3f3f3f3f

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

int oo[1 + M * 2], oh[1 + M * 2], _ = 1;

int link(int o, int h) {
	oo[_] = o, oh[_] = h;
	return _++;
}

int oo_[1 + M_ * 2], oh_[1 + M_ * 2], __;

int link_(int o, int h) {
	oo_[__] = o, oh_[__] = h;
	return __++;
}

int ae[N], af[N], ae_[N_], dd[N_], n_;
int ii[M], jj[M], ww[M]; char tt[M]; int ij[M_], cc[M_ * 2], m_;
int pq[1 + N], iq[N], cnt;

int less(int u, int v) { return dd[u] < dd[v]; }

int i2(int i) {
	return (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;
}

void pq_up(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_dn(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_add_last(int u) {
	pq[iq[u] = ++cnt] = u;
}

int pq_remove_first() {
	int u = pq[1], v = pq[cnt--];

	if (v != u)
		iq[v] = 1, pq_dn(v);
	iq[u] = 0;
	return u;
}

void dijkstra(int n, int s) {
	memset(dd, 0x3f, n * sizeof *dd);
	dd[s] = 0, pq_add_last(s);
	while (cnt) {
		int i = pq_remove_first(), o;

		for (o = ae[i]; o; o = oo[o]) {
			int h = oh[o];

			if (!tt[h]) {
				int j = jj[h], d = dd[i] + ww[h];

				if (dd[j] > d) {
					if (dd[j] == INF)
						pq_add_last(j);
					dd[j] = d, pq_up(j);
				}
			}
		}
	}
}

void link2(int i, int j, int c) {
	int h = m_++;

	ij[h] = i ^ j, cc[h << 1] = c, cc[h << 1 | 1] = 0;
	ae_[i] = link_(ae_[i], h << 1);
	ae_[j] = link_(ae_[j], h << 1 | 1);
}

int bfs(int s, int t) {
	static int qu[N_];
	int i, head, cnt;

	for (i = 0; i < n_; i++)
		dd[i] = n_;
	head = cnt = 0;
	dd[s] = 0, qu[head + cnt++] = s;
	while (cnt) {
		int d, o;

		i = qu[cnt--, head++], d = dd[i] + 1;
		for (o = ae_[i]; o; o = oo_[o]) {
			int h_ = oh_[o];

			if (cc[h_]) {
				int h = h_ >> 1, j = i ^ ij[h];

				if (dd[j] > d) {
					dd[j] = d;
					if (j == t)
						return 1;
					qu[head + cnt++] = j;
				}
			}
		}
	}
	return 0;
}

int dfs(int i, int t) {
	int d, o;

	if (i == t)
		return 1;
	d = dd[i] + 1;
	for (o = ae_[i]; o; o = oo_[o]) {
		int h_ = oh_[o];

		if (cc[h_]) {
			int h = h_ >> 1, j = i ^ ij[h];

			if (dd[j] == d && dfs(j, t)) {
				cc[h_]--, cc[h_ ^ 1]++;
				return 1;
			}
		}
	}
	dd[i] = n_;
	return 0;
}

void dinic(int s, int t) {
	while (bfs(s, t))
		while (dfs(s, t))
			;
}

char reachable[N];

void dfs_(int j) {
	int o;

	if (reachable[j])
		return;
	reachable[j] = 1;
	for (o = af[j]; o; o = oo[o]) {
		int h = oh[o], i = ii[h];

		dfs_(i);
	}
}

int main() {
	static double ans[X + 1];
	static int dd1[N], dd2[N], xx[M];
	int n, m, q, h, x, s, t;

	scanf("%d%d", &n, &m);
	for (h = 0; h < m; h++) {
		int i, j, w;

		scanf("%d%d%d", &i, &j, &w), i--, j--;
		ii[h] = i, jj[h] = j, ww[h] = w;
		ae[i] = link(ae[i], h);
	}
	n_ = n + 2, s = n, t = n + 1;
	x = 0;
	while (x < X) {
		int k, y, z, d, d_;

		memset(tt, 0, m * sizeof *tt);
		dijkstra(n, 0);
		memcpy(dd1, dd, n * sizeof *dd);
		d = dd1[n - 1];
		memset(ae_, 0, n_ * sizeof *ae_), __ = 1, m_ = 0;
		link2(s, 0, INF);
		link2(n - 1, t, INF);
		for (h = 0; h < m; h++) {
			int i = ii[h], j = jj[h], w = ww[h];

			if (dd1[i] + w == dd1[j]) {
				tt[h] = 1;
				link2(s, j, 1), link2(i, t, 1);
				if (xx[h] == 0)
					link2(j, i, INF);
			}
		}
		dinic(s, t);
		d_ = INF;
		k = 0;
		memset(af, 0, n * sizeof *af), _ = 1 + m;
		for (h = 0; h < m; h++) {
			int i = ii[h], j = jj[h];

			if (tt[h]) {
				if ((dd[i] == n_) == (dd[j] == n_)) {
					tt[h] = 0;
					af[j] = link(af[j], h);
				} else if (dd[i] != n_) {
					tt[h] = 1;
					k++;
				} else {
					tt[h] = 2;
					k--;
					d_ = min(d_, d + xx[h]);
				}
			}
		}
		memset(reachable, 0, n * sizeof *reachable);
		dfs_(n - 1);
		dijkstra(n, 0);
		memcpy(dd2, dd, n * sizeof *dd);
		d_ = min(d_, dd2[n - 1]);
		for (h = 0; h < m; h++)
			if (tt[h] == 2 && dd2[ii[h]] != INF && dd1[jj[h]] != INF && reachable[jj[h]])
				d_ = min(d_, d + dd2[ii[h]] - dd1[jj[h]]);
		y = d_ - d <= (X - x) / k ? x + (d_ - d) * k : X;
		for (z = x; z <= y; z++)
			ans[z] = d + (double) (z - x) / k;
		if (y < X) {
			for (h = 0; h < m; h++)
				if (tt[h] == 1)
					ww[h] += d_ - d, xx[h] += d_ - d;
				else if (tt[h] == 2)
					ww[h] -= d_ - d, xx[h] -= d_ - d;
		}
		x = y;
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &x);
		printf("%f\n", ans[x]);
	}
	return 0;
}


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

#define N	50
#define M	(N * (N - 1))
#define N_	(N + 2)
#define M_	(M * 3 + 2)
#define X	100000
#define INF	0x3f3f3f3f

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

int oo[1 + M * 2], oh[1 + M * 2], _ = 1;

int link(int o, int h) {
	oo[_] = o, oh[_] = h;
	return _++;
}

int oo_[1 + M_ * 2], oh_[1 + M_ * 2], __;

int link_(int o, int h) {
	oo_[__] = o, oh_[__] = h;
	return __++;
}

int ae[N], af[N], ae_[N_], dd[N_], n_;
int ii[M], jj[M], ww[M]; char tt[M]; int ij[M_], cc[M_ * 2], m_;
int pq[1 + N], iq[N], cnt;

int less(int u, int v) { return dd[u] < dd[v]; }

int i2(int i) {
	return (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;
}

void pq_up(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_dn(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_add_last(int u) {
	pq[iq[u] = ++cnt] = u;
}

int pq_remove_first() {
	int u = pq[1], v = pq[cnt--];

	if (v != u)
		iq[v] = 1, pq_dn(v);
	iq[u] = 0;
	return u;
}

void dijkstra(int n, int s) {
	memset(dd, 0x3f, n * sizeof *dd);
	dd[s] = 0, pq_add_last(s);
	while (cnt) {
		int i = pq_remove_first(), o;

		for (o = ae[i]; o; o = oo[o]) {
			int h = oh[o];

			if (!tt[h]) {
				int j = jj[h], d = dd[i] + ww[h];

				if (dd[j] > d) {
					if (dd[j] == INF)
						pq_add_last(j);
					dd[j] = d, pq_up(j);
				}
			}
		}
	}
}

void link2(int i, int j, int c) {
	int h = m_++;

	ij[h] = i ^ j, cc[h << 1] = c, cc[h << 1 | 1] = 0;
	ae_[i] = link_(ae_[i], h << 1);
	ae_[j] = link_(ae_[j], h << 1 | 1);
}

int bfs(int s, int t) {
	static int qu[N_];
	int i, head, cnt;

	for (i = 0; i < n_; i++)
		dd[i] = n_;
	head = cnt = 0;
	dd[s] = 0, qu[head + cnt++] = s;
	while (cnt) {
		int d, o;

		i = qu[cnt--, head++], d = dd[i] + 1;
		for (o = ae_[i]; o; o = oo_[o]) {
			int h_ = oh_[o];

			if (cc[h_]) {
				int h = h_ >> 1, j = i ^ ij[h];

				if (dd[j] > d) {
					dd[j] = d;
					if (j == t)
						return 1;
					qu[head + cnt++] = j;
				}
			}
		}
	}
	return 0;
}

int dfs(int i, int t) {
	int d, o;

	if (i == t)
		return 1;
	d = dd[i] + 1;
	for (o = ae_[i]; o; o = oo_[o]) {
		int h_ = oh_[o];

		if (cc[h_]) {
			int h = h_ >> 1, j = i ^ ij[h];

			if (dd[j] == d && dfs(j, t)) {
				cc[h_]--, cc[h_ ^ 1]++;
				return 1;
			}
		}
	}
	dd[i] = n_;
	return 0;
}

void dinic(int s, int t) {
	while (bfs(s, t))
		while (dfs(s, t))
			;
}

char reachable[N];

void dfs_(int j) {
	int o;

	if (reachable[j])
		return;
	reachable[j] = 1;
	for (o = af[j]; o; o = oo[o]) {
		int h = oh[o], i = ii[h];

		dfs_(i);
	}
}

int main() {
	static double ans[X + 1];
	static int dd1[N], dd2[N], xx[M];
	int n, m, q, h, x, s, t;

	scanf("%d%d", &n, &m);
	for (h = 0; h < m; h++) {
		int i, j, w;

		scanf("%d%d%d", &i, &j, &w), i--, j--;
		ii[h] = i, jj[h] = j, ww[h] = w;
		ae[i] = link(ae[i], h);
	}
	n_ = n + 2, s = n, t = n + 1;
	x = 0;
	while (x < X) {
		int k, y, z, d, d_;

		memset(tt, 0, m * sizeof *tt);
		dijkstra(n, 0);
		memcpy(dd1, dd, n * sizeof *dd);
		d = dd1[n - 1];
		memset(ae_, 0, n_ * sizeof *ae_), __ = 1, m_ = 0;
		link2(s, 0, INF);
		link2(n - 1, t, INF);
		for (h = 0; h < m; h++) {
			int i = ii[h], j = jj[h], w = ww[h];

			if (dd1[i] + w == dd1[j]) {
				tt[h] = 1;
				link2(s, j, 1), link2(i, t, 1);
				if (xx[h] == 0)
					link2(j, i, INF);
			}
		}
		dinic(s, t);
		d_ = INF;
		k = 0;
		memset(af, 0, n * sizeof *af), _ = 1 + m;
		for (h = 0; h < m; h++) {
			int i = ii[h], j = jj[h];

			if (tt[h]) {
				if ((dd[i] == n_) == (dd[j] == n_)) {
					tt[h] = 0;
					af[j] = link(af[j], h);
				} else if (dd[i] != n_) {
					tt[h] = 1;
					k++;
				} else {
					tt[h] = 2;
					k--;
					d_ = min(d_, d + xx[h]);
				}
			}
		}
		memset(reachable, 0, n * sizeof *reachable);
		dfs_(n - 1);
		dijkstra(n, 0);
		memcpy(dd2, dd, n * sizeof *dd);
		d_ = min(d_, dd2[n - 1]);
		for (h = 0; h < m; h++)
			if (tt[h] == 2 && dd2[ii[h]] != INF && reachable[jj[h]])
				d_ = min(d_, d + dd2[ii[h]] - dd1[jj[h]]);
		y = d_ - d <= (X - x) / k ? x + (d_ - d) * k : X;
		for (z = x; z <= y; z++)
			ans[z] = d + (double) (z - x) / k;
		if (y < X) {
			for (h = 0; h < m; h++)
				if (tt[h] == 1)
					ww[h] += d_ - d, xx[h] += d_ - d;
				else if (tt[h] == 2)
					ww[h] -= d_ - d, xx[h] -= d_ - d;
		}
		x = y;
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &x);
		printf("%f\n", ans[x]);
	}
	return 0;
}


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

#define N	50
#define M	(N * (N - 1))
#define N_	(N + 2)
#define M_	(M * 3 + 2)
#define X	100000
#define INF	0x3f3f3f3f

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

int oo[1 + M], oh[1 + M], _ = 1;

int link(int o, int h) {
	oo[_] = o, oh[_] = h;
	return _++;
}

int oo_[1 + M_ * 2], oh_[1 + M_ * 2], __;

int link_(int o, int h) {
	oo_[__] = o, oh_[__] = h;
	return __++;
}

int ae[N], af[N], ae_[N_], dd[N_], n_;
int ii[M], jj[M], ww[M]; char tt[M]; int ij[M_], cc[M_ * 2], m_;
int pq[1 + N], iq[N], cnt;

int less(int u, int v) { return dd[u] < dd[v]; }

int i2(int i) {
	return (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;
}

void pq_up(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_dn(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_add_last(int u) {
	pq[iq[u] = ++cnt] = u;
}

int pq_remove_first() {
	int u = pq[1], v = pq[cnt--];

	if (v != u)
		iq[v] = 1, pq_dn(v);
	iq[u] = 0;
	return u;
}

void dijkstra(int n, int s) {
	memset(dd, 0x3f, n * sizeof *dd);
	dd[s] = 0, pq_add_last(s);
	while (cnt) {
		int i = pq_remove_first(), o;

		for (o = ae[i]; o; o = oo[o]) {
			int h = oh[o];

			if (!tt[h]) {
				int j = jj[h], d = dd[i] + ww[h];

				if (dd[j] > d) {
					if (dd[j] == INF)
						pq_add_last(j);
					dd[j] = d, pq_up(j);
				}
			}
		}
	}
}

void link2(int i, int j, int c) {
	int h = m_++;

	ij[h] = i ^ j, cc[h << 1] = c, cc[h << 1 | 1] = 0;
	ae_[i] = link_(ae_[i], h << 1);
	ae_[j] = link_(ae_[j], h << 1 | 1);
}

int bfs(int s, int t) {
	static int qu[N_];
	int i, head, cnt;

	for (i = 0; i < n_; i++)
		dd[i] = n_;
	head = cnt = 0;
	dd[s] = 0, qu[head + cnt++] = s;
	while (cnt) {
		int d, o;

		i = qu[cnt--, head++], d = dd[i] + 1;
		for (o = ae_[i]; o; o = oo_[o]) {
			int h_ = oh_[o];

			if (cc[h_]) {
				int h = h_ >> 1, j = i ^ ij[h];

				if (dd[j] > d) {
					dd[j] = d;
					if (j == t)
						return 1;
					qu[head + cnt++] = j;
				}
			}
		}
	}
	return 0;
}

int dfs(int i, int t) {
	int d, o;

	if (i == t)
		return 1;
	d = dd[i] + 1;
	for (o = ae_[i]; o; o = oo_[o]) {
		int h_ = oh_[o];

		if (cc[h_]) {
			int h = h_ >> 1, j = i ^ ij[h];

			if (dd[j] == d && dfs(j, t)) {
				cc[h_]--, cc[h_ ^ 1]++;
				return 1;
			}
		}
	}
	dd[i] = n_;
	return 0;
}

void dinic(int s, int t) {
	while (bfs(s, t))
		while (dfs(s, t))
			;
}

char reachable[N];

void dfs_(int j) {
	int o;

	if (reachable[j])
		return;
	reachable[j] = 1;
	for (o = af[j]; o; o = oo[o]) {
		int h = oh[o], i = ii[h];

		dfs_(i);
	}
}

int main() {
	static double ans[X + 1];
	static int dd1[N], dd2[N], xx[M];
	int n, m, q, h, x, s, t;

	scanf("%d%d", &n, &m);
	for (h = 0; h < m; h++) {
		int i, j, w;

		scanf("%d%d%d", &i, &j, &w), i--, j--;
		ii[h] = i, jj[h] = j, ww[h] = w;
		ae[i] = link(ae[i], h);
	}
	n_ = n + 2, s = n, t = n + 1;
	x = 0;
	while (x < X) {
		int k, y, z, d, d_;

		memset(tt, 0, m * sizeof *tt);
		dijkstra(n, 0);
		memcpy(dd1, dd, n * sizeof *dd);
		d = dd1[n - 1];
		memset(ae_, 0, n_ * sizeof *ae_), __ = 1, m_ = 0;
		link2(s, 0, INF);
		link2(n - 1, t, INF);
		for (h = 0; h < m; h++) {
			int i = ii[h], j = jj[h], w = ww[h];

			if (dd1[i] + w == dd1[j]) {
				tt[h] = 1;
				link2(s, j, 1), link2(i, t, 1);
				if (xx[h] == 0)
					link2(j, i, INF);
			}
		}
		dinic(s, t);
		d_ = INF;
		k = 0;
		_ = 1 + m;
		for (h = 0; h < m; h++) {
			int i = ii[h], j = jj[h];

			if (tt[h]) {
				if ((dd[i] == n_) == (dd[j] == n_)) {
					tt[h] = 0;
					af[j] = link(af[j], h);
				} else if (dd[i] != n_) {
					tt[h] = 1;
					k++;
				} else {
					tt[h] = 2;
					k--;
					d_ = min(d_, d + xx[h]);
				}
			}
		}
		memset(reachable, 0, n * sizeof *reachable);
		dfs_(n - 1);
		dijkstra(n, 0);
		memcpy(dd2, dd, n * sizeof *dd);
		d_ = min(d_, dd2[n - 1]);
		for (h = 0; h < m; h++)
			if (tt[h] == 2 && dd2[ii[h]] != INF && reachable[jj[h]])
				d_ = min(d_, d + dd2[ii[h]] - dd1[jj[h]]);
		y = d_ - d <= (X - x) / k ? x + (d_ - d) * k : X;
		for (z = x; z <= y; z++)
			ans[z] = d + (double) (z - x) / k;
		if (y < X) {
			for (h = 0; h < m; h++)
				if (tt[h] == 1)
					ww[h] += d_ - d, xx[h] += d_ - d;
				else if (tt[h] == 2)
					ww[h] -= d_ - d, xx[h] -= d_ - d;
		}
		x = y;
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &x);
		printf("%f\n", ans[x]);
	}
	return 0;
}


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

#define N	50
#define M	(N * (N - 1))
#define N_	(N + 2)
#define M_	(M * 3 + 2)
#define X	100000
#define INF	0x3f3f3f3f

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

int oo[1 + M], oh[1 + M], _ = 1;

int link(int o, int h) {
	oo[_] = o, oh[_] = h;
	return _++;
}

int oo_[1 + M_ * 2], oh_[1 + M_ * 2], __;

int link_(int o, int h) {
	oo_[__] = o, oh_[__] = h;
	return __++;
}

int ae[N], af[N], ae_[N_], dd[N_], n_;
int ii[M], jj[M], ww[M]; char tt[M]; int ij[M_], cc[M_ * 2], m_;
int pq[1 + N], iq[N], cnt;

int less(int u, int v) { return dd[u] < dd[v]; }

int i2(int i) {
	return (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;
}

void pq_up(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_dn(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_add_last(int u) {
	pq[iq[u] = ++cnt] = u;
}

int pq_remove_first() {
	int u = pq[1], v = pq[cnt--];

	if (v != u)
		iq[v] = 1, pq_dn(v);
	iq[u] = 0;
	return u;
}

void dijkstra(int n, int s) {
	memset(dd, 0x3f, n * sizeof *dd);
	dd[s] = 0, pq_add_last(s);
	while (cnt) {
		int i = pq_remove_first(), o;

		for (o = ae[i]; o; o = oo[o]) {
			int h = oh[o];

			if (!tt[h]) {
				int j = jj[h], d = dd[i] + ww[h];

				if (dd[j] > d) {
					if (dd[j] == INF)
						pq_add_last(j);
					dd[j] = d, pq_up(j);
				}
			}
		}
	}
}

void link2(int i, int j, int c) {
	int h = m_++;

	ij[h] = i ^ j, cc[h << 1] = c, cc[h << 1 | 1] = 0;
	ae_[i] = link_(ae_[i], h << 1);
	ae_[j] = link_(ae_[j], h << 1 | 1);
}

int bfs(int s, int t) {
	static int qu[N_];
	int i, head, cnt;

	for (i = 0; i < n_; i++)
		dd[i] = n_;
	head = cnt = 0;
	dd[s] = 0, qu[head + cnt++] = s;
	while (cnt) {
		int d, o;

		i = qu[cnt--, head++], d = dd[i] + 1;
		for (o = ae_[i]; o; o = oo_[o]) {
			int h_ = oh_[o];

			if (cc[h_]) {
				int h = h_ >> 1, j = i ^ ij[h];

				if (dd[j] > d) {
					dd[j] = d;
					if (j == t)
						return 1;
					qu[head + cnt++] = j;
				}
			}
		}
	}
	return 0;
}

int dfs(int i, int t) {
	int d, o;

	if (i == t)
		return 1;
	d = dd[i] + 1;
	for (o = ae_[i]; o; o = oo_[o]) {
		int h_ = oh_[o];

		if (cc[h_]) {
			int h = h_ >> 1, j = i ^ ij[h];

			if (dd[j] == d && dfs(j, t)) {
				cc[h_]--, cc[h_ ^ 1]++;
				return 1;
			}
		}
	}
	dd[i] = n_;
	return 0;
}

void dinic(int s, int t) {
	while (bfs(s, t))
		while (dfs(s, t))
			;
}

char reachable[N];

void dfs_(int j) {
	int o;

	if (reachable[j])
		return;
	reachable[j] = 1;
	for (o = af[j]; o; o = oo[o]) {
		int h = oh[o], i = ii[h];

		dfs_(i);
	}
}

int main() {
	static double ans[X + 1];
	static int dd1[N], dd2[N], xx[M];
	int n, m, q, h, x, s, t;

	scanf("%d%d", &n, &m);
	for (h = 0; h < m; h++) {
		int i, j, w;

		scanf("%d%d%d", &i, &j, &w), i--, j--;
		ii[h] = i, jj[h] = j, ww[h] = w;
		ae[i] = link(ae[i], h);
	}
	n_ = n + 2, s = n, t = n + 1;
	x = 0;
	while (x < X) {
		int k, y, z, d, d_;

		memset(tt, 0, m * sizeof *tt);
		dijkstra(n, 0);
		memcpy(dd1, dd, n * sizeof *dd);
		d = dd1[n - 1];
		memset(ae_, 0, n_ * sizeof *ae_), __ = 1, m_ = 0;
		link2(s, 0, INF);
		link2(n - 1, t, INF);
		for (h = 0; h < m; h++) {
			int i = ii[h], j = jj[h], w = ww[h];

			if (dd1[i] + w == dd1[j]) {
				tt[h] = 1;
				link2(s, j, 1), link2(i, t, 1);
				if (xx[h] == 0)
					link2(j, i, INF);
			}
		}
		dinic(s, t);
		d_ = INF;
		k = 0;
		memset(af, 0, n * sizeof *af), _ = 1 + m;
		for (h = 0; h < m; h++) {
			int i = ii[h], j = jj[h];

			if (tt[h]) {
				if ((dd[i] == n_) == (dd[j] == n_)) {
					tt[h] = 0;
					af[j] = link(af[j], h);
				} else if (dd[i] != n_) {
					tt[h] = 1;
					k++;
				} else {
					tt[h] = 2;
					k--;
					d_ = min(d_, d + xx[h]);
				}
			}
		}
		memset(reachable, 0, n * sizeof *reachable);
		dfs_(n - 1);
		dijkstra(n, 0);
		memcpy(dd2, dd, n * sizeof *dd);
		d_ = min(d_, dd2[n - 1]);
		for (h = 0; h < m; h++)
			if (tt[h] == 2 && dd2[ii[h]] != INF && reachable[jj[h]])
				d_ = min(d_, d + dd2[ii[h]] - dd1[jj[h]]);
		y = d_ - d <= (X - x) / k ? x + (d_ - d) * k : X;
		for (z = x; z <= y; z++)
			ans[z] = d + (double) (z - x) / k;
		if (y < X) {
			for (h = 0; h < m; h++)
				if (tt[h] == 1)
					ww[h] += d_ - d, xx[h] += d_ - d;
				else if (tt[h] == 2)
					ww[h] -= d_ - d, xx[h] -= d_ - d;
		}
		x = y;
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &x);
		printf("%f\n", ans[x]);
	}
	return 0;
}


#include <stdio.h>
#include <memory.h>

int flag[5][5];
int flag2[5][5];
int mark[10];
int ans ;

int
dfs(int depth){
    int i,j,count,index;
    if(depth ==0){
        for(i=0;i<5;i++){
            for(j=0;j<5;j++){
                flag2[i][j] = flag[i][j];
            }
        }

        for(i=0;i<5;i++){
            for(j=0;j<5;j++){
                if(mark[i] && mark[j+5]){
                    flag2[i][j]=0;
                }
            }
        }
        for(i=0 ;i<10 ;i++){
            if(! mark[i] )
                continue;
            if ( i < 5){
                count=0;
                index=0;
                for(j=0;j<5;j++){
                    if(flag2[i][j]){
                        count ++;
                        index = j;
                    }
                }
                if( count >1 ){
                    return 0;
                }
                flag2[i][index]=0;
            }
            else {
                count=0;
                index =0;
                for(j=0;j<5;j++){
                    if(flag2[j][i-5]){
                        count ++;
                        index =j;
                    }
                }
                if( count >1 ){
                    return 0;
                }
                flag2[index][i-5]=0;
            }
        }
        count =0 ;
        for(i=0;i<5;i++){
            for(j=0;j<5;j++){
                if(flag2[i][j]){
                    count++;
                }
            }
        }
        if(count ==1)
            return 1;
        else
            return 0;
    }
    for(i=0;i<10;i++){
        if(mark[i])
            continue;
        mark[i] = 1;
        if(!dfs(depth-1))
            mark[i] =0;
        else
            return 1;
    }
    return 0;
}

int
main(int argc,
     char *argv[]){
    int n;
    while( scanf("%d",&n) !=-1 ){
        char card[2];
        char color[5] ={'R','G','B','Y','W'};
        int i,j;
        memset(flag,0,sizeof(flag));
        for(i=0;i<n;i++){
            scanf("%s",card);
            for(j=0;j<5;j++){
                if(card[0] == color [j]){
                    flag[j][card[1]-'1'] ++;
                }
            }
        }
        /* if(n==4) { */
        /*     for(i=0;i<5;i++){ */
        /*         for(j=0;j<5;j++){ */
        /*             printf("%d ", flag[i][j]); */
        /*         } */
        /*         printf("\n"); */
        /*     } */
        /* } */
        for(i=0;i<=10;i++){
            memset(mark,0,sizeof(mark));
            if(dfs(i)) {
                printf("%d\n",i);
                break;
            }
        }
    }

    return 0;
}


#include <stdio.h>
#include <memory.h>

int flag[5][5];
int flag2[5][5];
int mark[10];
int ans ;

int
dfs(int depth){
    int i,j,count,index;
    if(depth ==0){
        for(i=0;i<5;i++){
            for(j=0;j<5;j++){
                flag2[i][j] = flag[i][j];
            }
        }

        for(i=0;i<5;i++){
            for(j=0;j<5;j++){
                if(mark[i] && mark[j+5]){
                    flag2[i][j]=0;
                }
            }
        }
        for(i=0 ;i<10 ;i++){
            if(! mark[i] )
                continue;
            if ( i < 5){
                count=0;
                index=0;
                for(j=0;j<5;j++){
                    if(flag2[i][j]){
                        count ++;
                        index = j;
                    }
                }
                if( count >1 ){
                    return 0;
                }
                flag2[i][index]=0;
            }
            else {
                count=0;
                index =0;
                for(j=0;j<5;j++){
                    if(flag2[j][i-5]){
                        count ++;
                        index =j;
                    }
                }
                if( count >1 ){
                    return 0;
                }
                flag2[index][i-5]=0;
            }
        }
        count =0 ;
        for(i=0;i<5;i++){
            for(j=0;j<5;j++){
                if(flag2[i][j]){
                    count++;
                }
            }
        }
        if(count ==1)
            return 1;
        else
            return 0;
    }
    for(i=0;i<10;i++){
        if(mark[i])
            continue;
        mark[i] = 1;
        if(!dfs(depth-1))
            mark[i] =0;
        else
            return 1;
    }
    return 0;
}

int
main(int argc,
     char *argv[]){
    int n;
    int testcase =0;
    while( scanf("%d",&n) !=-1 ){
        testcase ++;
        char card[2];
        char color[5] ={'R','G','B','Y','W'};
        int i,j;
        memset(flag,0,sizeof(flag));
        for(i=0;i<n;i++){
            scanf("%s",card);
            for(j=0;j<5;j++){
                if(card[0] == color [j]){
                    flag[j][card[1]-'1'] ++;
                }
            }
        }
        if(testcase==0){
            printf("0\n");
            continue ;
        }
        /* if(n==4) { */
        /*     for(i=0;i<5;i++){ */
        /*         for(j=0;j<5;j++){ */
        /*             printf("%d ", flag[i][j]); */
        /*         } */
        /*         printf("\n"); */
        /*     } */
        /* } */
        for(i=0;i<=10;i++){
            memset(mark,0,sizeof(mark));
            if(dfs(i)) {
                printf("%d\n",i);
                break;
            }
        }
    }

    return 0;
}


#include <stdio.h>
#include <memory.h>

int flag[5][5];
int flag2[5][5];
int mark[10];
int ans ;

int
dfs(int depth){
    int i,j,count,index;
    if(depth ==0){
        for(i=0;i<5;i++){
            for(j=0;j<5;j++){
                flag2[i][j] = flag[i][j];
            }
        }

        for(i=0;i<5;i++){
            for(j=0;j<5;j++){
                if(mark[i] && mark[j+5]){
                    flag2[i][j]=0;
                }
            }
        }
        for(i=0 ;i<10 ;i++){
            if(! mark[i] )
                continue;
            if ( i < 5){
                count=0;
                index=0;
                for(j=0;j<5;j++){
                    if(flag2[i][j]){
                        count ++;
                        index = j;
                    }
                }
                if( count >1 ){
                    return 0;
                }
                flag2[i][index]=0;
            }
            else {
                count=0;
                index =0;
                for(j=0;j<5;j++){
                    if(flag2[j][i-5]){
                        count ++;
                        index =j;
                    }
                }
                if( count >1 ){
                    return 0;
                }
                flag2[index][i-5]=0;
            }
        }
        count =0 ;
        for(i=0;i<5;i++){
            for(j=0;j<5;j++){
                if(flag2[i][j]){
                    count++;
                }
            }
        }
        if(count ==1)
            return 1;
        else
            return 0;
    }
    for(i=0;i<10;i++){
        if(mark[i])
            continue;
        mark[i] = 1;
        if(!dfs(depth-1))
            mark[i] =0;
        else
            return 1;
    }
    return 0;
}

int
main(int argc,
     char *argv[]){
    int n;
    int testcase =0;
    while( scanf("%d",&n) !=EOF ){
        testcase ++;
        char card[2];
        char color[5] ={'R','G','B','Y','W'};
        int i,j;
        memset(flag,0,sizeof(flag));
        for(i=0;i<n;i++){
            scanf("%s",card);
            for(j=0;j<5;j++){
                if(card[0] == color [j]){
                    flag[j][card[1]-'1'] ++;
                }
            }
        }
        if(testcase==0){
            printf("0\n");
            continue ;
        }
        /* if(n==4) { */
        /*     for(i=0;i<5;i++){ */
        /*         for(j=0;j<5;j++){ */
        /*             printf("%d ", flag[i][j]); */
        /*         } */
        /*         printf("\n"); */
        /*     } */
        /* } */
        for(i=0;i<=10;i++){
            memset(mark,0,sizeof(mark));
            if(dfs(i)) {
                printf("%d\n",i);
                break;
            }
        }
    }

    return 0;
}


#include <stdio.h>
#include <memory.h>

int flag[5][5];
int flag2[5][5];
int mark[10];
int ans ;

int
dfs(int depth){
    if(depth ==0){

        for(int i=0;i<5;i++){
            for(int j=0;j<5;j++){
                flag2[i][j] = flag[i][j];
            }
        }

        for(int i=0;i<5;i++){
            for(int j=0;j<5;j++){
                if(mark[i] && mark[j+5]){
                    flag2[i][j]=0;
                }
            }
        }
        for(int i=0 ;i<10 ;i++){
            if(! mark[i] )
                continue;
            if ( i < 5){
                int count=0;
                int index=0;
                for(int j=0;j<5;j++){
                    if(flag2[i][j]){
                        count ++;
                        index = j;
                    }
                }
                if( count >1 ){
                    return 0;
                }
                flag2[i][index]=0;
            }
            else {
                int count=0;
                int index =0;
                for(int j=0;j<5;j++){
                    if(flag2[j][i-5]){
                        count ++;
                        index =j;
                    }
                }
                if( count >1 ){
                    return 0;
                }
                flag2[index][i-5]=0;
            }
        }
        int count =0 ;
        for(int i=0;i<5;i++){
            for(int j=0;j<5;j++){
                if(flag2[i][j]){
                    count++;
                }
            }
        }
        if(count ==1)
            return 1;
        else
            return 0;
    }
    for(int i=0;i<10;i++){
        if(mark[i])
            continue;
        mark[i] = 1;
        if(!dfs(depth-1))
            mark[i] =0;
        else
            return 1;
    }
    return 0;
}

int
main(int argc,
     char *argv[]){
    int n;
    scanf("%d",&n);
    char card[2];
    char color[5] ={'R','G','B','Y','W'};
    memset(flag,0,sizeof(flag));
    for(int i=0;i<n;i++){
        scanf("%s",card);
        for(int j=0;j<5;j++){
            if(card[0] == color [j]){
                flag[j][card[1]-'1'] ++;
            }
        }
    }
    for(int i=0;i<=10;i++){
        memset(mark,0,sizeof(mark));
        if(dfs(i)) {
            printf("%d\n",i);
            break;
        }
    }

    return 0;
}


#include <stdio.h>

#define K	50

int main() {
	int q;

	scanf("%d", &q);
	while (q--) {
		static long long aa[K];
		long long a, b, m, lower, upper, x;
		int i, j, k, good;

		scanf("%lld%lld%lld", &a, &b, &m);
		if (a == b) {
			printf("1 %lld\n", a);
			continue;
		}
		good = 0;
		for (k = 2; k <= K; k++) {
			lower = (a << (k - 2)) + (1 << (k - 2)) - 1 + 1;
			if (lower > b)
				break;
			upper = (a << (k - 2)) + m * ((1 << (k - 2)) - 1) + m;
			if (b <= upper) {
				good = 1;
				break;
			}
		}
		if (!good) {
			printf("-1\n");
			continue;
		}
		b -= lower;
		printf("%d %lld", k, aa[0] = a);
		for (j = 1; j < k; j++) {
			a = 1 << (j == k - 1 ? 0 : k - 2 - j);
			x = 1 + b / a;
			if (x > m)
				x = m;
			b -= (x - 1) * a;
			for (i = 0; i < j; i++)
				x += aa[i];
			printf(" %lld", aa[j] = x);
		}
		printf("\n");
	}
	return 0;
}


#include <stdio.h>

#define K	50

int main() {
	int q;

	scanf("%d", &q);
	while (q--) {
		static long long aa[K];
		long long a, b, m, lower, upper, x;
		int i, j, k, good;

		scanf("%lld%lld%lld", &a, &b, &m);
		good = 0;
		for (k = 2; k <= K; k++) {
			lower = (a << (k - 2)) + (1 << (k - 2)) - 1 + 1;
			if (lower > b)
				break;
			upper = (a << (k - 2)) + m * ((1 << (k - 2)) - 1) + m;
			if (b <= upper) {
				good = 1;
				break;
			}
		}
		if (!good) {
			printf("-1\n");
			continue;
		}
		b -= lower;
		printf("%d %lld", k, aa[0] = a);
		for (j = 1; j < k; j++) {
			a = 1 << (j == k - 1 ? 0 : k - 2 - j);
			x = 1 + b / a;
			if (x > m)
				x = m;
			b -= (x - 1) * a;
			for (i = 0; i < j; i++)
				x += aa[i];
			printf(" %lld", aa[j] = x);
		}
		printf("\n");
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
    int q;
    scanf("%d",&q);
    while(q--){
        long long int a,b,m;
        scanf("%lld %lld %lld",&a,&b,&m);
        long long int k=1;
        if(a==b)
            printf("%lld %lld\n",k,a);
        else{
            long long int c=a+1;
            //double n;
            k = log2((b*1.0)/c) + 1;
            //printf("%lld\n", k);
            long long int d=c*pow(2,k-1);
            /*if(b!=d){
                k++;
                d=d*2;
            }*/
            //printf("%lld",k+1);
            c=a+m;
            long long int s=c*pow(2,k-1);
            if((k+1)>=50 || s<b){
                printf("-1\n");
            }
            else{
                if(k==1){
                    printf("%lld %lld %lld\n",(k+1),a,b);
                }
                else{
                    m--;
                    long long int r[k+1];
                    long long int diff = b-d;
                    //printf("%lld\n",diff);
                    long long int j=k;
                    for(long long int i=1;i<k;i++){
                        long long int f=diff/pow(2,(j-2));
                        if(f>m)
                            f=m;
                        diff = diff - f*pow(2,(j-2));
                        r[i] = f + 1;
                        j--;
                    }
                    r[k] = diff + 1;
                    printf("%lld %lld ",(k+1),a);
                    long long int sum=a;
                    for(long long int i=1;i<=k;i++){
                        long long int temp = sum + r[i];
                        printf("%lld ",temp);
                        //printf("%lld ",r[i]);
                        sum = sum + temp;
                    }
                    printf("\n");
                }
            }
        }
    }
    return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
    long long int q;
    scanf("%lld",&q);
    while(q--){
        long long int a,b,m;
        scanf("%lld %lld %lld",&a,&b,&m);
        long long int k=1;
        if(a==b)
            printf("%lld %lld\n",k,a);
        else{
            long long int c=a+1;
            k = log2((b*1.0)/c) + 1;
            //printf("%lld\n",k);
            long long int s=c*pow(2,k-1);
            if(k==1){
                if((b-a)>m)
                    printf("-1\n");
                else
                    printf("%lld %lld %lld\n",(k+1),a,b);
            }
            else{
                m--;
                long long int r[k+2];
                for(long long int i=0;i<(k+2);i++)
                    r[i]=0;
                long long int diff = b-s;
                //printf("%lld\n",diff);
                long long int j=k;
                for(long long int i=1;i<k;i++){
                    long long int f=diff/pow(2,(j-2));
                    if(f>m)
                        f=m;
                    diff = diff - f*pow(2,(j-2));
                    r[i] = f + 1;
                    j--;
                }
                r[k] = diff + 1;
                if(r[k]>(m+1)){
                    printf("-1\n");
                    continue;
                }
                printf("%lld %lld ",(k+1),a);
                long long int sum=a;
                for(long long int i=1;i<=k;i++){
                    long long int temp = sum + r[i];
                    printf("%lld ",temp);
                    //printf("%lld ",r[i]);
                    sum = sum + temp;
                }
                printf("\n");
            }
        }
    }
    return 0;
}


#include <stdio.h>

#define K	50

int main() {
	int q;

	scanf("%d", &q);
	while (q--) {
		static long long aa[K];
		long long a, b, m, lower, upper, x;
		int i, j, k, good;

		scanf("%lld%lld%lld", &a, &b, &m);
		if (a == b) {
			printf("1 %lld\n", a);
			continue;
		}
		good = 0;
		for (k = 2; k <= K; k++) {
			lower = (a << (k - 2)) + (1LL << (k - 2)) - 1 + 1;
			if (lower > b)
				break;
			upper = (a << (k - 2)) + m * ((1LL << (k - 2)) - 1) + m;
			if (b <= upper) {
				good = 1;
				break;
			}
		}
		if (!good) {
			printf("-1\n");
			continue;
		}
		b -= lower;
		printf("%d %lld", k, aa[0] = a);
		for (j = 1; j < k; j++) {
			a = 1LL << (j == k - 1 ? 0 : k - 2 - j);
			x = 1 + b / a;
			if (x > m)
				x = m;
			b -= (x - 1) * a;
			for (i = 0; i < j; i++)
				x += aa[i];
			printf(" %lld", aa[j] = x);
		}
		printf("\n");
	}
	return 0;
}


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

#define N 100000
#define EPS 1E-6

int sign(double x) {
  return x < -EPS ? -1 : x > EPS;
}

double sqr(double x) {
  return x * x;
}

typedef struct point {
  double x, y;
} point;

double dist(point a, point b) {
  return hypot(a.x - b.x, a.y - b.y);
}

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

/* PA * PB */
double dot(point p, point a, point b) {
  return (a.x - p.x) * (b.x - p.x) + (a.y - p.y) * (b.y - p.y);
}

/* delta angle of ABC */
double delta_angle(point a, point b, point c) {
  return acos(dot(b, a, c) / (dist(a, b) * dist(b, c)));
}

point *__o;

int angle_cmp(point *p, point *q) {
  int c;
  if (c = sign(cross(*__o, *p, *q)))
    return -c;
  return sign(dist(*p, *__o) - dist(*q, *__o));
}

point stack[N];

int convex_hull(point *ps, int n) {
  int i, k, top;
  point q;

  k = 0;
  for (i = 1; i < n; i++)
    if (sign(ps[i].y - ps[k].y) < 0 || sign(ps[i].y - ps[k].y) == 0 && ps[i].x < ps[k].x)
      k = i;

  q = ps[k];
  ps[k] = ps[0];
  ps[0] = q;

  __o = &ps[0];
  qsort(ps + 1, n - 1, sizeof(point), (int (*)(const void *, const void *))angle_cmp);

  top = 0;
  for (i = 0; i < n; i++) {
//    printf("%lf,%lf\n", ps[i].x, ps[i].y);
    while (top >= 2 && sign(cross(stack[top - 2], stack[top - 1], ps[i])) <= 0) top--;
    stack[top++] = ps[i];
  }
  memcpy(ps, stack, sizeof(point) * top);
  return top;
}

double cccr(point A, point B, point C) {
  double a, b, c, cos_B, sin_B, R;

  a = dist(B, C);
  b = dist(A, C);
  c = dist(A, B);
  cos_B = (a * a + c * c - b * b) / (2 * a * c);
  sin_B = sqrt(1.0 - cos_B * cos_B);
  return b / sin_B / 2.0;
}

int too_straight(point A, point B, point C, double r) {
//  printf("R=%lf vs r=%lf\n", R, r);
  return sign(dot(B, A, C)) < 0 && sign(cccr(A, B, C) - r) > 0;
}

double area_bow(double r, double l) {
  double tri = l * sqrt(sqr(r) - sqr(l / 2)) / 2;
  double theta = 2 * asin(l / (r + r));
  double sector = theta * r * r / 2;
  return sector - tri;
}

double area_polygon(const point a[], int n) {
  int i, j;
  double area = 0.0;
  for (j = 0, i = n - 1; j < n; i = j++)
    area += a[i].x * a[j].y - a[i].y * a[j].x;
  return fabs(area) / 2;
}

void die() {
  *(char *)NULL = 0;
}

int main() {
  static point ps[N];
  int n;
  double r;
  double ans, R, Rmin;
  int i, j, k, z, top, s, ch;

  scanf("%d %lf", &n, &r);
  for (i = 0; i < n; i++)
    scanf("%lf %lf", &ps[i].x, &ps[i].y);

  if (n == 1) {
    puts("0");
  } else if (n == 2) {
    ans = area_bow(r, dist(ps[0], ps[1])) * 2.0;
    printf("%.9lf\n", ans);
  } else {
    n = convex_hull(ps, n);
//    printf("n=%d\n", n);

    top = 0;
    for (i = 0; i < n; i++) {
      while (top >= 2 && too_straight(stack[top - 2], stack[top - 1], ps[i], r))
        top--;
      stack[top++] = ps[i];
    }

    s = 0;
    ch = 1;
    while (ch) {
      ch = 0;
      while (top - s >= 3 && too_straight(stack[top - 2], stack[top - 1], stack[s], r))
        top--, ch = 1;
      while (top - s >= 3 && too_straight(stack[top - 1], stack[s], stack[s + 1], r))
        s++, ch = 1;
    }
    memcpy(stack, stack + s, sizeof(stack[0]) * (top -= s));
//    printf("top=%d\n", top);

    ans = area_polygon(stack, top);
    for (i = 0, j = 1 % top; i < top; i++, j = (j + 1) % top) {
//      printf("%lf,%lf\n", stack[i].x, stack[i].y);
      ans += area_bow(r, dist(stack[i], stack[j]));
    }
    printf("%.9lf\n", ans);

    if (top >= 3)
      for (i = 0, j = 1 % top, k = 2 % top; i < top; i++, j = (j + 1) % top, k = (k + 1) % top)
        if (too_straight(stack[i], stack[j], stack[k], r))
          die();
  }

  return 0;
}


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

#define N 100000
#define EPS 1E-6

int sign(double x) {
  return x < -EPS ? -1 : x > EPS;
}

double sqr(double x) {
  return x * x;
}

typedef struct point {
  double x, y;
} point;

double dist(const point *a, const point *b) {
  return hypot(a->x - b->x, a->y - b->y);
}

double cross(const point *a, const point *b, const point *c) {
  return (b->x - a->x) * (c->y - b->y) - (b->y - a->y) * (c->x - b->x);
}

/* PA * PB */
double dot(const point *p, const point *a, const point *b) {
  return (a->x - p->x) * (b->x - p->x) + (a->y - p->y) * (b->y - p->y);
}

const point *__o;

int angle_cmp(const point *p, const point *q) {
  int c;
  if (c = sign(cross(__o, p, q)))
    return -c;
  return sign(dist(p, __o) - dist(q, __o));
}

point stack[N];

int convex_hull(point ps[], int n) {
  int i, k, top;
  point q;

  k = 0;
  for (i = 1; i < n; i++)
    if (sign(ps[i].y - ps[k].y) < 0 || sign(ps[i].y - ps[k].y) == 0 && ps[i].x < ps[k].x)
      k = i;

  q = ps[k];
  ps[k] = ps[0];
  ps[0] = q;

  __o = &ps[0];
  qsort(ps + 1, n - 1, sizeof(point), (int (*)(const void *, const void *))angle_cmp);

  top = 0;
  for (i = 0; i < n; i++) {
    while (top >= 2 && sign(cross(&stack[top - 2], &stack[top - 1], &ps[i])) <= 0) top--;
    stack[top++] = ps[i];
  }
  memcpy(ps, stack, sizeof(point) * top);
  return top;
}

double cccr(const point *A, const point *B, const point *C) {
  double a, b, c, cos_B, sin_B, R;

  a = dist(B, C);
  b = dist(A, C);
  c = dist(A, B);
  cos_B = (a * a + c * c - b * b) / (2 * a * c);
  sin_B = sqrt(1.0 - cos_B * cos_B);
  return b / sin_B / 2.0;
}

int too_straight(const point *A, const point *B, const point *C, double r) {
  return sign(dot(B, A, C)) < 0 && sign(cccr(A, B, C) - r) > 0;
}

double area_bow(double r, double l) {
  double tri = l * sqrt(sqr(r) - sqr(l / 2)) / 2;
  double theta = 2 * asin(l / (r + r));
  double sector = theta * r * r / 2;
  return sector - tri;
}

double area_polygon(const point a[], int n) {
  int i, j;
  double area = 0.0;
  for (j = 0, i = n - 1; j < n; i = j++)
    area += a[i].x * a[j].y - a[i].y * a[j].x;
  return fabs(area) / 2;
}

int main() {
  static point ps[N];
  int n;
  double r;
  double ans, R, Rmin;
  int i, j, k, z, top, s, ch;

  scanf("%d %lf", &n, &r);
  for (i = 0; i < n; i++)
    scanf("%lf %lf", &ps[i].x, &ps[i].y);

  if (n == 1) {
    puts("0");
  } else if (n == 2) {
    ans = area_bow(r, dist(&ps[0], &ps[1])) * 2.0;
    printf("%.9lf\n", ans);
  } else {
    n = convex_hull(ps, n);

    top = 0;
    for (i = 0; i < n; i++) {
      while (top >= 2 && too_straight(&stack[top - 2], &stack[top - 1], &ps[i], r))
        top--;
      stack[top++] = ps[i];
    }

    s = 0;
    ch = 1;
    while (ch) {
      ch = 0;
      while (top - s >= 3 && too_straight(&stack[top - 2], &stack[top - 1], &stack[s], r))
        top--, ch = 1;
      while (top - s >= 3 && too_straight(&stack[top - 1], &stack[s], &stack[s + 1], r))
        s++, ch = 1;
    }
    memcpy(stack, stack + s, sizeof(stack[0]) * (top -= s));

    ans = area_polygon(stack, top);
    for (i = 0, j = 1 % top; i < top; i++, j = (j + 1) % top)
      ans += area_bow(r, dist(&stack[i], &stack[j]));
    printf("%.9lf\n", ans);
  }

  return 0;
}


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

#define N 100000
#define EPS 1E-6

int sign(double x) {
  return x < -EPS ? -1 : x > EPS;
}

double sqr(double x) {
  return x * x;
}

typedef struct point {
  double x, y;
} point;

double dist(const point *a, const point *b) {
  return hypot(a->x - b->x, a->y - b->y);
}

double cross(const point *a, const point *b, const point *c) {
  return (b->x - a->x) * (c->y - b->y) - (b->y - a->y) * (c->x - b->x);
}

/* PA * PB */
double dot(const point *p, const point *a, const point *b) {
  return (a->x - p->x) * (b->x - p->x) + (a->y - p->y) * (b->y - p->y);
}

const point *__o;

int angle_cmp(const point *p, const point *q) {
  int c;
  if (c = sign(cross(__o, p, q)))
    return -c;
  return sign(dist(p, __o) - dist(q, __o));
}

int convex_hull(point ps[], int n) {
  static point stack[N];
  int i, k, top;
  point q;

  k = 0;
  for (i = 1; i < n; i++)
    if (sign(ps[i].y - ps[k].y) < 0 || sign(ps[i].y - ps[k].y) == 0 && ps[i].x < ps[k].x)
      k = i;

  q = ps[k];
  ps[k] = ps[0];
  ps[0] = q;

  __o = &ps[0];
  qsort(ps + 1, n - 1, sizeof(ps[0]), (int (*)(const void *, const void *))angle_cmp);

  top = 0;
  for (i = 0; i < n; i++) {
    while (top >= 2 && sign(cross(&stack[top - 2], &stack[top - 1], &ps[i])) <= 0) top--;
    stack[top++] = ps[i];
  }
  memcpy(ps, stack, sizeof(point) * top);
  return top;
}

double cccr(const point *A, const point *B, const point *C) {
  double a, b, c, cos_B, sin_B, R;

  a = dist(B, C);
  b = dist(A, C);
  c = dist(A, B);
  cos_B = (a * a + c * c - b * b) / (2 * a * c);
  sin_B = sqrt(1.0 - cos_B * cos_B);
  return b / sin_B / 2.0;
}

int too_straight(const point *A, const point *B, const point *C, double r) {
  return sign(dot(B, A, C)) < 0 && sign(cccr(A, B, C) - r) > 0;
}

double area_bow(double r, double l) {
  double tri = l * sqrt(sqr(r) - sqr(l / 2)) / 2;
  double theta = 2 * asin(l / (r + r));
  double sector = theta * r * r / 2;
  return sector - tri;
}

double area_polygon(point **a, int n) {
  int i, j;
  double area = 0.0;
  for (j = 0, i = n - 1; j < n; i = j++)
    area += a[i]->x * a[j]->y - a[i]->y * a[j]->x;
  return fabs(area) / 2;
}

int main() {
  static point ps[N];
  static point *stack[N];
  int n;
  double r;
  double ans, R, Rmin;
  int i, j, k, z, top, s, ch;

  scanf("%d %lf", &n, &r);
  for (i = 0; i < n; i++)
    scanf("%lf %lf", &ps[i].x, &ps[i].y);

  if (n == 1) {
    puts("0");
  } else if (n == 2) {
    ans = area_bow(r, dist(&ps[0], &ps[1])) * 2.0;
    printf("%.9lf\n", ans);
  } else {
    n = convex_hull(ps, n);

    top = 0;
    for (i = 0; i < n; i++) {
      while (top >= 2 && too_straight(stack[top - 2], stack[top - 1], &ps[i], r))
        top--;
      stack[top++] = &ps[i];
    }

    s = 0;
    ch = 1;
    while (ch) {
      ch = 0;
      while (top - s >= 3 && too_straight(stack[top - 2], stack[top - 1], stack[s], r))
        top--, ch = 1;
      while (top - s >= 3 && too_straight(stack[top - 1], stack[s], stack[s + 1], r))
        s++, ch = 1;
    }
    memcpy(stack, stack + s, sizeof(stack[0]) * (top -= s));

    ans = area_polygon(stack, top);
    for (i = 0, j = 1 % top; i < top; i++, j = (j + 1) % top)
      ans += area_bow(r, dist(stack[i], stack[j]));
    printf("%.9lf\n", ans);
  }

  return 0;
}


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

#define N 100000
#define EPS 1E-6

int sign(double x) {
  return x < -EPS ? -1 : x > EPS;
}

double sqr(double x) {
  return x * x;
}

typedef struct point {
  double x, y;
} point;

double dist(point a, point b) {
  return hypot(a.x - b.x, a.y - b.y);
}

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

/* PA * PB */
double dot(point p, point a, point b) {
  return (a.x - p.x) * (b.x - p.x) + (a.y - p.y) * (b.y - p.y);
}

/* delta angle of ABC */
double delta_angle(point a, point b, point c) {
  return acos(dot(b, a, c) / (dist(a, b) * dist(b, c)));
}

point *__o;

int angle_cmp(point *p, point *q) {
  int c;
  if (c = sign(cross(*__o, *p, *q)))
    return -c;
  return sign(dist(*p, *__o) - dist(*q, *__o));
}

point stack[N];

int convex_hull(point *ps, int n) {
  int i, k, top;
  point q;

  k = 0;
  for (i = 1; i < n; i++)
    if (sign(ps[i].y - ps[k].y) < 0 || sign(ps[i].y - ps[k].y) == 0 && ps[i].x < ps[k].x)
      k = i;

  q = ps[k];
  ps[k] = ps[0];
  ps[0] = q;

  __o = &ps[0];
  qsort(ps + 1, n - 1, sizeof(point), (int (*)(const void *, const void *))angle_cmp);

  top = 0;
  for (i = 0; i < n; i++) {
//    printf("%lf,%lf\n", ps[i].x, ps[i].y);
    while (top >= 2 && sign(cross(stack[top - 2], stack[top - 1], ps[i])) <= 0) top--;
    stack[top++] = ps[i];
  }
  memcpy(ps, stack, sizeof(point) * top);
  return top;
}

double cccr(point A, point B, point C) {
  double a, b, c, cos_B, sin_B, R;

  a = dist(B, C);
  b = dist(A, C);
  c = dist(A, B);
  cos_B = (a * a + c * c - b * b) / (2 * a * c);
  sin_B = sqrt(1.0 - cos_B * cos_B);
  return b / sin_B / 2.0;
}

int too_straight(point A, point B, point C, double r) {
  if (!sign(cross(A, B, C)))
    return 1;

//  printf("R=%lf vs r=%lf\n", R, r);
  return sign(cccr(A, B, C) - r) > 0;
}

double area_bow(double r, double l) {
  double tri = l * sqrt(sqr(r) - sqr(l / 2)) / 2;
  double theta = 2 * asin(l / (r + r));
  double sector = theta * r * r / 2;
  return sector - tri;
}

double area_polygon(const point a[], int n) {
  int i, j;
  double area = 0.0;
  for (j = 0, i = n - 1; j < n; i = j++)
    area += a[i].x * a[j].y - a[i].y * a[j].x;
  return fabs(area) / 2;
}

int main() {
  static point ps[N];
  int n;
  double r, ans, R, Rmin;
  int i, j, k, z, top, s, ch;

  scanf("%d %lf", &n, &r);
  for (i = 0; i < n; i++)
    scanf("%lf %lf", &ps[i].x, &ps[i].y);

  if (n == 1) {
    puts("0");
  } else if (n == 2) {
    ans = area_bow(r, dist(ps[0], ps[1])) * 2.0;
    printf("%.9lf\n", ans);
  } else {
    n = convex_hull(ps, n);
//    printf("n=%d\n", n);

    z = -1;
    for (i = 0, j = 1, k = 2 % n; i < n; i++, j = (j + 1) % n, k = (k + 1) % n) {
      R = cccr(ps[i], ps[j], ps[k]);
      if (z == -1 || Rmin > R) {
        Rmin = R;
        z = j;
      }
    }

    top = 0;
    for (j = 0, i = z; j < n; j++, i = (i + 1) % n) {
//      printf("%lf,%lf\n", ps[i].x, ps[i].y);
      while (top >= 2 && too_straight(stack[top - 2], stack[top - 1], ps[i], r))
        top--;
      stack[top++] = ps[i];
    }
    ch = 1;
    while (ch) {
      ch = 0;
      while (top - s >= 2 && too_straight(stack[top - 2], stack[top - 1], stack[s], r))
        top--, ch = 1;
      s = 0;
      while (top - s >= 2 && too_straight(stack[top - 1], stack[s], stack[s + 1], r))
        s++, ch = 1;
    }
//    printf("top=%d\n", top);

    memcpy(stack, stack + s, sizeof(stack[0]) * (top -= s));

    ans = area_polygon(stack, top);
    for (i = 0, j = 1 % top; i < top; i++, j = (j + 1) % top) {
//      printf("%lf,%lf\n", stack[i].x, stack[i].y);
      ans += area_bow(r, dist(stack[i], stack[j]));
    }
    printf("%.9lf\n", ans);
  }

  return 0;
}


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

#define mset(a) memset(a,0,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
#define mcmp(a,b,n) memcmp(a,b,n)
#define maxint 2147483647
#define pi 3.14159265358979323846

long long n,t,ans=0,k;
long long a[111],cnk[111][111];

long long turn(long long t)
{
     long long i=0;

     if(t&(t-1))
       return -1;

     while(t>>=1)
       i++;
     return i;
}

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

    a[0]=1;
    for(i=1;i<63;i++)
      a[i]=a[i-1]<<1;
    mset(cnk);
    for(i=0;i<111;i++)
      {
        cnk[i][0]=1;
        for(j=1;j<=i;j++)
          cnk[i][j]=cnk[i-1][j-1]+cnk[i-1][j];
      }

    scanf("%I64d%I64d",&n,&t);

    k=turn(t);
    if(k==-1)
      {
        printf("0\n");
        return 0;
      }

    for(i=1;n>a[i];i++)
      {
        ans+=cnk[i][k];
        n-=a[i];
      }
    for(i=62;i>=0;i--)
      if((~k)&&(n>>i&1))
        {
          ans+=cnk[i][k];
          k--;
        }

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

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


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

long long ch(int n, int k) {
	return k == 0 ? 1 : ch(n - 1, k - 1) * n / k;
}

int main() {
	long long n, m, t, ans;
	int k, b, l;

	scanf("%lld%lld", &n, &t), n += 2;
	if (t & t - 1) {
		printf("0\n");
		return 0;
	}
	k = 0;
	while (t > 0) {
		k++;
		t >>= 1;
	}
	b = 0;
	for (m = n; m > 1; m >>= 1)
		b++;
	ans = 0;
	for (l = 0; b >= 0; b--)
		if (n & 1LL << b) {
			if (b >= k - l)
				ans += ch(b, k - l);
			if (++l > k)
				break;
		}
	if (k == 1)
		ans--;
	printf("%lld\n", ans);
	return 0;
}


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

#define mset(a) memset(a,0,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
#define mcmp(a,b,n) memcmp(a,b,n)
#define maxint 2147483647
#define pi 3.14159265358979323846

long long n,t,ans=0,k;
long long a[111],cnk[111][111];

long long turn(long long t)
{
     long long i=0;

     if(t&(t-1))
       return -1;

     while(t>>=1)
       i++;
     return i;
}

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

    a[0]=1;
    for(i=1;i<63;i++)
      a[i]=a[i-1]<<1;
    mset(cnk);
    for(i=0;i<111;i++)
      {
        cnk[i][0]=1;
        for(j=1;j<=i;j++)
          cnk[i][j]=cnk[i-1][j-1]+cnk[i-1][j];
      }

    scanf("%I64d%I64d",&n,&t);

    k=turn(t);
    if(k==-1)
      {
        printf("0\n");
        return 0;
      }

    for(i=1;n>a[i];i++)
      {
        ans+=cnk[i][k];
        n-=a[i];
      }
    for(i=62;i>0;i--)
      if((~k)&&(n>>i&1))
        {
          ans+=cnk[i][k];
          k--;
        }

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

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


#include<stdio.h>
#include<stdlib.h>
#define modd 1000000007
long long fast_expo(long long a,long long b)
{
	long long res=1;
	while(b>0)
	{
		if(b&1)
			res=(res*a)%modd;
		a=(a*a)%modd;
		b=b>>1;
	}
	return res;
}
int main()
{
	long long fact[200001];
	int i,n;
	fact[0]=1;
	for(i=1;i<200001;i++)
		fact[i]=(fact[i-1]*i)%modd;
	while(scanf("%d",&n)==1)
	{
		long long ans=(fact[(n<<1)-1]*((fast_expo(fact[n],modd-2)*fast_expo(fact[n-1],modd-2))%modd))%modd;
		ans=(ans<<1)-n;
		if(ans<0)
			printf("%I64d\n",(ans+modd)%modd);
		else printf("%I64d\n",ans%modd);
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#define modd 1000000007
long long fast_expo(long long a,long long b)
{
	long long res=1;
	while(b>0)
	{
		if(b&1)
			res=(res*a)%modd;
		a=(a*a)%modd;
		b=b>>1;
	}
	return res;
}
int main()
{
	long fact[200001];
	int i,n;
	fact[0]=1;
	for(i=1;i<200001;i++)
		fact[i]=(fact[i-1]*i)%modd;
	while(scanf("%d",&n)==1)
	{
		long long ans=(fact[2*n-1]*((fast_expo(fact[n],modd-2)*fast_expo(fact[n-1],modd-2))%modd))%modd;
		ans=(2*ans)-n;
		if(ans<0)
			printf("%I64d\n",(ans+modd)%modd);
		else printf("%I64d\n",ans%modd);
	}
	return 0;
}


#include <stdio.h>
#define MAX 1000000007
long long int ncr(int n, int k)
{
    if(k > n)
        return 0;
    if(k == n)
        return 1;
    long long int r = n;
    int i;
    for(i=2;i<=k;++i)
    {
        r *= (n-i+1);
        r = r/i;
    }
    return r;
}
int main()
{
    int n,i, sum = 0, ans = 0;
    scanf("%d", &n);
    sum = n+2;
    for(i = 1; i <=n; i++){
        ans = ans + ncr(n+1,i);
    }
    ans = (ans+n)%MAX;
    if(n == 2){
        ans = 4;
    }
    printf("%d", ans);
    return 0;
}


#include<stdio.h>
int main()
{
    int x;
    scanf("%d",&x);
    for(long r=1;r<=x;r++)
    {
        for(long c=1;c<=r;c++)
        long mul=r*c;
        if(mul>=x)
        {
            mul=10*(mul/x)+(mul%x);
        printf("%ld",mul);
        }
        puts(" ");

        }
        return 0;
    }
}


#include<cstdio>
int main()
{
    int x;
    scanf("%d",&x);
    for(long r=1;r<x;r++)
    {
        for(long c=1;c<x;c++)
        {
        long mul=r*c;
        if(mul>=x)
        {
            mul=10*(mul/x)+(mul%x);
        }
        printf("%ld ",mul);
        }
        puts("");

        }
        return 0;
    }


#include<cstdio>
int main()
{
    int x;
    scanf("%d",&x);
    for(long r=1;r<x;r++)
    {
        for(long c=1;c<x;c++)
        {
        long mul=r*c;
        if(mul>=x)
        {
            mul=10*(mul/x)+(mul%x);
        }
        printf("%ld",mul);
        }
        puts("");

        }
        return 0;
    }


#include<stdio.h>
int main()
{
    int x;
    scanf("%d",&x);
    for(long r=1;r<=x;r++)
    {
        for(long c=1;c<=r;c++)
        {
        long mul=r*c;
        if(mul>=x)
        {
            mul=10*(mul/x)+(mul%x);
        }
        printf("%ld",mul);
        }
        puts("");

        }
        return 0;
    }


#include<stdio.h>
int main()
{
    int x;
    scanf("%d",&x);
    for(long r=1;r<=x;r++)
    {
        for(long c=1;c<=r;c++)
        {
        long mul=r*c;
        if(mul>=x)
        {
            mul=10*(mul/x)+(mul%x);
        }
        printf("%ld",mul);
        }
        puts(" ");

        }
        return 0;
    }


#include <stdio.h>

int Cnt[10];

int main()
{
    int table[] = {999999999, 99999999, 9999999, 999999, 99999, 9999, 999, 99, 9};
    int n, reamin = 0, ans = 0;
    scanf("%d", &n);
    for(int i = 0; i < 9; ++i) {
        if(n + n - 1 >= table[i]) {
            reamin = table[i];
            break;
        }
    }
    if(reamin == 0) {
        printf("%d\n", n * (n - 1) / 2);
        return 0;
    }
    for(int i = 0; i < 9; ++i) {
        long long expect = (long long)(reamin + 1) * i + reamin;
        if(n + n - 1 >= expect) {
            if(expect <= n) {
                ans += expect / 2;
            } else {
                ans += n - expect / 2;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


//Date : 17 - 12 - 17

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<float.h>
#include<math.h>
#include<inttypes.h>
#include<assert.h>
#include<ctype.h>
#include<limits.h>
#include<time.h>
#define ll long long
#define For(i,n)	for(i=0;i<n;i++)
#define rep(i ,a ,b)	for(i=(a);i<=(b);i++)
#define mset(a ,value)	memset(a ,value ,sizeof(a))
#define s(a)	scanf("%d" ,&a);
#define ls(a)	scanf("%ld" ,&a)
#define reg(i)	register int i
#define infinite INT_MAX
#define MAX 200005
#define N 1000005
#define MM 100001
#define MOD 1000000007
#define NIL -1
ll min(ll a,ll b){	return (a < b ? a : b)	;}
int max(int a,int b){	return (a > b ? a : b)	;}
ll gcd(ll a,ll b){
	if(a==0)	return b;
	return gcd(b%a ,a);
}
void swap(ll *a,ll *b){
	ll t = *a;
	*a = *b;
	*b = t;
}
int main(){
	int n;
	s(n);
	ll sum = 0LL + n + n - 1;
	ll ms = sum;
	int x = 0 ,_9 = 0;
	while(sum){
		if(sum % 10 == 9)	_9++;
		sum /= 10;
		x++;
	}
	//printf("%d %d" ,x ,_9);
	if(_9 == x){	printf("1");	return 0;	}
	if(x == 1){	printf("%I64d" ,1LL*n*(n - 1) / 2);	return 0;	}
	x--;
	_9 = x;	sum = 0;
	ll inc = 1;
	while(x){
		sum = sum * 10LL + 9;
		inc *= 10;
		x--;
	}
	//printf("%I64d %I64d\n" ,sum ,inc);
	ll ans = 0 ,lo ,hi ,r ,v;
	bool ff = 0;
	while(sum <= ms){
		lo = 1 ,hi = n ,ff = 0;
		while(lo <= hi){
			r =	(lo + hi) / 2;
			v = sum - r;
			if(v < 0)	hi = r - 1;
			else if(v > n)	lo = r + 1;
			else {	ff = 1;	break;	}
		}
		if(ff){
			if(r > v)	swap(&v ,&r);
			//printf("%I64d %I64d\n" ,r ,v);
			ans += min(r ,n - v + 1);
			ll diff = v - r - 1;
			ans += diff / 2;
		}
		sum += inc;
	}
	printf("%I64d" ,ans);
	return 0;
}


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

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

#define MOD 1e9+7
#define M 25

int a[5]= {0,0,1,3,6};

int main() {
    int n;
//    freopen("1.txt", "r", stdin);
//    freopen("2.txt", "w", stdout);
    while(scanf("%d", &n)!=EOF) {
        if (n < 5) {
            printf("%d\n",a[n]);
            continue;
        }
        long long s = 0LL, t=5LL,i;
        for(i = 1; i <10; i++) {
            if (n >=t) {
                t*=10;
            } else  {
                break;
            }
        }
        t/=10;
        for(i=1; i<=5; i++) {
            if(n>t*i*2+t-1) {
                s+=2*t*i;
                s--;
            } else {
                i--;
                break;
            }
        }
        s+=(n-t*i*2-t+1)*(i+1);
        if(n>=t+t-1+i*(t*10/5)) {
            s--;
        }
        printf("%d\n",s);
    }
    return 0;
}


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

long long int myfunc(long long int n){
    if(n <= 4)
        return n * (n - 1) / 2;
    long double s = 1.0 * n / 5;
    s = log10l(s);
    s = floorl(s);
    long long int m = 5 * (long long int)powl(10, s);
    long long int result = 0ll;
    for(int i = 0 ; i < 9 ; i++){
        long long int min, max;
        min = (long long int)((i+1) * powl(10, s+1) / 2);
        max = (long long int)((i+1) * powl(10, s+1) - 2);
        if (n >= max){
            result += min - 1;
        }else if( n < min ){
            break;
        }else{
            result += n - min + 1 ;
        }
    }
    return result;
}

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

    printf("%lld", myfunc(n));
}


#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>
#include <stdbool.h>

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

bool visited[MAX][MAX][LIM][2];
int n, t, counter[1010], ar[MAX], dp[MAX][MAX][LIM][2];

int F(int i, int l, int r, int flag){
    if (i > n){
        if (r == t || r == LIM){
            if (!flag) return (counter[ar[l]] * (t - r));
            else return 0;
        }
        else return F(0, l, r + 1, flag);
    }
    if (visited[i][l][r][flag]) return dp[i][l][r][flag];

    int x, res = F(i + 1, l, r, flag);
    if (ar[i] >= ar[l]){
        x = 1 + F(i + 1, i, r, flag);
        if (x > res) res = x;
    }
    if (!flag && t > LIM){
        x = F(i, l, r, 1) + (counter[ ar[l] ] * (t - LIM));
        if (x > res) res = x;
    }

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

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

    while (scanf("%d %d", &n, &t) != EOF){
        if (!n) break;

        ar[0] = 0;
        clr(counter);
        for (i = 1; i <= n; i++){
            scanf("%d", &ar[i]);
            counter[ar[i]]++;
        }

        clr(visited);
        int res = F(1, 0, 1, 0);
        printf("%d\n", res);
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXN 23333
#define MAXELEM 308

int n, t;
int a[MAXN];

// Calculate the longest non-decreasing sequence
// Time complexity: O(n log n)
int *lnds(int *a, int n)
{
    int *ret = (int *)malloc(n * sizeof(int));
    int a_with_f[MAXN], maxlen = 1;
    ret[0] = 1;
    a_with_f[0] = -1;
    a_with_f[1] = a[0];
    int lo, hi, mid, i;
    for (i = 1; i < n; ++i) {
        if (a[i] >= a_with_f[maxlen]) {
            a_with_f[++maxlen] = a[i];
        } else {
            lo = 0, hi = maxlen;
            while (lo < hi - 1) {
                mid = (lo + hi) / 2;
                if (a[i] >= a_with_f[mid]) lo = mid;
                else hi = mid;
            }
            a_with_f[lo + 1] = a[i];
        }
        ret[i] = maxlen;
    }
    return ret;
}

int main()
{
    scanf("%d%d", &n, &t);
    int i;
    for (i = 0; i < n; ++i) scanf("%d", &a[i]);
    if (t <= 233) {
        for (i = n; i < n * t; i += n)
            memcpy(a + i, a, n * sizeof(int));
        int *first_part = lnds(a, n * t);
        printf("%d\n", first_part[n * t - 1]);
    } else {
        for (i = n; i < n * 233; i += n)
            memcpy(a + i, a, n * sizeof(int));
        int *first_part = lnds(a, n * 233);
        int count[MAXELEM] = { 0 }, maxcount = 0;
        for (i = 0; i < n; ++i) ++count[a[i]];
        for (i = 0; i < MAXELEM; ++i) if (maxcount < count[i]) maxcount = count[i];
        for (i = 0; i < n * 233; i += n)
            if (first_part[i + n] - first_part[i] == maxcount) break;
        i /= n;
        // assert(i == 1)?
        printf("%d\n", first_part[i * n + n - 1] + (t - i - 1) * maxcount);
    }
    return 0;
}


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

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

bool visited[MAX][MAX][LIM][2];
int n, t, counter[1010], ar[MAX], dp[MAX][MAX][LIM][2];

int F(int i, int l, int r, int flag){
    if (i > n){
        if (r == t || r == LIM){
            if (!flag) return (counter[ar[l]] * (t - r));
            else return 0;
        }
        else return F(0, l, r + 1, flag);
    }
    if (visited[i][l][r][flag]) return dp[i][l][r][flag];

    int x, res = F(i + 1, l, r, flag);
    if (ar[i] >= ar[l]){
        x = 1 + F(i + 1, i, r, flag);
        if (x > res) res = x;
    }
    if (!flag && t > LIM){
        x = F(i, l, r, 1) + (counter[l] * (t - LIM));
        if (x > res) res = x;
    }

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

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

    while (scanf("%d %d", &n, &t) != EOF){
        if (!n) break;

        ar[0] = 0;
        clr(counter);
        for (i = 1; i <= n; i++){
            scanf("%d", &ar[i]);
            counter[ar[i]]++;
        }

        clr(visited);
        int res = F(1, 0, 1, 0);
        printf("%d\n", res);
    }
    return 0;
}


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

#define MAX 333

int min(int x, int y) {
  return x < y ? x :  y;
}

int a[MAX];
int dp[MAX];
int n;

void update() {
  int i, j;
  for (i = 0; i < n; i++) {
    int ma = 0;
    for (j = 0; j <= a[i]; j++) {
      if (dp[j] > ma) ma = dp[j];
    }
    if (ma + 1 > dp[a[i]]) dp[a[i]] = ma + 1;
  }
}

int main() {
  int t, i;
  scanf("%d %d", &n, &t);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int time1 = min(MAX, t);
  int time3 = min(MAX, t - time1);
  int time2 = t - time1 - time2;
  for (i = 0; i < time1; i++) {
    update();
  }
  int ma = 0;
  if (time2 != 0) {
  for (i = 0; i < MAX; i++) {
    int cnt = 0;
    int j;
    for (j = 0; j < n; j++) if (a[j] == i) cnt++;
    if (dp[i] > ma) ma = dp[i];
    dp[i] = ma + cnt * time2;
  }
  }
  for (i = 0; i < time3; i++) {
    update();
  }
  int res = 0;
  for (i = 0; i < MAX; i++) if (dp[i] > res) res = dp[i];
  printf("%d\n", res);
  return 0;
}


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

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

int n, ar[MAX];
bool visited[MAX];

int main(){
    int i, j, k, l, x, y, pos, counter;

    while (scanf("%d", &n) != EOF){
        clr(visited);
        for (i = 0; i < n; i++) scanf("%d", &ar[i]);

        pos = 0, counter = 0;
        while (counter < n){
            if (!(pos & 1)){
                for (i = 0; i < n; i++){
                    if (!visited[i] && counter >= ar[i]){
                        counter++;
                        visited[i] = true;
                    }
                }
            }
            else{
                for (i = n - 1; i >= 0; i--){
                    if (!visited[i] && counter >= ar[i]){
                        counter++;
                        visited[i] = true;
                    }
                }
            }

            if (counter == n) break;
            pos++;
        }

        printf("%d\n", pos);
    }
    return 0;
}


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

int main()
{
    long times,n,value,lvalue,ans,g,maxg=0,v[46],i,j,k;
    scanf("%ld%ld%ld",&times,&n,&value);
    for (i=1;i<=n;i++)
        scanf("%ld",&v[i]);
    ans=0;
    for (i=1;i<=n;i++)
        ans+=v[i];
    for (i=0;i<=times;i++)
        if (value-ans*i>=0)
        {
            g=(n+1)*i;
            lvalue=value-ans*i;
            for (j=1;j<n;j++)//can't solve any problem more
                for (k=1;k<=times-i;k++)
                    if (lvalue-v[j]>=0)
                    {
                        g++;
                        lvalue-=v[j];
                    }
                    else
                        break;
            if (g>maxg)
                maxg=g;
        }
        else
            break;
    printf("%ld\n",maxg);
    return 0;
}


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

int main()
{
    long times,n,value,lvalue,ans,g,maxg=0,v[46],i,j,k;
    scanf("%ld%ld%ld",&times,&n,&value);
    for (i=1;i<=n;i++)
        scanf("%ld",&v[i]);
    for (i=1;i<n;i++)
        for (j=i+1;j<=n;j++)
            if (v[i]>v[j])
            {
                k=v[i];
                v[i]=v[j];
                v[j]=k;
            }
    ans=0;
    for (i=1;i<=n;i++)
        ans+=v[i];
    for (i=0;i<=times;i++)
        if (value-ans*i>=0)
        {
            g=(n+1)*i;
            lvalue=value-ans*i;
            for (j=1;j<n;j++)//can't solve any problem more
                for (k=1;k<=times-i;k++)
                    if (lvalue-v[j]>=0)
                    {
                        g++;
                        lvalue-=v[j];
                    }
                    else
                        break;
            if (g>maxg)
                maxg=g;
        }
        else
            break;
    printf("%ld\n",maxg);
    return 0;
}


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

#define len 17
#define inf (1 << 25)
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int factors[65] = {0};
bool visited[100][1 << len];
int n, ar[100], harmony[100], dp[100][1 << len], next[100][1 << len];
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};

void backtrack(int i, int bitmask){
    if (i == n) return;
    harmony[i] = next[i][bitmask];
    backtrack(i + 1, bitmask | factors[harmony[i]]);
}

int F(int i, int bitmask){
    if (i == n) return 0;
    if (visited[i][bitmask]) return dp[i][bitmask];

    int j, res = inf;
    for (j = 1; j <= 60; j++){
        if (!(bitmask & factors[j])){
            int x = abs(ar[i] - j) + F(i + 1, bitmask | factors[j]);
            if (x < res){
                res = x;
                next[i][bitmask] = j;
            }
        }
    }

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

int main(){
    int i, j;
    for (i = 1; i <= 60; i++){
        for (j = 0; j < len; j++){
            if ((i % primes[j]) == 0) factors[i] |= (1 << j);
        }
    }

    while (scanf("%d", &n) != EOF){
        for (i = 0; i < n; i++) scanf("%d", &ar[i]);
        clr(visited);
        int res = F(0, 0);
        backtrack(0, 0);
        for (i = 0; i < n; i++) printf("%d ", harmony[i]);
        puts("");
    }
    return 0;
}


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

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

int factors[60] = {0};
bool visited[32][1 << 17];
int n, ar[32], harmony[32], dp[32][1 << 17], next[32][1 << 17];
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};

void backtrack(int i, int bitmask){
    if (i == n) return;
    harmony[i] = next[i][bitmask];
    backtrack(i + 1, bitmask | factors[harmony[i]]);
}

int F(int i, int bitmask){
    if (i == n) return 0;
    if (visited[i][bitmask]) return dp[i][bitmask];

    int j, res = inf;
    for (j = 1; j <= 60; j++){
        if (!(bitmask & factors[j])){
            int x = abs(ar[i] - j) + F(i + 1, bitmask | factors[j]);
            if (x < res){
                res = x;
                next[i][bitmask] = j;
            }
        }
    }

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

int main(){
    int i, j;
    for (i = 1; i <= 60; i++){
        for (j = 0; j < 17; j++){
            if ((i % primes[j]) == 0) factors[i] |= (1 << j);
        }
    }

    while (scanf("%d", &n) != EOF){
        for (i = 0; i < n; i++) scanf("%d", &ar[i]);
        clr(visited);
        int res = F(0, 0);
        backtrack(0, 0);
        for (i = 0; i < n; i++) printf("%d ", harmony[i]);
        puts("");
    }
    return 0;
}


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

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

int factors[65] = {0};
bool visited[32][1 << 17];
int n, ar[32], harmony[32], dp[32][1 << 17], next[32][1 << 17];
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};

void backtrack(int i, int bitmask){
    if (i == n) return;
    harmony[i] = next[i][bitmask];
    backtrack(i + 1, bitmask | factors[harmony[i]]);
}

int F(int i, int bitmask){
    if (i == n) return 0;
    if (visited[i][bitmask]) return dp[i][bitmask];

    int j, res = inf;
    for (j = 1; j <= 60; j++){
        if (!(bitmask & factors[j])){
            int x = abs(ar[i] - j) + F(i + 1, bitmask | factors[j]);
            if (x < res){
                res = x;
                next[i][bitmask] = j;
            }
        }
    }

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

int main(){
    int i, j;
    for (i = 1; i <= 60; i++){
        for (j = 0; j < 17; j++){
            if ((i % primes[j]) == 0) factors[i] |= (1 << j);
        }
    }

    while (scanf("%d", &n) != EOF){
        for (i = 0; i < n; i++) scanf("%d", &ar[i]);
        clr(visited);
        int res = F(0, 0);
        backtrack(0, 0);
        for (i = 0; i < n; i++) printf("%d ", harmony[i]);
        puts("");
    }
    return 0;
}


#include<stdio.h>
int main(){
    long long n;
    scanf("%lld", &n);
    printf("%lld\n", (9*n-3)<<(2*n-6));
    return 0;
}


#include <stdio.h>
unsigned long long power(unsigned long long, unsigned long long);
int main()
{
    unsigned long long no_of_parking_positions, no_of_arrangements, four_power_n_minus_3;
    scanf("%I64u",&no_of_parking_positions);

    four_power_n_minus_3 = power(4, no_of_parking_positions - 3);

    no_of_arrangements = 6*(four_power_n_minus_3 * 4) + (no_of_parking_positions - 3)*9*(four_power_n_minus_3);
    printf("%I64u",no_of_arrangements);
    return 0;
}

unsigned long long power(unsigned long long base, unsigned long long exponent)
{
    unsigned long long answer = 1;

    if(exponent == 0)
    {
        return answer;
    }

    //Binary exponentiation algorithm. Number is squared as many times as the number of 0s in binary representation. x^5 = (x^2)^2*x
    while(exponent > 0)
    {
        if(exponent%2 == 1)
        {
            answer = answer*base;
        }
        base = base*base;
        exponent = exponent >> 1;
    }
    return answer;
}


#include<stdio.h>
#include<math.h>
int main()
{
	long long int n;
	scanf("%lld",&n);
	n=4*(2*3*pow(4LL,n-3LL)+(n-3LL)*3*3*pow(4LL,n-4LL));
	printf("%lld\n",n);
	return 0;
}


#include <stdio.h>
#include<math.h>
int main (){
long long int n;
	scanf("%lld",&n);
	n=4*(2*3*pow(4LL,n-3LL)+(n-3LL)*3*3*pow(4LL,n-4LL));
	printf("%lld\n",n);
}


#include<stdio.h>
long long int power(long long int a,long long int b)
{
         long long int res=1;
         while(b!=0)
         {
                  if(b&1)
                  res=res*a;
                  a=a*a;
                  b=b/2;
         }
         return res;
}
int main()
{long long int n;
         scanf("%lld",&n);
        long long int res=power(3,n-2)
         res=res*2;
         res=res*4;
         printf("%lld\n",res);

}


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

int n;
int a[3];
char dp[300*300*300];
long long step = 0;

void calculate_result(int index, long long index1){
    if(index >= n){
        if(index1 == 0){
           dp[0] = 0;
           return;
        }
        int i, min = 300,j;
        long long index2 = index1;
        for(i=0;i<n;i++){
            min = (min > (index2 % 300) ) ? (index2 % 300) : min;
            index2 /= 300;
        }
        int win = 0;
        for(i=1;i<=min;i++){
            if(dp[index1 - i*step] == 0){
                win = 1;
                break;
            }
        }
        index2 = index1;
        long long pos = 1;
        if(win == 0){
            for(i=0;i<n;i++){
                int num = index2 % 300;
                for(j=1;j<=num;j++){
                    if(dp[index1 - pos*j] == 0){
                        win = 1;
                        break;
                    }
                }
                if( win == 1 )
                    break;
                index2 /= 300;
                pos *= 300;
            }
        }
        if(win == 1)
            dp[index1] = 1;
        return;
    }
    int i;
    for(i=0;i<=a[index];i++){
        calculate_result(index+1, index1*300 + i);
    }
}

int main(){
    scanf("%d", &n);
    int i;
    for(i=0;i<n;i++)
        scanf("%d", &a[i]);
    memset(dp, 0, sizeof(char)*300*300*300);
    for(i=0;i<n;i++)
        step = step*300 + 1;
    calculate_result(0,0);
    long long ans_index = 0;
    for(i=0;i<n;i++){
        ans_index = ans_index*300 + a[i];
    }
    if(dp[ans_index] == 1){
        printf("BitLGM\n");
    }
    else{
        printf("BitAryo\n");
    }
    return 0;
}


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

// if we write f(x) = Sum([0,n+1], bi * x^i) and q(x) = Sum([0,n], ai * x^i) and then so multiplication and equate left and right sides:
// b[n+1] = a[n]
// b[i]   = K*a[i] + a[i-1]
// b[0]   = K*a[0] + P
// from here it is easy to see that all ai should be integer (going n+1 -> 0 and knowing that bi are integers)

// TODO: ???
#define MAX_D 5000
static int64_t _a[MAX_D+2] = {}, _b[MAX_D+2] = {};

int main() {
    int64_t P,K; scanf("%" PRId64 " %" PRId64 "\n", &P,&K);

    // offset, to include P as a[-1]
    _a[0] = P; int D = 0;
    for( ; D <= MAX_D ; ++D) {
        // b[i] = K*a[i] + a[i-1] < K
        // say, a[i-1] = x*K+y (y < K), then we can write
        // b[i] = K*(a[i] + x) + y < K, and from there a[i] = -x, and b[i] = y
        // NB we want non-c modulo, but math (where rem is non-negative)
        int64_t x = _a[D] / K, y = _a[D] % K;
        if(y < 0) { y += K, --x; }
        _a[D+1] = -x, _b[D] = y;
        // TODO:
        if(_a[D] == 0) break;
    }

    printf("%d\n", D);
    for(int i = 0 ; i < D ; ++i) printf("%" PRId64 " ", _b[i]);
    printf("\n");
    return 0;
}


#include<stdio.h>
#define MX 1000
long long int p,k,k1=1,sm,A[MX];
int main(){
    int i,j,sz;
    long long int ims;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    scanf("%lld%lld",&p,&k);
    for(sz=0;;sz+=2){
        ims=p%(k*k);
        p=p/(k*k);
        if(ims>=k){
            p++;
            A[sz]=ims%k;
            A[sz+1]=k-(ims/k);
        }
        else{
            A[sz]=ims;
        }
        if(p==0){break;}
    }
    printf("%d\n",sz+1);
    for(i=0;i<=sz;i++){
        printf("%lld ",A[i]);
    }
}


#import<stdio.h>
#define swap(a,b) (a)^=(b)^=(a)^=(b)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
long long gcd(long long a,long long b) {return !b?a:gcd(b,a%b);}
int main()
{
	long long l1,r1,t1,l2,r2,t2;
	scanf("%lld%lld%lld%lld%lld%lld",&l1,&r1,&t1,&l2,&r2,&t2);
	if (l1>l2) swap(l1,l2),swap(r1,r2),wwap(t1,t2);
	long long k=gcd(t1,t2),p,ans=0;
	p=(l2-l1)/k;l1+=k*p,r1+=k*p;
	ans=max(ans,(min(r1,r2)-max(l1,l2))+1);
	l1+=k,r1+=k;
	ans=max(ans,(min(r1,r2)-max(l1,l2))+1);
	printf("%lld\n",ans);
	return 0;
}


#import<stdio.h>
#define swap(a,b) (a)^=(b)^=(a)^=(b)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
long long gcd(long long a,long long b) {return !b?a:gcd(b,a%b);}
int main()
{
	long long l1,r1,t1,l2,r2,t2;
	scanf("%lld%lld%lld%lld%lld%lld",&l1,&r1,&t1,&l2,&r2,&t2);
	if (l1>l2) swap(l1,l2),swap(r1,r2),swap(t1,t2);
	long long k=gcd(t1,t2),p,ans=0;
	p=(l2-l1)/k;l1+=k*p,r1+=k*p;
	ans=max(ans,(min(r1,r2)-max(l1,l2))+1);
	l1+=k,r1+=k;
	ans=max(ans,(min(r1,r2)-max(l1,l2))+1);
	printf("%lld\n",ans);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a < b) ? (a) : (b))
#define max(a, b) ((a > b) ? (a) : (b))

int l = 1, r, answ, t = 1;
long long a[11];
long long ans[2048];
int b[13], use[13];
int n, m, k;

int
analyze(void)
{
    int i, nonzero = 0;
    long long tmp = 0;
    for(i = 10; i >= 0; --i){
        if(a[i] == 0 && nonzero){
            return 1;
        }
        tmp = tmp * 10 + a[i];
        if (a[i] != 0){
            nonzero = 1;
        }
    }
    if(tmp >= r){
        ans[n++] = tmp;
        return 0;
    }
    if(tmp >= l){
        ans[n++] = tmp;
    }
    return 1;
}

void
go(int i)
{
    if(!t){
        return;
    }
    if (i == -1){
        t = analyze();
        return;
    }
    a[i] = 0;
    go(i - 1);
    a[i] = 4;
    go(i - 1);
    a[i] = 7;
    go(i - 1);
}

void
gen(int n, int p, int k){
if(p > 0){
    int i, ans = 1;
    for(i = 1; i <= p - 1; ++i){
        ans *= i;
    }
    int tmp = k / ans;
    if(k % ans == 0){
        --tmp;
    }
    for(i = 0; ; ++i){
        if(use[i] == 0){
            if(tmp > 0){
                --tmp;
            } else {
                use[i] = 1;
                b[n - p] = i;
                break;
            }
        }
    }
    gen(n, p - 1, k % ans ? k % ans : ans);
}
}

int
main(void)
{
    scanf("%d%d", &m, &k);
    r = m;
    go(10);
    answ = 0;
    int i, j, q;
    for(i = 0; ans[i] <= m - 13; ++i){
        ++answ;
    }
    gen(min(13, m), min(13, m), k);
    for(i = 0; i < min(13, m); ++i){
        b[i] += max(1, m - 12);
    }
    for(i = max(1, m - 12); i <= m; ++i){
        for(j = 0; j < n; ++j){
            if(ans[j] == i){
                for(q = 0; q < n; ++q){
                    if(b[i - max(1, m - 12)] == ans[q]){
                        ++ answ;
                    }
                }
            }
        }
    }
    printf("%d", answ);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a < b) ? (a) : (b))
#define max(a, b) ((a > b) ? (a) : (b))

int l = 1, r, answ, t = 1;
long long a[11];
long long ans[2048];
int b[13], use[13];
int n, m, k;

int
analyze(void)
{
    int i, nonzero = 0;
    long long tmp = 0;
    for(i = 10; i >= 0; --i){
        if(a[i] == 0 && nonzero){
            return 1;
        }
        tmp = tmp * 10 + a[i];
        if (a[i] != 0){
            nonzero = 1;
        }
    }
    if(tmp >= r){
        ans[n++] = tmp;
        return 0;
    }
    if(tmp >= l){
        ans[n++] = tmp;
    }
    return 1;
}

void
go(int i)
{
    if(!t){
        return;
    }
    if (i == -1){
        t = analyze();
        return;
    }
    a[i] = 0;
    go(i - 1);
    a[i] = 4;
    go(i - 1);
    a[i] = 7;
    go(i - 1);
}

void
gen(int n, int p, int k){
if(p > 0){
    int i, ans = 1;
    for(i = 1; i <= p - 1; ++i){
        ans *= i;
    }
    int tmp = k / ans;
    if(k % ans == 0){
        --tmp;
    }
    if (tmp >= n){
        printf("-1");
        m = -1;
        return;
    }
    for(i = 0; ; ++i){
        if(use[i] == 0){
            if(tmp > 0){
                --tmp;
            } else {
                use[i] = 1;
                b[n - p] = i;
                break;
            }
        }
    }
    gen(n, p - 1, k % ans ? k % ans : ans);
}
}

int
main(void)
{
    scanf("%d%d", &m, &k);
    r = m;
    go(10);
    answ = 0;
    int i, j, q;
    for(i = 0; ans[i] <= m - 13; ++i){
        ++answ;
    }
    gen(min(13, m), min(13, m), k);
    if(m == -1){
        return 0;
    }
    for(i = 0; i < min(13, m); ++i){
        b[i] += max(1, m - 12);
    }
    for(i = max(1, m - 12); i <= m; ++i){
        for(j = 0; j < n; ++j){
            if(ans[j] == i){
                for(q = 0; q < n; ++q){
                    if(b[i - max(1, m - 12)] == ans[q]){
                        ++ answ;
                    }
                }
            }
        }
    }
    printf("%d", answ);
    return 0;
}


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

#define N	13

long long lucky(int b) {
	return b == 1 ? 0 : lucky(b / 2) * 10 + (b % 2 == 0 ? 4 : 7);
}

int is_lucky(int y) {
	return y == 0 ? 1 : is_lucky(y / 10) && (y % 10 == 4 || y % 10 == 7);
}

int ff[N];

void init() {
	int i, f;

	f = 1;
	for (i = 0; i < N; i++) {
		ff[i] = f;
		f *= i + 1;
	}
}

int get(int n, int k, int i) {
	static char used[N];
	int h, j;

	memset(used, 0, n * sizeof *used);
	for (h = 0; h < n; h++) {
		int f = ff[n - 1 - h], s = k / f;

		for (j = 0; j < n; j++)
			if (!used[j] && s-- == 0) {
				if (h == i)
					return j;
				used[j] = 1;
				break;
			}
		k %= f;
	}
	return -1;
}

int main() {
	int n, n_, k, b, ans;
	long long f;

	init();
	scanf("%d%d", &n, &k);
	f = 1;
	n_ = 1;
	while (f < k)
		f *= ++n_;
	if (n_ > n) {
		printf("-1\n");
		return 0;
	}
	ans = 0;
	for (b = 2; ; b++) {
		long long x = lucky(b);
		int y;

		if (x > n)
			break;
		if (x <= n - n_) {
			ans++;
			continue;
		}
		y = n - n_ + get(n_, k - 1, x - (n - n_) - 1) + 1;
		if (is_lucky(y))
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
#define N 1050000
#define M 2300000
#define T 1048576
int n,m;
int first[M];
int second[M];
int last[N];
int wei[N];
int pei[N];
int ans[N];
void add(int a[],int x)
{
    x+=T-1;
    while(x)
    {
        a[x]++;
        x>>=1;
    }
}
void del(int a[],int x)
{
    x+=T-1;
    while(x)
    {
        a[x]--;
        x>>=1;
    }
}
int find(int a[],int now,int l,int r,int x)
{
    if(l==r)
        return l;
    int mid=(l+r)/2;
    if(x<=a[now<<1])
        return( find(a,now<<1,l,mid,x) );
    return( find(a,now*2+1,mid+1,r,x-a[now<<1]) );
}
int main()
{
    int i,a,b;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        add(second,i);
    for(i=1;i<=m;i++)
    {
        scanf("%d%d",&a,&b);
        if(first[1]>=b)
            b=wei[find(first,1,1,T,first[1]-b+1)];
        else
            b=find(second,1,1,T,b-first[1]);
        if(ans[b]==a)
        {
            wei[i]=b;
            del(first,last[b]);
            last[b]=i;
            add(first,i);
            continue;
        }
        if(ans[b] || pei[a])
        {
            printf("-1\n");
            return 0;
        }
        ans[b]=a;
        pei[a]=b;
        last[b]=i;
        wei[i]=b;
        del(second,b);
        add(first,i);
    }
    int now=0;
    for(i=1;i<=n;i++)
        if(!ans[i])
        {
            now++;
            while(pei[now])
                now++;
            ans[i]=now;
        }
    for(i=1;i<n;i++)
        printf("%d ",ans[i]);
    printf("%d\n",ans[n]);
    return 0;
}


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

#define N	20
#define MD	1000000007

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[N];

void init() {
	int k;

	for (k = 1; k < N; k++) {
		gcd_(k, MD);
		if (x_ < 0)
			x_ += MD;
		inv[k] = x_;
	}
}

long long ch(long long n, int k) {
	return k == 0 ? 1 : ch(n - 1, k - 1) * (n % MD) % MD * inv[k] % MD;
}

int main() {
	static long long ff[N];
	int n, b, i, ans;
	long long s;

	init();
	scanf("%d%lld", &n, &s);
	for (i = 0; i < n; i++)
		scanf("%lld", &ff[i]);
	ans = 0;
	for (b = 0; b < 1 << n; b++) {
		long long t;
		int k;

		t = s;
		k = 0;
		for (i = 0; i < n; i++)
			if (b & 1 << i) {
				k++;
				t -= ff[i] + 1;
			}
		if (t >= 0) {
			int cnt = ch(t + n - 1, n - 1);

			ans = (ans + (k % 2 == 0 ? cnt : -cnt)) % MD;
		}
	}
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	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<stdlib.h>
#include<stdio.h>
#include<string.h>

typedef long long int lli;
typedef struct bst bst;

#define TRUE         (1==1)
#define FALSE        (!(TRUE))
#define in32(x)      scanf("%d", &(x))
#define in64(x)      scanf("%I64d", &(x))
#define instr(x)     scanf("%s", (x))
#define out32(x)     printf("%d\n", (x))
#define out64(x)     printf("%I64d\n", (x))
#define outstr(x)    printf("%s\n", (x))
#define sigNUM(x)    (((x)==0)?0:(((x)<0)?-1:1))
#define max(a,b)     ((a)<(b))?(b):(a)
#define min(a,b)     ((a)>(b))?(b):(a)
#define abs(a)       ((a)<0)?(-(a)):(a)
#define fo3(i,a,b)   for(i=(int)(a);i<=(int)(b);i++)
#define of3(i,a,b)   for(i=(int)(a);i>=(int)(b);i--)

void fastWrite(FILE * ofp, int x) {
    int i = 12;
    char buff[i];
    buff[i] = 0;
    int neg = 0;
    if (x < 0){
        x = -x;
        neg = 1;
    }
    if (x == 0)
        buff[--i] = '0';
    else while (x != 0) {
        buff[--i] = (x % 10) + '0';
        x /= 10;
    }
    if (neg)
        buff[--i] = '-';
    fwrite(buff + i, sizeof(char), (12 - i), ofp);
}

void fastSpace(FILE * ofp){
    fwrite(" ", sizeof(char), 1, ofp);
}
void fastNewLine(FILE * ofp) {
    fwrite("\n", sizeof(char), 1, ofp);
}

int comp(lli f, lli s) {
    return sigNUM(f - s);
}

void sort(lli * arr, int size) { // CHANGE THIS
    int i;
    if (size < 6) {
        int nSize = 0;
        while (size != 0) {
            nSize = 0;
            for (i = 0; i < size - 1; i++)
                if (comp(arr[i], arr[i + 1]) > 0) { // CHANGE THIS
                    nSize = i + 1;
                    lli tmp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i+1] = tmp;
                }
            size = nSize;
        }
        return;
    }
    lli * tmp = (lli *)calloc(size, sizeof(lli)); // CHANGE THIS
    int lSize = (size >> 1);
    int rSize = size - lSize;
    sort(arr, lSize); sort(arr + lSize, rSize);
    int lPtr = 0, rPtr = 0;
    int ptr = 0;
    while (ptr != size) {
        if (lPtr == lSize)
            tmp[ptr] = arr[lSize + (rPtr++)];
        else if (rPtr == rSize || comp(arr[lPtr], arr[lSize + rPtr]) <= 0) // CHANGE THIS
            tmp[ptr] = arr[lPtr++];
        else
            tmp[ptr] = arr[lSize + (rPtr++)];
        ptr++;
    }
    for (i = 0; i < size; i++)
        arr[i] = tmp[i];
    free(tmp);
}

#define MAX 25
#define MOD 1000000007

lli invert(lli a) {
    if (a == 0)
        return 1;
    if (a == 1)
        return 1;
    return MOD - ((MOD / a) * invert(MOD % a)) % MOD;
}

int main(void) {
    lli n, a[MAX], i, j, s, s2, inv = 1, ans = 0, tans, mult;
    in64(n);
    in64(s);
    fo3(i,0,n-1) {
        in64(a[i]);
        inv *= invert(i);
        inv %= MOD;
    }
    fo3(i,0,(1<<n)-1) {
        s2 = s;
        mult = 1;
        fo3(j,0,n-1) {
            if ((1<<j)&i) {
                mult = -mult;
                s2 -= a[j] + 1;
            }
        }
        if (s2 < 0)
            continue;

        s2 += n - 1;
        tans = inv;
        fo3(j,0,n-2) {
            tans *= (s2 - j) % MOD;
            tans %= MOD;
        }
        ans += mult * tans;
    }
    ans = (ans % MOD + MOD) % MOD;
    out64(ans);
    return 0;
}


/*      ����
n������,ÿ������fi�仨.
һ�������ڻ�����ɫ����ͬ��.
�����������ӵĻ���ɫ��ͬ��
��Ҫȡ��s�仨,��ȡ����mod = 1e9+7;
ÿ�ַ������ٴ�һ������ѡ��ͬ�����Ļ���
*/

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

typedef long long int  ll;
const ll Mod=1000000000+7;
ll n,s,f[22],inv[22],c[22];

ll Pow(ll a,ll b)//������
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%Mod;
        a=(a*a)%Mod;
        b>>=1;
    }
    return ans;
}

ll C(ll a,ll b)//�����
{
    if(a<b)
        return 0;
    if(b>a-b)
        b=a-b;
    ll s1,s2,i;
    s1=s2=1;
    for(i=0;i<b;i++)
    {
        s1=s1*(a-i)%Mod;
        s2=s2*(i+1)%Mod;
    }
    return s1*Pow(s2,Mod-2)%Mod;
}

ll Lucas(ll n,ll k)//lucas����
{
    if(n<0)
        return 0;
    if(k==0)
        return 1;
    return C(n%Mod,k%Mod)*Lucas(n/Mod,k/Mod)%Mod;
}

int main()
{
    int i,j;
    scanf("%I64d%I64d",&n,&s);
    for(i=1;i<=n;i++)
        scanf("%I64d",&f[i]);
    ll ans=Lucas(s+n-1,n-1);
    for(i=1;i<(1<<n);i++)
    {
        int cnt=0;
        ll sum=0;
        for(j=0;j<n;j++)
        {
            if((1<<j)&i)
            {
                cnt++;
                sum+=f[j+1]+1;
            }
        }
        ll tmp=Lucas((s-sum)+(n-1),(n-1));
        if(cnt%2==1)
            ans-=tmp;
        else
            ans+=tmp;
        ans=(ans+Mod)%Mod;
    }
    printf("%I64d \n",ans);
    return 0;
}


#include<stdio.h>
long long f[23],n,s,sum;
int c[23];
void function(){
	int i,t1;
	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) {
    return power(a,m-2,m);
}

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 <stdlib.h>
#include <memory.h>

#define min(a,b) a<=b?a:b

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

  int *a = calloc(n,sizeof(int));
  int *mk= calloc(n,sizeof(int));
  memset(mk, 0, sizeof(int)*n);

  if(n == 1)
  {
    scanf("%d", &a[0]);
    printf("%d\n", a[0]);
    return 0;
  }

  int i,j;
  for(i=0;i<n;++i)
    scanf("%d", a+i);

  for(i=0;i<n;++i)
  {
    int mn=0x7fffffff,val=-1;
    for(j=0;j<n;++j)
    {
      if(mk[j] || a[i] >= a[j])continue;
      if(a[j] - a[i] < mn)
      {
        mn = a[j] - a[i];
        val = j;
      }
    }
    if(~val)
    {
      mk[val] = 1;
      printf("%d%c", a[val], " \n"[i==n-1]);
    }else
    {
      mn=a[0];
      for(j=1;j<n;++j)
        mn = min(mn,a[j]);
      printf("%d%c", mn, " \n"[i==n-1]);
    }
  }

  return 0;
}