#include<stdio.h>
#include<string.h>
#include<iostream>
#include<vector>
//#include<algorithm>
using namespace std;
#include<stdlib.h>
#define T 1e16
#define L 1000003
long long  c[28]={0,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368000,20922789888000,355687428096000,6402373705728000,121645100408832000};
struct node
{
    long long value;
    int t;
    int same;
}tem;

int cmp(const void *a,const void *b)
{
    return ((struct node*)a)->value < ((struct node*)b)->value;
}
int get_ha(long long x)
{
    x*=131;
    return x%L;
}
vector<struct node > vec[L];
int a[100];
long long s,count;
int lim,len,n,ha,k;
void dfs(int cur,long long sum,int ik,int fg)
{
    int i;
    if(sum>s)
    {
        return ;
    }
    if(fg==0&&cur==lim)
    {

        tem.value=sum;
        tem.t=ik;
        tem.same=1;
        ha=get_ha(sum);
        len=vec[ha].size();
        for(i=0;i<len;i++)
        {
            if(vec[ha][i].value==sum&&vec[ha][i].t==ik)
            {
                vec[ha][i].same++;
                break;
            }
        }
        if(i==len)
        vec[ha].push_back(tem);
        return ;
    }
    else if(fg==1&&cur==n)
    {
        ha=get_ha(s-sum);
        len=vec[ha].size();
        for(i=0;i<len;i++)
        {
            if(vec[ha][i].value==s-sum&&vec[ha][i].t+ik<=k)
            {
                count+=vec[ha][i].same;
            }
        }
        return ;
    }
    if(sum+a[cur]<=T)
    dfs(cur+1,sum+a[cur],ik,fg);
    dfs(cur+1,sum,ik,fg);
    if(ik<k&&a[cur]<=18)
    {
        dfs(cur+1,sum+c[a[cur]],ik+1,fg);
    }
}
int main()
{
    int i,j;
    scanf("%d %d %I64d",&n,&k,&s);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    //sort(a,a+n);
    qsort(a,n,sizeof(a[0]),cmp);
    count=0;
    lim=n/2;
    //printf("lim=%d\n",lim);
    dfs(0,0,0,0);
    //system("pause");
    dfs(lim,0,0,1);
    printf("%I64d\n",count);
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define ull unsigned long long
#define CY printf("YES\n")
#define CN printf("NO\n")
#define x first
#define y second
#define PII pair<int,int >
#define de(x) cerr<<#x<<'='<<x<<'\n'
#define dde(x,y) cerr<<#x<<'='<<x<<","<<#y<<"="<<y<<'\n'
#define rep(i, a, b) for(int i = (a); i <= (b); i ++)
#define dec(i, a, b) for(int i = (a); i >= (b); i --)
#define vi vector<int>
#define vpii vector<PII>
#define pb push_back
#define rvs(s) reverse(s.begin(),s.end())
#define all(s) s.begin(),s.end()
int qmi(int a, int k);
int mo(int x,int p){return x = ((x%p)+p)%p;}
const int N=2000007;
const int mod=1e9+7;
const int inf=0x3f3f3f3f3f3f3f3f;
const double eps=1e-8;
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int  n,m,k,t,q,p,x,y;
int a[N],vis[N],b[N],dp[N];
bool st[100000000];
int cnt=0;
signed main (){
	cin>>n>>m;
	rep(i,1,20){
		rep(j,1,m){
			if(st[i*j]==false){
				cnt++;
				st[i*j]=true;
			}
		}
		dp[i]=cnt;
	}
	int res=1;
	rep(i,2,n){
		if(vis[i]==0){
			int ct=0;
			for(int j=i;j<=n;j*=i){
				ct++;
				vis[j]=1;
			}
			res+=dp[ct];
		}
	}
	cout<<res;

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


#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

typedef long long LL;

const int MOD=1e9+7;
const int Maxn=100+9;

#define plus(x,y) (x=((x)+(y)>=MOD)?((x)+(y)-MOD):((x)+(y)))

int c[Maxn][Maxn],n,m,K,dp[2][Maxn][Maxn][Maxn],Ans;

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

	c[0][0]=1;

	for(int i=1;i<=K;++i)
		for(int j=0;j<=i;++j)
		{
			c[i][j]=(j?c[i-1][j-1]:0)+c[i-1][j];

			if(c[i][j]>K)
				c[i][j]=K+1;
		}

	++n;

	int now=1,last=0;

	dp[now][0][1][1]=1;

	for(int i=0;i<=m;++i)
	{
		last=now,now^=1;

		if(i)
		{
			int tmp=0;

			for(int j=2;j<=n;++j)
				for(int l=1;l<=K;++l)
					plus(tmp,dp[last][j][0][l]);

			plus(Ans,(LL)tmp*(m-i+1)%MOD);
		}

		if(i==m)
			break;

		memset(dp[now],0,sizeof(dp[now]));

		for(int j=0;j<=n;++j)
			for(int k=1;k<=n;++k)
				for(int l=1;l<=K;++l)
					if(dp[last][j][k][l])
						for(int t=k;t<=n-j;++t)
							if(l*c[t-1][k-1]<=K)
								plus(dp[now][j+t][t-k][l*c[t-1][k-1]],dp[last][j][k][l]);
	}

	printf("%d\n",Ans);

	return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int x;

int main(){
	cin>>x;
	if(x==2){cout<<3;return 0;}
	if(x==3){cout<<5;return 0;}
	int ans=1;
	while(1){
		if((ans*ans+1)/2>=x){
			cout<<ans;
			return 0;
		}
		ans+=2;
	}
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #define LOCAL
#ifdef LOCAL
#define DEBUG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define DEBUG(fmt, ...)
#endif

using namespace std;
#define szof(v) ((int)(v).size())
#define allof(v) begin(v), end(v)
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxheap = priority_queue<T>;

set<pair<ll, int>> visit;
unordered_set<ll> dests;

void dfs(ll x, int rem) {
    visit.insert({x, rem});
    if (rem > 0) {
        if (visit.find(make_pair(x + 1, rem - 1)) == visit.end()) {
            dfs(x + 1, rem - 1);
        }
        if (visit.find(make_pair(x + 5, rem - 1)) == visit.end()) {
            dfs(x + 5, rem - 1);
        }
        if (visit.find(make_pair(x + 10, rem - 1)) == visit.end()) {
            dfs(x + 10, rem - 1);
        }
        if (visit.find(make_pair(x + 50, rem - 1)) == visit.end()) {
            dfs(x + 50, rem - 1);
        }
    } else {
        // DEBUG("dest = %lld\n", x);
        // ++cnt;
        dests.insert(x);
    }
}

void mmain() {
    // int lastans = 0;
    int n;
    scanf("%d", &n);
    vector<int> small = {
        0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292, 341, 390, 439, 488,
    };
    if (n <= 15) {
        printf("%d\n", small[n]);
        return;
    } else {
        printf("%lld\n", 49LL * (n - 15) + 1LL*small[15]);
    }

    // dfs(0, 200);
    // int ans = dests.size();
    // if (ans == 49LL * (200 - 15) + small[15]) {
    //     printf("cool\n");
    // } else {
    //     printf("no\n");
    // }
    // for (int n = 1; n <= 15; ++n) {
    //     visit.clear();
    //     dests.clear();
    //     dfs(0, n);
    //     printf("%d, ", szof(dests));
    //     // printf("n = %d, ans = %d, delta = %d\n", n, szof(dests),
    //     //        szof(dests) - lastans);
    //     // lastans = szof(dests);
    // }
    // int n;
    // scanf("%d", &n);
    // if (n <=)
    // dfs(0, n);
    // cout << dests.size() << "\n";
}

int main() {
#ifdef LOCAL
    clock_t begin = clock();
    printf("*********Starting program*********\n\n");
    freopen("data.txt", "r", stdin);
#endif
    mmain();
#ifdef LOCAL
    clock_t end = clock();
    double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
    printf("\nTime taken: %lf\n", elapsed_secs);
#endif
}


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

const int mod = 998244353;
const int N = 55;
const int M = 2010;

typedef long long LL;

int Pow(int x, int y) {
	int res = 1;
	for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
	return res;
}

int a[N], coef[2][N][M], frac[M], inv[M];

int main() {
	int n, k, L = 0; cin >> n >> k;
	bool flag = false;
	for (int i = 1; i <= n; i++) {
		cin >> a[i], L += a[i];
		if (a[i] > k) flag = true;
	}
	if (!flag) return puts("0"), 0;
	frac[0] = inv[0] = 1;
	for (int i = 1; i <= M - 10; i++)
		frac[i] = (LL)frac[i - 1] * i % mod, inv[i] = Pow(frac[i], mod - 2);
	int tot = 0; coef[0][0][0] = 1;
	int cur = 0;
	L = Pow(L, mod - 2);
	for (int i = 1; i <= n; i++) {
		cur ^= 1, memset(coef[cur], 0, sizeof(coef[cur]));
		int lim = (a[i] - 1) / k;
		static int tmp[M], tmp1[M];
		for (int l = 0; l <= lim; l++) {
			int w1 = (LL)(a[i] - l * k) * L % mod;
			tmp[l] = Pow(w1, l);
			if (l) tmp1[l] = Pow(w1, l - 1);
		}
		for (int j = 0; j < i; j++)
			for (int t = j; t <= tot; t++) if (coef[cur ^ 1][j][t]) {
				int w = coef[cur ^ 1][j][t];
				for (int l = 0; l <= lim; l++) {
					int hh = (LL)w * inv[l] % mod;
					if (l & 1) hh = mod - hh;
					coef[cur][j][t + l] = (coef[cur][j][t + l] + (LL)hh * tmp[l]) % mod;
					if (l) coef[cur][j + 1][t + l] = (coef[cur][j + 1][t + l] + (LL)hh * l % mod * tmp1[l]) % mod;
				}
			}
		tot += lim;
	}
	int res = 0;
	for (int i = 0; i <= n; i++)
		for (int j = i; j <= tot; j++) if (coef[cur][i][j]) {
			int w = coef[cur][i][j];
			int a = j - i, b = 1 - (LL)j * k * L % mod;
			if (b < 0) b += mod;
			res = (res + (LL)w * frac[a] % mod * Pow(Pow(mod + 1 - b, mod - 2), a + 1)) % mod;
		}
	printf("%d\n", (mod - res) % mod);
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

const double EPS = 1e-9;

struct point3d {
    double x, y, z;

    point3d ( double a , double b , double c ) : x(a) , y(b) , z(c) {}
    point3d ( double a , double b ) : x(a) , y(b) , z(0) {}
    point3d ( void ) : x(0) , y(0) , z(0) {}

    point3d operator- ( const point3d& o ) const {
        return point3d(x - o.x, y - o.y, z - o.z);
    }

    point3d operator* ( double o ) const {
        return point3d(o*x, o*y, o*z);
    }

    double cross ( const point3d& o ) const {
        return x * o.y - o.x * y;
    }
};

struct segment {
    point3d p0, p1, u;

    segment ( point3d& a , point3d& b ) : p0(a) , p1(b) , u(b - a) {}
};

struct polygon {
    int n_points;
    std::vector<point3d> points;

    polygon ( void ) : n_points(0) { }

    point3d& operator[] ( int i ) {
        return points[i];
    }
};

struct ray {
    point3d v;

    ray ( void ) { }

    ray ( point3d a ) : v(a) {}

    double intersect ( point3d& p ) {
        double point_t;
        if ( fabs(v.cross(p)) < EPS ) {
            point_t = p.x / (double) v.x;
            if ( point_t < -EPS || point_t > 1 + EPS ) {
                return INFINITY;
            }
            return point_t;
        }
        return INFINITY;
    }

    double intersect ( segment&& s ) {
        const point3d& u = s.u;
        const point3d& w = s.p0;

        double det, ray_t, segment_t;

        det = v.cross(u);
        if ( fabs(det) < EPS ) {
            return std::min(intersect(s.p0), intersect(s.p1));
        }

        ray_t = w.cross(u) / det;
        segment_t = w.cross(v) / det;

        if ( ray_t < -EPS || segment_t < -EPS || segment_t > 1 + EPS ) {
            return INFINITY;
        }

        return ray_t;
    }

    double intersect ( polygon& p ) {
        int i;
        double min_t;

        min_t = INFINITY;
        for ( i = 0 ; i < p.n_points ; ++ i ) {
            min_t = std::min(min_t, intersect(segment(p[i], p[i+1])));
        }

        return min_t;
    }

    bool is_parallel ( ray& o ) {
        return fabs(v.cross(o.v)) < EPS;
    }
};

std::pair<double, double> ray_time ( ray& free_fall , ray& parachute , polygon& fence , int g ) {
    double free_fall_t, parachute_t, aux_t;

    free_fall_t = free_fall.intersect(fence);
    parachute_t = parachute.intersect(fence);

    if ( free_fall_t < parachute_t ) {
        aux_t = - free_fall.v.z * free_fall_t / (double) g;
        return std::make_pair(free_fall_t, aux_t);
    }
    return std::make_pair(parachute_t, 0);
}

std::pair<double, double> vertex_time ( point3d& vertex , point3d& plane , point3d& wind , int g ) {
    double A, B, C, D, det;
    std::pair<double, double> ans;

    A = plane.x - plane.z * wind.x / (double) wind.z;
    B = - g * wind.x / (double) wind.z;
    C = plane.y - plane.z * wind.y / (double) wind.z;
    D = - g * wind.y / (double) wind.z;

    det = A * D - B * C;
    ans.first = ( vertex.x * D - B * vertex.y ) / det;
    ans.second = ( A * vertex.y - vertex.x * C ) / det;

    if ( ans.first < -EPS || ans.second < -EPS || plane.z * ans.first + g * ans.second < -EPS ) {
        return std::make_pair(INFINITY, INFINITY);
    }

    return ans;
}

int main ( void ) {

    int i, g;
    polygon fence;
    point3d origin, plane, wind;
    ray free_fall, parachute_fall;
    std::pair<double, double> best_t;

    std::cin >> fence.n_points;
    fence.points.resize(fence.n_points + 1);

    for ( i = 0 ; i < fence.n_points ; ++ i ) {
        std::cin >> fence[i].x >> fence[i].y;
    }
    fence[fence.n_points] = fence[0];

    std::cin >> origin.x >> origin.y;
    std::cin >> plane.x >> plane.y >> plane.z;
    std::cin >> g;
    std::cin >> wind.x >> wind.y >> wind.z;

    for ( i = 0 ; i <= fence.n_points ; ++ i ) {
        fence[i].x -= origin.x;
        fence[i].y -= origin.y;
    }

    free_fall = ray(plane);
    parachute_fall = ray(plane - wind * (plane.z/(double)wind.z));

    best_t = ray_time(free_fall, parachute_fall, fence, g);

    if ( !free_fall.is_parallel(parachute_fall) ) {
        for ( point3d& p : fence.points ) {
            best_t = std::min(best_t, vertex_time(p, plane, wind, g));
        }
    }

    if ( best_t.first == INFINITY || best_t.second == INFINITY ) {
        std::cout << "-1 -1" << std::endl;
        return 0;
    }

//    std::cout << best_t.first << std::endl;
//    std::cout << (free_fall.v * best_t.first).x << " " << (free_fall.v * best_t.first).y << std::endl;

//    std::cout << (parachute_fall.v * best_t.first).x << " " << (parachute_fall.v * best_t.first).y << std::endl;
//    std::cout << (parachute_fall.v * 1).x << " " << (parachute_fall.v * 1).y << std::endl;
//    std::cout << (parachute_fall.v * 2).x << " " << (parachute_fall.v * 2).y << std::endl;

    std::cout << std::fixed << std::setprecision(10)
              << best_t.first << " " << best_t.second << std::endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)

#define type(x) __typeof(x.begin())

#define orta (bas + son >> 1)
#define sag (k + k + 1)
#define sol (k + k)

#define pb push_back
#define mp make_pair

#define nd second
#define st first

#define endl '\n'

typedef pair < int ,int > pii;

typedef long long ll;

const long long linf = 1e18+5;
int mod = (int) 1e9 + 7;
const int logN = 18;
const int SQ = 250;
const int inf = 1e9;
const int N = 5e4 + 5;

ll all, ch[N], path[N];
int size[N], ok[N], dp[N], n, m, P[N], p[N], x, y, z, t, val[N], C[N];
vector< pair< int , pii > > q;
vector< int > v[N], nodes;
char c;

int up(int x, int y) {
    if(!x) return 0;
    int &r = dp[x];
    if(r != -1) return r;
    if(P[x] == y) return r = x;
    return r = up(P[x], y);
}

int up2(int x) {
    if(ok[x]) return x;
    int &r = dp[x];
    if(r != -1) return r;
    return r = up2(P[x]);
}

int dfs1(int node) {
    size[node] = 1;
    int s = ok[node] ? 2 : 0;
    ch[node] = 0;
    foreach(it, v[node]) {
        s += dfs1(*it);
        size[node] += size[*it];
        ch[node] -= size[*it] * (ll) size[*it];
    } ch[node] += size[node] * (ll) size[node];
    if(s >= 2) ok[node] = 1;
    all += ch[node] * (ll) val[node];
    return s != 0;
}

void dfs2(int node, int last, int root, int bef = 0) {
    path[node] = path[root] + (size[root] - size[node]) * (ll) val[root];
    C[node] = size[bef];
    if(ok[node]) { nodes.pb(node); P[node] = last; last = node; bef = -1; }
    foreach(it, v[node]) {
        if(bef == -1) dfs2(*it, node, node, *it);
        else dfs2(*it, last, node, bef);
    }
}

int ctr(int x, int y) {
    while(x) {
        if(x == y) return 1;
        x = P[x];
    } return 0;
}

int main() {

    scanf("%d", &n);
    FOR(i, 2, n) scanf("%d", &p[i]);
    FOR(i, 1, n) scanf("%d", &val[i]);

    scanf("%d", &m);

    FOR(i, 1, m) {
        scanf(" %c %d %d", &c, &y, &z);
        if(c == 'P') { ok[y] = ok[z] = 1; q.pb(mp(0, mp(y, z))); }
        if(c == 'V') { ok[y] = 1; q.pb(mp(1, mp(y, z))); }
        if(i == m || i % SQ == 0) {
            FOR(i, 1, n) v[i].clear();
            FOR(i, 2, n) v[p[i]].pb(i);
            nodes.clear();
            ok[1] = 1; all = 0;
            dfs1(1), dfs2(1, 0, 0, 1);
            memset(ok, 0, sizeof ok);
            foreach(it, q) {
                printf("%.12lf\n", all / (1.0 * n * n));
                foreach(it3, nodes) ok[*it3] = 0;
                if(it->st == 1) {
                    int node = it->nd.st, val = it->nd.nd - ::val[node];
                    all += val * ch[it->nd.st];
                    foreach(it3, nodes) dp[*it3] = -1;
                    foreach(it3, nodes) {
                        int take = up(*it3, node);
                        if(take == 0) continue;
                        path[*it3] += val * (ll) (size[node] - C[take]);
                    } :: val[node] += val;
                }
                else {
                    if(ctr(it->nd.nd, it->nd.st)) swap(it->nd.nd, it->nd.st);
                    p[it->nd.st] = it->nd.nd;
                    int node = it->nd.st, par = P[it->nd.st], sz = size[node];
                    all -= 2 * sz * path[node];
                    while(par) {
                        ok[par] = ok[node] = 1;
                        ch[par] -= 2LL * sz * (size[par] - C[node]);
                        size[par] -= sz; C[node] -= sz;
                        node = P[node]; par = P[par];
                    } C[1] -= sz; C[it->nd.st] = sz;
                    ll ggg = path[it->nd.st];
                    foreach(it3, nodes) dp[*it3] = -1;
                    foreach(it3, nodes) {
                        if(!ok[*it3] || *it3 == it->nd.st) {
                            int take = up2(*it3);
                            if(take == it->nd.st) path[*it3] -= ggg;
                            else path[*it3] -= val[take] * (ll) sz;
                        }
                    }
                    foreach(it3, nodes) dp[*it3] = -1, ok[*it3] = 0; C[it->nd.st] = 0;
                    node = it->nd.st, par = it->nd.nd, P[node] = par;
                    while(par) {
                        ok[par] = ok[node] = 1;
                        size[par] += sz; C[node] += sz;
                        ch[par] += 2LL * sz * (size[par] - C[node]);
                        node = P[node]; par = P[par];
                    } C[1] += sz;
                    foreach(it3, nodes) dp[*it3] = -1;
                    ggg = path[it->nd.nd] + (ll) (size[it->nd.nd] - sz) * val[it->nd.nd];
                    foreach(it3, nodes) {
                       if(!ok[*it3] || *it3 == it->nd.st) {
                            int take = up2(*it3);
                            if(take == it->nd.st) path[*it3] += ggg;
                            else path[*it3] += val[take] * (ll) sz;
                        }
                    }
                    all += 2 * path[it->nd.st] * size[it->nd.st];
                    foreach(it3, nodes) dp[*it3] = -1, ok[*it3] = 0;
                }
            }
            q.clear();
            memset(ok, 0, sizeof ok);
        }
    }
    printf("%.12lf\n", all / (1.0 * n * n));
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

//#define input(a) scanf("%d", &a)
//#define input2(a,b) scanf("%d %d", &a,&b)

int main(){

	long long int n;
	long long int a=0, b=0;
	cin>>n;
	cin>>a>>b;
	/*int mayor=0, menor=0;

	if(a<b){
		mayor = b;
		menor = a;
	}
	else{
		mayor=a;
		menor=b;
	}

	int wm=0,bm=0;
	wm = mayor-1;
	bm = n - menor;

	if(bm<wm)
		printf("Black");
	else
		printf("White");
	*/
	long long int wm=0, bm=0;
	wm = max(a-1, b-1);
	bm = max(n-a, n-b);

	if(wm<=bm)
		printf("White");
	else
		printf("Black");

	return 0;
}


//175E
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
double ans=0;
int ne,nf,ns;
double le,lf,ls;
int rf,re,rs;
int de,df;
double interFLen[30][30];
double interELen[30][30];
double inter(double st1,double ed1,double st2,double ed2){
	if(st2>ed1 || st1>ed2)return 0;
	return min(ed1,ed2)-max(st1,st2);
}
int place[30];
void calc(){
	static double winF[30];
	static double winE[30];
	for(int i=1;i<=13;i++){
		winF[i]=2*lf;
		winE[i]=2*le;
		for(int j=1;j<=13;j++){
			winF[i]+=interFLen[i][j]*place[j];
			winE[i]+=interELen[i][j]*place[j];
		}
		winF[i]*=df;
		winE[i]*=de;
	}
	static double f[30][30];
	memset(f,0,sizeof(f));
	for(int pos=1;pos<=13;pos++){
		for(int times=1;times<=2-place[pos];times++){
			for(int i=nf;i>=0;i--){
				for(int j=ne;j>=0;j--){
					if(i)
						f[i][j]=max(f[i][j],f[i-1][j]+winF[pos]);
					if(j)
						f[i][j]=max(f[i][j],f[i][j-1]+winE[pos]);
				}
			}
		}
	}
	ans=max(ans,f[nf][ne]);
}
void dfs(int id,int left){
	if(id==14){
		if(!left)
			calc();
		return;
	}
	//Nothing
	dfs(id+1,left);
	//Place one
	if(left>=1){
		place[id]=1;
		dfs(id+1,left-1);
		place[id]=0;
	}
	//Place two
	if(left>=2){
		place[id]=2;
		dfs(id+1,left-2);
		place[id]=0;
	}
}
int main(){
	scanf("%d%d%d",&nf,&ne,&ns);
	scanf("%d%d%d",&rf,&re,&rs);
	scanf("%d%d",&df,&de);
	lf=sqrt(rf*rf-1);
	le=sqrt(re*re-1);
	ls=sqrt(rs*rs-1);
	for(int i=1;i<=13;i++)
		for(int j=1;j<=13;j++)
			interFLen[i][j]=inter(i-lf,i+lf,j-ls,j+ls),
			interELen[i][j]=inter(i-le,i+le,j-ls,j+ls);
	dfs(1,ns);
	cout<<fixed<<setprecision(6)<<ans<<endl;
	return 0;
}


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

int main()
{
	int n,i,d=0,f=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	d=a[1]-a[0];

  for (int i=1; i<n; i++)
    {
    	if ((a[i] - a[i-1]) != d)
     			{
     				f=1;
     				break;
     			}
     }
	if(f==1)
	{
		cout<<a[n-1]<<endl;
	}
	if(f==0)
	{
		cout<<a[n-1]+d;
	}
		return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
      long long n,i=0,k,j,ans=0,x=0,y=0,m=0,a[101],t;
      char ch[1201];
      cin>>n>>ch;
      k=strlen(ch);
      //cout<<k<<" "<<ch;
      for(i=0;i<k-1;i++)
      {
            x=0;
            y=0;
            for(j=i;j<k;j++)
            {
                  if(ch[j]=='R')
                  x++;
                  else if(ch[j]=='L')
                  x--;
                  else if(ch[j]=='U')
                  y++;
                  else
                  y--;
                  if(x==0&&y==0)
                  ans++;
            }
      }
      cout<<ans;
}


#include <iostream>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    getchar();
    int sum1 = 0;
    for(int i = 0; i < n / 2; ++i){
        char d = getchar();
        if(d != '4' && d != '7'){
            cout << "NO";
            return 0;
        }
        sum1 += d - '0';
    }
    int sum2 = 0;
    for(int i = 0; i < n / 2; ++i){
        char d = getchar();
        if(d != '4' && d != '7'){
            cout << "NO";
            return 0;
        }
        sum2 += d - '0';
    }
    if(sum1 == sum2){
        cout << "YES";
    }
    else{
        cout << "NO";
    }

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()

const int N = 30;
int n;
map<int, int> dp;
int s[35];

int dfs(int S) {
	if (dp.count(S)) return dp[S];
	int sg = 0;
	for (int i = 0; i < 30; i++) if (S>>i&1) {
		sg |= (1<<dfs((((1<<30) - 1)^s[i])&S));
	}
	for (int i = 0; ; i++) if ((sg&(1<<i)) == 0) {
		dp[S] = i;
		break;
	}
	return dp[S];
}

int sg(int x) {
	if (x == 0) return 0;
	if (x == 1) return 1;
	if (x == 2) return 2;
	if (x == 3) return 1;
	if (x == 4) return 4;
	if (x == 5) return 3;
	if (x == 6) return 2;
	if (x == 7) return 1;
	if (x == 8) return 5;
	if (x == 9) return 6;
	if (x == 10) return 2;
	if (x == 11) return 1;
	if (x == 12) return 8;
	if (x == 13) return 7;
	if (x == 14) return 5;
	if (x == 15) return 9;
	if (x == 16) return 8;
	if (x == 17) return 7;
	if (x == 18) return 3;
	if (x == 19) return 4;
	if (x == 20) return 7;
	if (x == 21) return 4;
	if (x == 22) return 2;
	if (x == 23) return 1;
	if (x == 24) return 10;
	if (x == 25) return 9;
	if (x == 26) return 3;
	if (x == 27) return 6;
	if (x == 28) return 11;
	if (x == 29) return 12;
	if (x == 30) return 14;
}

int vis[1000005];

int main() {
	int n;
	scanf("%d", &n);
	int sum = 0;
	int f = 0;
	for (int i = 2; i * i <= n; i++) {
		if (vis[i]) continue;
		int tmp = 0;
		for (ll j = i; j <= n; j *= i) {
			if (j < 1000005) vis[j] = 1;
			tmp++;
		}
	//	printf("%d %d\n", i, tmp);
		sum += tmp;
		f ^= sg(tmp);
	}
	n -= sum;
	f ^= (n % 2);
	printf("%s\n", f ? "Vasya" : "Petya");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 int n;
 cin>>n;
 string s,a;
 cin>>s;
 for(int i=0;i<n;++i)
 {if(s[i]!='o')
   a+=s[i];
  else
  {int j=i+1;
   while(j<n-1&&s[j]=='g'&&s[j+1]=='o')
    j+=2;
   if(j!=i+1)
    a+="***";
   else
    a+='o';
   i=j-1;
  }
 }
 cout<<a;
 return 0;
}


#include <iostream>
using namespace std;
int main(void)
{
    int a,s,d;
    cin>>a>>s>>d;
    cout<< min(min(2*(a+s),2*(a+d)), min(a+s+d,2*(d+s))) <<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define ll long long
#define pb push_back
using namespace std;

const int N = 1e5 + 100, M = 1e9 + 7;
typedef pair <int, int> pii;
string s, t;

bool IS(string f) {
	int j = 0;
	for(int i = 0; i < f.size(); i++) {
		if(f[i] == t[j])
			j++;
		if(j == t.size())
			break;
	}
	if(j != t.size()) {
		return false;
	}
	return true;
}

int main() {
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i < s.size(); i++) {
		for(int j = i; j < s.size(); j++) {
			string f = s;
			f.erase(i, (j - i + 1));
			if(IS(f)) {
				ans = max(ans, (j - i + 1));
			}
		}
	}
	cout << ans << endl;
}


#define _CRT_SECURE_NO_DEPRECATE

#include <bitset>
#include <array>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <cstdio>
#include <climits>
#include <iostream>
#include <vector>
#include <set>
#include <sstream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <stack>
#include <deque>
#include <tuple>
#include <queue>
#include <exception>
#include <functional>
#include <iomanip>
#ifndef __GNUC__
#include <intrin.h>
#endif
using namespace std;
typedef long long ll;

void ans()
{
	cout << "YES";
	exit(0);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	////#ifdef LOCAL_PROJECT
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif // !ONLINE_JUDGE

	ll n;
	cin >> n;
	if (n < 5)
	{
		cout << ((n)*(n - 1)) / 2;
		return 0;
	}
	for (ll i = 1000000000; i >= 10; i /= 10)
	{
		//100 [50-500)
		int buf = i / 2;
		if (n < buf)
			continue;
		ll ans = 0;
		ll j;
		ll last = buf;
		for (j = 0; j < 5; j++)
		{
			ll cur = j*i + buf;
			if (n >= cur)
			{
				ans += (j + 1)*(min(n, cur + i - 1) - (last - 1));
				if (n >= (j + 1)*i - 1)
					ans--;
			}
			last = cur + i;
		}
		cout << ans;
		break;
	}
}


#include<bits/stdc++.h>
using namespace std;
const long long maxn=1005;
const long long inf=0x3f3f3f3f;
const long long mod=1e9+7;
long long n,m,k;
long long buf[maxn][maxn],col[maxn][maxn],reach[maxn][maxn];
long long match[maxn],appear[maxn],rev[maxn];
long long calc()
{
	memset(rev,-1,sizeof(rev));
	memset(match,-1,sizeof(match));
	memset(appear,0,sizeof(appear));
	for(long long i=0;i<n;i++)
		for(long long j=0;j<m;j++)
			appear[col[i][j]]=1;
	for(long long i=0;i<n;i++)
	{
		for(long long j=0;j<m;j++)
		{
			if(~buf[i][j])
			{
				if(match[buf[i][j]]!=-1&&match[buf[i][j]]!=col[i][j])
					return 0;
				match[buf[i][j]]=col[i][j];
				if(rev[col[i][j]]!=-1&&rev[col[i][j]]!=buf[i][j])
					return 0;
				rev[col[i][j]]=buf[i][j];
			}
		}
	}
	long long k2=0;
	for(long long i=0;i<k;i++)
		if(appear[i])
			++k2;
	long long emp=0,cont=0;
	for(long long i=0;i<k;i++)
	{
		if(appear[i]&&rev[i]==-1)
			++emp;
		if(rev[i]!=-1)
			++cont;
	}
	long long ans=1;
	for(long long i=0;i<emp;i++)
		ans*=(k-cont-i);
	ans%=mod;
	return ans;
}
long long dfs(long long x,long long y,long long used)
{
	if(y==m)
	{
		y=0;
		x++;
	}
	if(x==n)
		return calc();
	long long res=0;
	reach[x][y]=((x>0?reach[x-1][y]:0)|(y>0?reach[x][y-1]:0));
	for(long long i=0;i<min(used+1,k);i++)
	{
		if(reach[x][y]>>i&1)
			continue;
		reach[x][y]|=(1<<i);
		col[x][y]=i;
		res+=dfs(x,y+1,max(used,i+1));
		if(res>=mod)
			res-=mod;
		reach[x][y]^=(1<<i);
	}
	return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin>>n>>m>>k;
    for(long long i=0;i<n;i++)
    {
    	for(long long j=0;j<m;j++)
    	{
    		cin>>buf[i][j];
    		buf[i][j]--;
		}
	}
	if(n+m-1>k)
	{
		cout<<"0"<<endl;
		return 0;
	}
	cout<<dfs(0,0,0)<<endl;
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 1000005
#define ll long long
#define mod 1000000007
int fac[N],inv[N],n,m,maxn,ans;
int q_pow(int x,int n){int ret=1;for(;n;n>>=1,x=(ll)x*x%mod)if(n&1)ret=(ll)ret*x%mod;return ret;}
int C(int n,int m){return (ll)fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	scanf("%d%d%*d%*d",&n,&m);maxn=max(n,m);fac[0]=1;
	for(int i=1;i<=maxn;i++)fac[i]=fac[i-1]*(ll)i%mod;inv[maxn]=q_pow(fac[maxn],mod-2);
	for(int i=maxn;i;i--)inv[i-1]=(ll)i*inv[i]%mod;
	for(int i=1;i<n;i++)if(i<=m)
	{
		int tmp=(ll)C(m-1,i-1)*fac[n-2]%mod*inv[n-i-1]%mod*q_pow(m,n-i-1)%mod;
		if(i!=n-1)tmp=(ll)tmp*(i+1)%mod*q_pow(n,n-i-2)%mod;(ans+=tmp)%=mod;
	}
	printf("%d\n",ans);
}


#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<algorithm>
#include<map>
#include <iomanip>
using namespace std;

// Codeforces 577A
int main() {
	long long n, x;
	cin >> n >> x;
	long long res = 0;
	long long timesN = n * n;

	if (x > timesN) {
		cout << 0 << endl;
		return 0;
	}

	if (x == 1) {
		cout << 1 << endl;
		return 0;
	}

	for (int i = 1; i < n + 1; i++) {
		if (x % i == 0) {
			if (x / i <= n) {
				res++;
			}
		}
	}

	cout << res << endl;

	return 0;
}


#include <stdio.h>

int main(){
	int n, m;

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

	int x;
	int y;

	if (n >= m){
		x = m;
		y = n;
	}

	else {
		x = n;
		y = m;
	}

	int count = 0;

	if (x == y){
		printf("1");
		return 0;
	}

	for (;;){
		count ++;
		x *= 3;
		y *= 2;

		if (x > y){
			printf("%d", count);
			return 0;
		}
	}
	return 0;
}


#include <iostream>
#include <vector>

typedef std::vector<std::vector<int> > vii;

vii combine(vii a, vii b) {
	for(int i = 0; i < a.size(); i++) {
		for(int j = 0; j < a[i].size(); j++) {
			a[i][j] += b[i][(j + a[i][j]) % a[i].size()];
		}
	}
	return a;
}

int fexp(vii x, int e) {
	vii ans = x;
	for(int i = 0; i < ans.size(); i++) {
		for(int j = 0; j < ans[i].size(); j++) {
			ans[i][j] = 0;
		}
	}
	for(; e > 0; e /= 2) {
		if(e & 1) {
			ans = combine(ans, x);
		}
		x = combine(x, x);
	}
	return ans[0][0];
}

int main() {
	int b, d;
	std::cin >> b >> d;
	std::string s1, s2;
	std::cin >> s1 >> s2;
	vii base(s1.size());
	for(int i = 0; i < s1.size(); i++) {
		for(int k = 0; k < s2.size(); k++) {
			base[i].push_back(0);
			for(int j = i; j < s1.size(); j++) {
				if(s1[j] == s2[(base[i][k] + k) % s2.size()]) {
					base[i][k]++;
				}
			}
		}
	}
	std::cout << fexp(base, b) / s2.size() / d << '\n';
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
#define mp make_pair
#define pll pair<ll, ll>
ll n2;
bool rem(pll &A){
    ll d1=(A.f+1)*(A.f+1)+(A.s)*A.s;
    ll d2=(A.f)*A.f+(A.s+1)*(A.s+1);
    if (d1>n2 or d2>n2)
        return true;
    return false;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    ll n;
    cin >> n;
    if (n==0){
        cout << "1\n";
        return 0;
    }
    n2=n*n;
    pll Point(0, n);
    pll Ret1(n, 0);
    ll contador=0;
    while (Point!=Ret1){
        if (rem(Point)){
            contador++;
        }
        ll d1=((Point.f+1)*(Point.f+1))+(Point.s*Point.s);
        if (d1<=n2)
            Point.f++;
        else
            Point.s--;
    }
    cout << contador*4 << "\n";
    return 0;
}


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

int n , m ;
int arr[101] = {};
int q[101] = {};
int c[101] = {};

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

    cin >> n >> m;

    for(int i = 0 ;i < n ; i++)
        cin >> arr[i];

    for(int i = 1 ; i <= m ; i++)
        cin >> q[i];

    for(int i = 0 ; i < n ; i++)
        c[arr[i]]++;

    for(int i = 0 ; i < n ; i++)
    {
        int c[m+1] = {};
        bool ok = 1;
        for(int j = i ;j < n ;j++)
        {
            c[arr[j]]++;
            bool ok = 1;

            for(int k = 1; k <= m ; k++)
            {
                if(c[k] != q[k])
                {
                    ok = 0;
                    break;
                }
            }

            if(ok)
                return cout << "YES" , 0;

        }

    }

    cout << "NO";

    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <cmath>
#include <cassert>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <iomanip>
#define mkp make_pair
#define pb push_back
#define IOS ios_base::sync_with_stdio(0),cin.tie(0)
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int maxn=2e5+5;
const int mod=1e9+7;
const int INF=2147483647;
long long F[maxn];
long long S[maxn];
int main(){
	IOS;
	int n,m;
	cin>>n>>m;
	F[0]=1, F[1]=2;
	for(int i=2;i<=100000;i++){
		F[i]=(F[i-1]+F[i-2])%mod;
	}
	S[1]=-1,S[2]=0,S[3]=F[0];
	for(int i=4;i<=100000;i++){
		S[i]=(S[i-1]+F[i-3])%mod;
	}
	cout<<((S[n]+S[m]+3)*2)%mod<<'\n';
	return 0;
}


#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
    long long k,n,s,p;cin>>k>>n>>s>>p;cout<<fixed<<(int)(ceil((double)(k*ceil((double)n/s))/p))<<endl;
    return 0;
}


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

int prime[1000],primeSize = 0;

void fill(int n){
	int root = (int)sqrt(n) + 1;
	for (int i = 2; i < root; ++i)
	{
		bool Isprime = true;
		for (int j = 0; j < primeSize; ++j)
		{
			if(i % prime[j] == 0){
				Isprime = false;
			}
		}
		if(Isprime == true && n % i == 0){
			prime[primeSize++] = i;
		}
	}
}

int smalld(int n){
	for (int i = 0; i < primeSize; ++i)
	{
		if(n % prime[i] == 0){
			return prime[i];
		}
	}
	return -1;
}

void devide(int n,int k){
	int dev[1000];
	int devS = 0;
	for (int i = 0; i < k - 1; ++i)
	{
		int num = smalld(n);
		if(num == -1 || num == n){
			cout<<-1;
			return;
		}else{
			dev[devS++] = num;
			n /= num;
		}
	}
	for (int i = 0; i < devS; ++i)
	{
		cout<<dev[i]<<" ";
	}
	cout<<n;
}

int main()
{
	//freopen("input.in","r",stdin);
	int n,k;
	cin>> n >>k;
	fill(n);
	devide(n,k);
	return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<vector>
#include <iterator>
#include <set>
#include <stack>

#define mx(ans, cnt) ans = max(ans, cnt)
#define fauto(a) for(auto i : a) cout << i << " "; cout << endl;
#define sp(n) fixed << setprecision(n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define _ << " " <<
#define swp(x, y) if (x > y) swap(x, y);
#define swpg(x, y) if (x < y) swap(x, y);
#define ff first
#define ss second
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define nn end1
#define intmax ((1ll << 32) - 1)

using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using ull = unsigned long long;

//while (l < r) {
//    int mid = (r + l + 1) / 2;      правый
//    if (a[mid] > x) r = mid - 1;
//    else l = mid;
//}
//while (l < r) {
//    int mid = (r + l) / 2;          левый
//    if (a[mid] >= x) r = mid;
//    else l = mid + 1;
//}

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

int main() {

    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //setlocale(LC_ALL, "Russian");

    int n, k, p;
    cin >> n >> k >> p;

    p *= n;

    ll ans = 0;
    while (n > 1) {
        int cnt = 1;
        while (cnt <= n) cnt *= 2;
        cnt /= 2;

        ans += cnt * k + cnt / 2;
        n -= cnt / 2;
    }

    cout << ans _ p << endl;

#ifdef LOCAL_DEBUG
    cerr << "Execution time: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
    return 0;
}
// *1* 2 4 8 6
// 1 3 9 7
// *1* 4 6

/*
 ╔═════════════════════════════════════════════════════════════════════════════════════════╗
 ║                                                                                ║
 ║  ║███████║  ║█████║    ║████║   ║██████║      ║████║ ║██║  ║██║ ║██║    ║██║   ║█████║  ║
 ║  ║██║     ║██║       ║██║  ║██║ ║██║  ║██║  ║██║║██║ ║██║║██║   ║██║    ║██║ ║██║       ║
 ║  ║████║  ║██║  ║███║ ║██║  ║██║ ║███║║██║  ║██║ ║██║ ║████║     ║██║    ║██║   ║████║   ║
 ║  ║██║    ║██║   ║██║ ║██║  ║██║ ║██║██║   ║█████████║║██║║██║    ║██║  ║██║        ║██║ ║
 ║  ║███████║ ║██████║    ║████    ║██  ║██║       ║██║ ║██║  ║██║    ║████║     ║█████║   ║
 ║                                                                                ║
 ╚═════════════════════════════════════════════════════════════════════════════════════════╝
 */

/*
 n!

    n!
 --------
 (n - k)!

      n!
 ------------
 k! * (n - k)!
 */


#include <iostream>
#include <stdio.h>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int, int> PII;
typedef pair<int, PII> PIP;
#define N 30

inline int value(char c) {
    return c - 'a' + 1;
}

string w[N];
map<string, int> score;
map<string, PIP> dp;

PIP DFS(const string &s) {
    if (dp.count(s) != 0) {
        return dp[s];
    }
    PIP &ret = dp[s];
    ret = PIP(-1, PII(0, 0));
    string t; PIP tmp;
    for (char c = 'a'; c <= 'z'; c++) {
        for (int d = 0; d < 2; d++) {
            t = d ? (c + s) : (s + c);
            map<string, int>::iterator it = score.find(t);
            if (it != score.end()) {
                tmp = DFS(t);
                tmp = PIP(tmp.first * -1, PII(- tmp.second.second + it->second, - tmp.second.first));
                ret = max(ret, tmp);
            }
        }
    }
    return ret;
}

int main () {
    int n;
    while (cin >> n) {
        score.clear();
        for (int i = 0; i < n; i++) {
            cin >> w[i];
        }
        score.clear();
        for (int i = 0; i < n; i++) {
            int len = w[i].length();
            for (int j = 0; j < len; j++) {
                for (int k = 1; j + k <= len; k++) {
                    score[ w[i].substr(j, k) ] |= (1 << i);
                }
            }
        }
        for (map<string, int>::iterator it = score.begin(); it != score.end(); it++) {
            int cb = 0;
            for (int i = 0; i < n; i++) {
                cb += ((it->second & (1 << i)) != 0);
            }
            int len = it->first.length();
            int sum = 0, maxvalue = 0;
            for (int i = 0; i < len; i++) {
                int v = value(it->first[i]);
                sum += v;
                maxvalue = max(maxvalue, v);
            }
            it->second = sum * maxvalue + cb;
        }
        dp.clear();
        PIP ans = DFS("");
        puts (ans.first == 1 ? "First" : "Second");
        printf ("%d %d\n", ans.second.first, -ans.second.second);
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main()

    {
        int n;
        cin>>n;
        if(n==2)
        cout<<2<<endl;
        else
        cout<<1<<endl;
    }


#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <algorithm>
#include <cmath>
#include <ctime>

using namespace std;
#define ll long long
#define MOD 1000000007
#define mp(a, b) make_pair(a, b)
#define PI 3.1415926535
#define EPS 0.00000001
#define pii pair<int, int>
#define INF 3000000

int main()
{
    int xp, yp, xv, yv;
    cin >> xp >> yp >> xv >> yv;
    if(xp <= xv && yp <= yv)
    {
        cout << "Polycarp";
        return 0;
    }
    if(xp >= xv && yp >= yv)
    {
        cout << "Vasiliy";
        return 0;
    }

    if(xp > xv)
    {
        if(yp <= yv - xp)
        {
            cout << "Polycarp";
        }
        else
            cout << "Vasiliy";
    }
    else
    {
        if(xp <= xv - yp)
        {
            cout << "Polycarp";
        }
        else
            cout << "Vasiliy";
    }
}


#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(){

    string cad,protocol,domain,context = "";
    int pos1,pos2;

    cin >> cad;

    if(cad[0] == 'f'){
        protocol = "ftp";
        pos1 = 3;
    }else{
        protocol = "http";
        pos1 = 4;
    }

    pos2 = cad.rfind("ru");
    //cout << cad.size() << endl;
    //cout << pos1 << "-" << pos2+2 << endl;
    domain = cad.substr(pos1,pos2-pos1);
    context = cad.substr(pos2+2);

    //cout << cad << endl;
    if(context != "") printf("%s://%s.ru/%s\n",protocol.c_str(),domain.c_str(),context.c_str());
    else printf("%s://%s.ru\n",protocol.c_str(),domain.c_str());

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	vector < int > a;
	vector < int > b;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int x,c=0,t=0;
	for(int i=0;i<n;i++){
		a.push_back(s[i]-'0');
	}
	int k=n;
	int j=n;
	for(int i=0;i<n;i++){
		while(j<2*n){
			b.push_back(s[j]-'0');
			j++;
		}
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	for(int i=0;i<n;i++){
		if(a[i]<b[i]){
			c++;
		}
		else if(a[i]>b[i]){
			t++;
		}
	}
	if(c==n || t==n){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}

}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
long double pi;
long double px[5],py[5];
int main(){
	int n,i;
	pi=acos((long double)-1);
//	std::cout.precision(12);
	std::cout<<std::fixed<<setprecision(12);
	scanf("%d",&n);
	printf("%d\n",n*5-(n-1));
	px[0]=py[0]=0;
	long double ten=20*cos(pi*36/180);
	long double t=10;
	px[1]=t*cos(pi*72/180);py[1]=-t*sin(pi*72/180);
	px[2]=ten*cos(pi*36/180);py[2]=-ten*sin(pi*36/180);
	px[3]=t*cos(pi*36/180);py[3]=t*sin(pi*36/180);
	for(i=0;i<n;i++){
		long double base=i*ten;
		for(int i=0;i<4;i++){
//			printf("%.12Lf %.12Lf\n",base+px[i],py[i]);
			std::cout<<base+px[i]<<" "<<py[i]<<std::endl;
			//fprintf(stderr,"(%.3Lg,%.3Lg),",base+px[i],base+py[i]);
		}
	}
//	printf("%.12Lf %.12Lf\n",(long double)n*ten,(long double)0);
	std::cout<<n*ten<<" "<<0<<std::endl;
	//fprintf(stderr,"(%.3Lg,%.3Lg)\n",(long double)n*ten,(long double)0);
	for(i=0;i<n;i++)
		printf("%d %d %d %d %d\n",i*4+1,i*4+2,i*4+3,i*4+5,i*4+4);
	for(i=0;i<n;i++)
		printf("%d %d %d %d ",i*4+1,i*4+3,i*4+4,i*4+2);
	for(i=n;i>0;i--)
		printf("%d ",i*4+1);
	printf("%d\n",1);
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long LL;

struct node {
    LL x, y;
};
node b, c;

bool Judge(LL x, LL y) {
    node a;
    a.x = x;
    a.y = y;
    if (c.x == 0 && c.y == 0) {
        if (a.x == b.x && a.y == b.y)
            return true;
        return false;
    }
    LL k, C;
    LL g, h;
    g = b.x - a.x;
    h = b.y - a.y;
    k = g * c.x + h * c.y;
    if (k % (c.x * c.x + c.y * c.y) == 0) {
        k /= (c.x * c.x + c.y * c.y);
        if (c.y != 0) {
            C = g - k * c.x;
            if (C % c.y == 0) {
                return true;
            }
            return false;
        } else {
            C = k * c.y - h;
            if (C % c.x == 0) {
                return true;
            }
            return false;
        }
        /*  C = g - k * c.x;
        if ((c.y == 0 && C == 0) || (c.y != 0 && C % c.y == 0)) {
             if (c.y != 0)
                 C = C / c.y;
             else C = 0;
             //cout << a.x << " " << a.y << endl;
             if (g == k * c.x + C * c.y && h == k * c.y - C * c.x)
                 return true;
             return false;
         }*/
    }
    return false;
}

int main() {
    node a;
    while (cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y) {
        if (Judge(a.x, a.y) == true) {
            puts("YES");
        } else if (Judge(-a.y, a.x) == true) {
            puts("YES");
        } else if (Judge(a.y, -a.x) == true) {
            puts("YES");
        } else if (Judge(-a.x, -a.y) == true) {
            puts("YES");
        } else {
            puts("NO");
        }
    }
    return 0;
}
/*
-2 2
3 3
5 0

 */


#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
#include<numeric>
#include<list>
#define PI acos(-1.0)
using namespace std;
int main()
{
	long long n;
	cin >> n;
	if (n % 4 == 1 || n % 4 == 2)
		cout << 1;
	else
		cout << 0;
	return 0;
}


#include <cstdio>
#include <queue>

std::queue<int>q[3];
int t,n,a[200001],head[200001],nxt[400001],b[400001],k,d[200001];
bool vis[200001];
void push(int s,int t){
	nxt[++k]=head[s];
	head[s]=k;
	b[k]=t;
}
int main(){
	scanf("%d",&t);
	for(int fd=1;fd<=t;fd++){
		scanf("%d",&n);
		for(int i=1;i<=n;i++)scanf("%d",a+i),head[i]=0,a[i]=(a[i]==0)?2:(a[i]-1);
		k=0;
		for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),push(u,v),push(v,u);
		int fin=0x7f7f7f7f;
		for(int fd=0;fd<2;fd++){
			for(int i=1;i<=n;i++)vis[i]=d[i]=0;
			for(int i=1;i<=n;i++)
				for(int j=head[i];j;j=nxt[j])
					++d[i];
			for(int i=1;i<=n;i++)if(d[i]<=1)q[a[i]].push(i);
			int ans=0;
			for(int now=fd;!q[0].empty()||!q[1].empty()||!q[2].empty();now^=1){
				++ans;
				for(;;){
					int p=-1;
					if(!q[now].empty())p=q[now].front(),q[now].pop();
					else if(!q[2].empty())p=q[2].front(),q[2].pop();
					else break;
					if(vis[p])continue;
					vis[p]=1;
					for(int i=head[p];i;i=nxt[i])
						if(!vis[b[i]])
							if((--d[b[i]])<=1)q[a[b[i]]].push(b[i]);
				}
			}
			if(fin>ans)fin=ans;
		}
		printf("%d\n",fin);
	}
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const int MAXN=2e5+10,MAXM=1e7+10;
const int INF=INT_MAX,SINF=0x3f3f3f3f;
const ll llINF=LLONG_MAX;
const int MOD=1e9+7,mod=998244353;
#define lowbit(x) x&-x
const int inv2=5e8+4;

ll h1,h2,a,b;

int main()
{
    scanf("%lld%lld%lld%lld",&h1,&h2,&a,&b);
    h2-=h1;
    int now=14,d=0;
    while(h2>0)
    {
        if(now>=10&&now<22)h2-=a;
        else h2+=b;
        now++;
        if(now>=24)
        {
            now-=24;
            d++;
        }
        if(d>1e6)return puts("-1"),0;
    }
    cout<<d;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	string s;
	cin>>s;
	int n;
	cin>>n;
	bool x=0,y=0;
	while(n--)
	{
		string t;
		cin>>t;
		if(t==s)
			return cout<<"YES",0;

		if(t[0]==s[1])
			x=1;
		if(t[1]==s[0])
			y=1;
	}
	cout<<(x && y ?"YES":"NO");
}


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

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    //sort(a+1,a+n-1);
    cout << a[n-1] << " ";
    for(int i=1;i<n-1;i++)
        cout << a[i] << " ";
    cout << a[0];
}


#include<bits/stdc++.h>
using namespace std;
int n,k,a[100000],sum=1,s,ans;
//a[100000]是素数表，sum是n之前素数数量，ans是“好素数”数量
void prime(){
    bool t;
    a[0]=2;
    for(int i=3;i<=n;i+=2){
    //优化(i+=2)，因为素数除 2 外都是单数。
        t=1;
        for(int j=2;j<i;j++){
            if(i%j==0){
                t=0;
                break;
            }
        }
        if(t){
            a[sum]=i;
            sum++;
        }
    }
}//打表部分
int main(){
    cin >> n >> k;
    prime();
    for(int i=0;i<sum;i++){
        for(int j=0;j<i;j++){
//只要号数小于i，那么都是小于a[i]的素数
            s=(a[i]-1)-a[j];
//如果a[j]就是其中的一个素数，那么s就是与其相邻的一个素数。
            if(s==a[j-1]||s==a[j+1]){
//相邻的素数分别有比它大一号和小一号的
                ans++;
                break;
            }
        }
    }
    if(ans>=k) cout << "YES";
    else cout << "NO";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define loop(i,k,n) for (ll i = k ; i < n ; ++i)
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl

void Suhaib_Sawalha (){

    int a , b , g , l;
    cin >> a >> b >> g >> l;
    if (l % g){
        cout << 0;
        return;
    }
    l /= g;
    int sq = sqrt(l) , ans = 0;
    for (int i = 1 ; i <= sq ; ++i){
        if (l % i == 0){
            int c = l/i;
            if (__gcd(i,c) == 1 && i * g >= a && i * g <= b && c * g >= a && c * g <= b)
                ans += 1 + (i != c);
        }
    }
    cout << ans;
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<endl)
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


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

#define ll long long
#define sz(c) (int)c.size()

int main() {
	int n;
	cin >> n;
	cout << n * 3 / 2 << endl;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char y;
    cin.get(y);
    string s;
    getline(cin,s);
    vector <int> v;
    string s1 = "";
    for(int i=0; i<s.length(); i++){
        if(s[i] == ' '){
            stringstream str;
            str << s1;
            int x;
            str >> x;
            v.push_back(x);
            s1 = "";
        }
        else{
            s1 = s1 + s[i];
        }
    }
    stringstream ss;
    ss << s1;
    int x;
    ss >> x;
    v.push_back(x);

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

    int k = v[0];
    while(true){
        if((n*k - e) > e){
            break;
        }
        k++;
    }
    cout<<k;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long dist[200005];

bool visit[200005];

bool present[200005];

void getDist(vector<long> G[],long src) {

    queue<long> Q;

    memset(visit,false,sizeof visit);

    memset(present,false,sizeof present);

    memset(dist,-1,sizeof dist);

    Q.push(src);

    dist[src]=0;

    present[src]=1;

    while(!Q.empty()) {

        long cur = Q.front();

        Q.pop();

        present[cur]=false;

        visit[cur]=true;

        for(long x:G[cur]) {

            if(!visit[x]) {

                if(dist[x]==-1)

                    dist[x]=dist[cur]+1;

                else

                    dist[x]=min(dist[x],dist[cur]+1);

                if(!present[x]) {

                    Q.push(x);

                    present[x]=true;

                }

            }

        }

    }

    return ;

}

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    long n;

    cin >> n;

    long m;

    cin >> m;

    vector<long> G1[200005],G2[200005];

    for(long i = 0 ; i < m ; i++) {

        long u;

        cin >> u;

        long v;

        cin >> v;

        G1[u].push_back(v);

        G2[v].push_back(u);

    }

    long k;

    cin >> k;

    vector<long> p(k);

    for(long i = 0 ; i < k ; i++) {

        cin >> p[i];

    }

    getDist(G2,p.back());

    long res_min =0;

    long res_max=0;

    for(long i=1; i<k; i++) {

        if(dist[p[i-1]]==dist[p[i]]+1) {

            long cnt=0;

            for(long x:G1[p[i-1]]) {

                if(dist[x]==dist[p[i]]) {

                    cnt++;

                }

            }

            if(cnt>1) {

                res_max++;

            }

        } else {

            res_min++;

            res_max++;

        }

    }

    cout << res_min << ' ' << res_max << '\n';

    return 0;

}


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

#define FOR(i, a, b) for(int i=a; i<=b; i++)
#define DOW(i, a, b) for(int i=a; i>=b; i--)
#define S(a)  scanf("%d",&a)
#define LS(a) scanf("%lld",&a)
#define DS(a) scanf("%lf",&a)
#define PC(a) printf("Case %d: ",a)
#define P(a) printf("%d\n",a)
#define LP(a)  printf("%lld",a)
#define DP(a) printf("%.04lf",a)
#define pb push_back
#define mp make_pair
#define fi   first
#define se     second
#define fast std::ios::sync_with_stdio(false)
#define init freopen("input.txt","r",stdin)
#define outit freopen("output.txt","w",stdout)
#define INF 0xfffffff
#define gc getchar

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii>  vii;
typedef vector<vector<int>> vvi;
typedef vector<vector<ii>> vvii;

void scanint( int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for(; ((c<48 || c>57) && c != '-'); c = gc());
    if(c=='-')
    {
        neg=1;
        c=gc();
    }
    for(; c>47 && c<58; c = gc())
    {
        x = (x<<1) + (x<<3) + c - 48;
    }
    if(neg) x=-x;
}
 ll x[3],y[3];
bool checkx(int i,int j,int k){
  if(x[i]==x[j] && ((y[k]>y[i] && y[k]>y[j])  ||(y[k]<y[i] && y[k]<y[j])  || y[k]==y[j] ||  y[k]==y[i] ))
    return true;
  return false;

}
bool checky(int i,int j,int k){
  if(y[i]==y[j] && (x[k]==x[i] || x[k]==x[j]||(x[k]>x[i] && x[k]>x[j]) || (x[k]<x[i] && x[k]<x[j])))
    return true;
  return false;

}

int main()
{

   fast;
    int t;
    // S(t);
    //for(int tc=1; tc<=t; tc++)
    {

        for(int i=0;i<3;i++)
        cin>>x[i]>>y[i];

        if((x[0]==x[1] && x[1]==x[2]) ||(y[0]==y[1] && y[1]==y[2])){
          cout<<"1\n";
          return 0;
        }
        // bool  ans=false;
         if(checkx(0,1,2) || checkx(1,2,0) || checkx(2,0,1) || checky(0,1,2) || checky(1,2,0) || checky(2,0,1) )
         {
            cout<<"2\n";
            return 0;

         }
        cout<<"3\n";
    }

    return 0;

}


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

#define pb push_back
#define ppp pop_back
#define pii pair<int, int>
#define fi first
#define se second

const int N = 1005;
const ll p = 1e9 + 7;

pair<ll, bool> dp[2*N][2*N];

ll add(ll a, ll b) {
	if (a + b >= p) return a + b - p;
	else return a + b;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	dp[0][0] = {0, 1};
	for (int i=1; i<=2*n; i++) {
		for (int j=0; j<=i; j++) {
			ll cur = 0;
			bool used = 0;
			if (j) {
				cur = dp[i-1][j-1].fi;
				used = dp[i-1][j-1].se;
			}
			if (j+1 <= i-1) {
				cur = add(cur, dp[i-1][j+1].fi);
				used |= dp[i-1][j+1].se;
			}
			if (used) dp[i][j] = {add(cur, 1), 0};
			else dp[i][j] = {cur, 1};
		}
	}
	cout << dp[2*n][0].fi << "\n";
    return 0;
}


#include <stdio.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <set>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <assert.h>
#include <cmath>
using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i, n) for(int i=0;i<n;i++)
#define pb(x) push_back(x)
#define all(x) (x).begin(), (x).end()
#define szz(x) (int)(x).size()
#define Fi first
#define Se second

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f;
const ll MOD = 1000000007;
const int IT_MAX = 1 << 17;

const double EPS = 1e-9;
const double PI = acos(-1);

const int MX = 100005;

pdd operator+(pdd l, pdd r){ return pdd(l.first + r.first, l.second + r.second);  }
pdd operator-(pdd l, pdd r){ return pdd(l.first - r.first, l.second - r.second);  }
double operator*(pdd a, pdd b) { return a.Fi * b.Fi + a.Se * b.Se; }
pdd operator*(pdd l, double r){ return pdd(l.first * r, l.second * r);  }
double operator/(pdd l, pdd r){ return l.first*r.second - l.second*r.first;  }
pdd r90(pdd c){ return pdd(-c.second, c.first); }
double size(pdd c){ return hypot(c.first, c.second); }
double sq(double x){ return x*x;}
double size2(pdd c){ return sq(c.first) + sq(c.second); }
pdd unit(double a){ return pdd(cos(a), sin(a)); }
pdd rotate(pdd v, double a){ return unit(a) * v.first + unit(a + PI/2) * v.second; }

int intersect(pdd a, pdd b, pdd u, pdd v, pdd &des){
    if(abs(u/v) < EPS) return 0;
    des = pdd(((a-u)/v)/(v/b), ((a-u)/b)/(v/b));
    return 1;
}

struct circle{
    circle(pdd O, double r):O(O), r(r){}
    circle(){}
    pdd O;
    double r;
};

int get_circle(pdd p0, pdd p1, pdd p2, circle &des){
    pdd a = (p0+p1) * 0.5, b = r90(p0-p1);
    pdd u = (p0+p2) * 0.5, v = r90(p0-p2), R;
    if( !intersect(a, b, u, v, R) ) return 0;
    des = circle(a+b*R.first, size(a+b*R.first - p0));
    return 1;
}

struct node{
    node(int a, int b, int c, circle X):a(a), b(b), c(c), X(X){}
    int a, b, c;
    circle X;
};

node make_circle(vector<int> Q, pdd D[MX]){
    if( Q.size() == 0 ) return node(-1, -1, -1, circle(pdd(0, 0), 0));
    if( Q.size() == 1 ) return node(Q[0], -1, -1, circle(D[Q[0]], 0));
    circle res;
    for(int i = 0; i < Q.size(); i++){
        swap(Q.back(), Q[i]);
        res = circle((D[Q[0]]+D[Q[1]]) * 0.5, size(D[Q[0]]-D[Q[1]])/2);
        bool ch = 1;
        for(int c : Q){
            if( size2(D[c]-res.O) > sq(res.r) + 1e-6) ch = 0;
        }
        if( ch ) return node(Q[0], Q[1], -1, res);
        swap(Q.back(), Q[i]);
    }
    get_circle(D[Q[0]], D[Q[1]], D[Q[2]], res);
    return node(Q[0], Q[1], Q[2], res);
}

node smallest_circle(vector<int> &P, vector<int> &Q, int N, pdd D[MX])
{
    node c = make_circle(Q, D);
    if( N == 0 || Q.size() >= 3 ) return c;
    for(int i = 0; i < N; i++){
        if( size2(c.X.O - D[P[i]]) > sq(c.X.r) ){
            Q.push_back(P[i]);
            c = smallest_circle(P, Q, i, D);
            Q.pop_back();
        }
    }
    return c;
}

int counter = 0;
void get_enc(vector<int> L, vector<int> X, vector<node> &ans, pdd D[MX], double prob = 1){
    if(prob < 1e-4) return;
    counter++;
    vector<int> P, Q;
    random_shuffle(L.begin(), L.end());
    for(int c : X) P.push_back(c);
    for(int c : L) P.push_back(c);
    node x = smallest_circle(P, Q, L.size(), D);
    ans.push_back(x);
    vector<int> t1;
    auto is_in = [](vector<int> &X, int x){
        for(int c : X) if(c == x) return true;
        return false;
    };
    if(!is_in(X, x.a)) t1.push_back(x.a);
    if(!is_in(X, x.b)) t1.push_back(x.b);
    if(!is_in(X, x.c)) t1.push_back(x.c);

    for(int c : t1){
        for(int j = 0; j < L.size(); j++) if(L[j] == c) L.erase(L.begin()+j);
        get_enc(L, X, ans, D, prob / 3);
        prob = prob * 2 / 3;
        X.push_back(c);
    }
}

pdd D1[MX], D2[MX];
int N, N1, N2;
map <pii, int> Mx;

void check(pdd O1, pdd O2, double a)
{
    auto move = [&](pdd c){
        return rotate(c - O1, a) + O2;
    };
    counter++;
    int corr = 0;
    vector <pii> ansv;
    for(int i=1;i<=N1;i++) {
        pdd ex = move(D1[i]);

        int tx = (int)(ex.first * 100 + 0.5);
        int ty = (int)(ex.second * 100 + 0.5);
        int f = 0;
        for(int dx=-1;dx<=1;dx++) for(int dy=-1;dy<=1;dy++) if(f == 0) {
            if(Mx.find(pii(tx + dx, ty + dy)) != Mx.end()) {
                int idx = Mx[pii(tx + dx, ty + dy)];
                ansv.emplace_back(i, idx);
                f = 1;
            }
        }
        corr += f;
        if(i > 100 && ((double)corr / i) * N1 < N * 0.5) break;
    }
    if(szz(ansv) > 0.91 * N) {
        int chkA[MX] = {}, chkB[MX] = {};
        for(pii e : ansv) chkA[e.Fi] = chkB[e.Se] = 1;
        int ia = 1, ib = 1;
        while(szz(ansv) < N) {
            while(chkA[ia] == 1) ++ia;
            while(chkB[ib] == 1) ++ib;
            ansv.pb(pii(ia, ib));
            ++ia; ++ib;
        }
        for(pii e : ansv) printf("%d %d\n", e.Fi, e.Se);
        exit(0);
    }
}

int main()
{
//    freopen("A.out","r",stdin);
    scanf("%d", &N);
    scanf("%d", &N1);
//    printf("%d %d\n", N, N1);
    for(int i = 1; i <= N1; i++) scanf("%lf%lf", &D1[i].first, &D1[i].second);
    scanf("%d", &N2);
    for(int i = 1; i <= N2; i++) scanf("%lf%lf", &D2[i].first, &D2[i].second);
    for(int i=1;i<=N2;i++) {
        int tx = (int)(D2[i].first * 100 + 0.5);
        int ty = (int)(D2[i].second * 100 + 0.5);
        Mx[pii(tx, ty)] = i;
    }

    vector<int> t1, t2;
    vector<node> A1, A2;
    for(int i = 1; i <= N1; i++) t1.push_back(i);
    get_enc(t1, t2, A1, D1);

    t1.clear();
    for(int i = 1; i <= N2; i++) t1.push_back(i);
    get_enc(t1, t2, A2, D2);
 //   printf("%d\n", counter); counter = 0;

    for(node a1 : A1){
        for(node a2 : A2){
            if(fabs(a1.X.r - a2.X.r) > 0.1 ) continue;
            pdd P1[] = {D1[a1.a], D1[a1.b], D1[a1.c]};
            pdd P2[] = {D2[a2.a], D2[a2.b], D2[a2.c]};

            for(pdd &c : P1) c = c - a1.X.O;
            for(pdd &c : P2) c = c - a2.X.O;

            int O[3] = {0, 1, 2};
            do{
                int ch = 1;
                double t = atan2(P1[0] / P2[O[0]], P1[0] * P2[O[0]]);
                for(int i = 1; i < 3; i++){
                    double u = atan2(P1[i] / P2[O[i]], P1[i] * P2[O[i]]);
                    if(fabs(t-u) < EPS) ch = 0;
                }
                check(a1.X.O, a2.X.O, t);
            }while(next_permutation(O, O+3));
        }
    }
  //  printf("%d\n", counter); counter = 0;
}


#include <bits/stdc++.h>
 using namespace  std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const double pi=3.1415926535897932384626433832;
const long long mod=1e9+7;
//long long primeset[5000000]={};
typedef complex<double> cd;
typedef long long ll;
typedef double ld;
//#define For(i,0,n) for(long long i = 0 ; i<n ;i++)
cd fast_exp(cd a, long long b)
{
	if (b == 0)
		return 1;

	cd res = fast_exp(a, b / 2);

	res = res * res;

	if (b % 2 == 1)
		res = res * a;

	return res;
}

long long fastexpon(long long a,long long b,long long mod)
{
	if(b==0)
		return 1;

	long long res=fastexpon(a,b/2,mod);

	res=(res*res)%mod;
	if(b%2==1)
		res= (res * a)%mod;

	return res;
}

//template ends here

int main()
 {

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

	ll q;
	cin>>q;
	while(q--)
	{
		ll a,b,m;
		cin>>a>>b>>m;

		ll pow[50];
		pow[0]=1;
		pow[1]=1;
		for(ll i=2 ;i<=50 ;i++)
		{
			pow[i]=2*pow[i-1];
		}

		ll check=0;
		if(a == b)
		{
			cout<<1<<' '<<a<<'\n';
			continue;
		}
		for(ll k=2 ; k<=50; k++)
		{
			ll l = pow[k-1]*(a+1);
			ll r = pow[k-1]*(a+m);

			if(l<= b && r>=b)
			{
				ll curb=b;
				check = 1;
				ll mchoice[k-1]={};
				b=b-l;

				for(ll j = k-1 ; j>0 ;j--)
				{
					//cout<<"b  = "<<b<<"pow [j] = "<<pow[j-1]<<'\n';

					if(b>=pow[j-1])
					{
						mchoice[k-1-j]= min(b/pow[j-1],m-1);

					}
					else
					mchoice[k-1-j]=0;

					//cout<<" mc "<<k-1-j<<"  = "<<mchoice[k-1-j]<<'\n';
					b=b-mchoice[k-1-j]*pow[j-1];

					 if(b==0)
					 	break;
				}

				if(log(a+1)+log(pow[k-1]) > log(curb)+ 1e-5 )
				{
					check=0;
					break;
				}

				cout<<k<<' '<<a<<' ';
				ll cum=a;

				for(ll i=0 ; i<k-1 ;i++)
				{
					  //cum = cum+mchoice[i]+1;
					  cout<<cum+1+mchoice[i]<<' ';
					  cum = cum+cum+1+mchoice[i];
					//cout<<mchoice[i]<<' ';
				}
				cout<<'\n';
				break;
				//return 0;
			}
		}

		if(check == 0)
			cout<<-1<<'\n';

	}
	//cout<<'\n'<<"time elapsed: "<<clock()*1000.0 / CLOCKS_PER_SEC<<" ms"<<'\n';
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<set>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn = 2500;
const int inf = 0x3f3f3f3f;
int main()
{
    ll a,b;
    ll vac = 1;
    scanf("%lld%lld",&a,&b);
    for(ll i=a+1;i<=b;i++)
    {
        vac = ((vac%10) * (i%10))%10;
        if(vac == 0)
            break;
    }
    printf("%lld\n",vac);
    return 0;
}


#include <iostream>
#include <utility>
#include <algorithm>
#include <memory.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <list>
#include <stack>
#include <cmath>
#include <stdlib.h>
#include <unistd.h>
using namespace std;

typedef  long long LL;
const int Mod = 1e9 + 9;
inline int FIX(LL a) {return (a % Mod + Mod) % Mod;}
#define MP(x,y) make_pair(x,y)
#define LEN(x) ((int)x.length())
#define take(x,y) (((x)>>(y)) & 1ll)
//#define move(n) (1<<(n))
#define what_is(x) cerr << #x << " is " << x << endl;
#define eb emplace_back
#define UNQ(x) (sort(begin(x),end(x)),x.erase(unique(begin(x),end(x)),end(x)))

int n,m,k;
LL cal(LL cnt) {
    //cal 2^cnt
    if(cnt == 1) return 2;
    LL cur = cal(cnt/2);
    cur = cur * cur % Mod;
    if(cnt % 2 == 1) cur = cur * 2 % Mod;
    return cur;
}
int main(){
    scanf("%d %d %d",&n,&m,&k);
    int x1 = m/(k-1),x2 = n - m;
    if(x1 <= x2) {
        cout<<m<<endl;
    }else {
        LL ret = x2 * (k - 1);
        LL d = m - (k - 1) * x2;
        if(d < k) {
            ret = (ret + d) % Mod;
            cout<<ret<<endl;
            return 0;
        }
        LL tmp = 0;
        tmp += FIX(cal(d/k)-1);
        tmp *= 2;
        tmp %= Mod;
        tmp *= k;
        tmp %= Mod;
        tmp += d % k;
        tmp %= Mod;
        (ret += tmp)%=Mod;
        cout<<ret<<endl;
    }
    return 0;
}


/*
 *
 * In The Name Of god
 *
 *
 *
 *
 *
*/

#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <iomanip>
#include <utility>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <memory>
#pragma comment(linker, "/stack:256000000")

using namespace std;

int main () {
        ios_base::sync_with_stdio(false);
        int n, sum = 0;
        cin >> n;
        for (int i=0; i<n; i++) {
                int a;
                cin >> a;
                sum += a;
        }
        int ans = 0;
        for (int i=1; i<=5; i++)
                if ((sum + i) % (n+1) != 1)
                        ans ++ ;
        cout << ans << endl;
        return 0;
}


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

#define print(x) cerr << #x << " is " << x << endl;
#define int long long int
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpi vector<pair<int, int>>
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pb push_back
#define PI 3.1415926535897932384626
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define out cout << fixed << setprecision(12) <<

const int N = 2e5 + 10;
const int mod = 1e9 + 7;
const double lifeofpi = acos(-1);

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

    int a, b, f, k;
    cin >> a >> b >> f >> k;

    int ans = 0, fuel = b;
    int x = 0;
    while(k--){
        int y = a - x;
        if(abs(x - f) > fuel){
            ans = -1;
            break;
        }
        fuel -= (abs(x - f));

        if(abs(y - f) > b){
            ans = -1;
            break;
        }
        if(abs(y - f) > fuel || (k && 2 * abs(y - f) > fuel)) {
            ans++;
            fuel = b;
        }

        fuel -= abs(y - f);
        x = y;
    }

    cout << ans << '\n';
    return 0;
}


#include <bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define lson rt << 1
#define rson rt << 1 | 1
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std;

struct Scanner {
    FILE* fp = nullptr;
    char line[(1 << 15) + 1];
    size_t st = 0, ed = 0;
    void reread() {
        memmove(line, line + st, ed - st);
        ed -= st;
        st = 0;
        ed += fread(line + ed, 1, (1 << 15) - ed, fp);
        line[ed] = '\0';
    }
    bool succ() {
        while (true) {
            if (st == ed) {
                reread();
                if (st == ed) return false;
            }
            while (st != ed && isspace(line[st])) st++;
            if (st != ed) break;
        }
        if (ed - st <= 50) reread();
        return true;
    }
    template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
    bool read_single(T& ref) {
        if (!succ()) return false;
        while (true) {
            size_t sz = 0;
            while (st + sz < ed && !isspace(line[st + sz])) sz++;
            ref.append(line + st, sz);
            st += sz;
            if (!sz || st != ed) break;
            reread();
        }
        return true;
    }
    template <class T, enable_if_t<is_integral<T>::value, int> = 0>
    bool read_single(T& ref) {
        if (!succ()) return false;
        bool neg = false;
        if (line[st] == '-') {
            neg = true;
            st++;
        }
        ref = T(0);
        while (isdigit(line[st])) {
            ref = 10 * ref + (line[st++] - '0');
        }
        if (neg) ref = -ref;
        return true;
    }
    template <class T> bool read_single(vector<T>& ref) {
        for (auto& d : ref) {
            if (!read_single(d)) return false;
        }
        return true;
    }
    void read() {}
    template <class H, class... T> void read(H& h, T&... t) {
        bool f = read_single(h);
        assert(f);
        read(t...);
    }
    Scanner(FILE* _fp) : fp(_fp) {}
};

struct Printer {
  public:
    template <bool F = false> void write() {}
    template <bool F = false, class H, class... T>
    void write(const H& h, const T&... t) {
        if (F) write_single(' ');
        write_single(h);
        write<true>(t...);
    }
    template <class... T> void writeln(const T&... t) {
        write(t...);
        write_single('\n');
    }

    Printer(FILE* _fp) : fp(_fp) {}
    ~Printer() { flush(); }

  private:
    static constexpr size_t SIZE = 1 << 15;
    FILE* fp;
    char line[SIZE], small[50];
    size_t pos = 0;
    void flush() {
        fwrite(line, 1, pos, fp);
        pos = 0;
    }
    void write_single(const char& val) {
        if (pos == SIZE) flush();
        line[pos++] = val;
    }
    template <class T, enable_if_t<is_integral<T>::value, int> = 0>
    void write_single(T val) {
        if (pos > (1 << 15) - 50) flush();
        if (val == 0) {
            write_single('0');
            return;
        }
        if (val < 0) {
            write_single('-');
            val = -val;  // todo min
        }
        size_t len = 0;
        while (val) {
            small[len++] = char('0' + (val % 10));
            val /= 10;
        }
        for (size_t i = 0; i < len; i++) {
            line[pos + i] = small[len - 1 - i];
        }
        pos += len;
    }
    void write_single(const string& s) {
        for (char c : s) write_single(c);
    }
    void write_single(const char* s) {
        size_t len = strlen(s);
        for (size_t i = 0; i < len; i++) write_single(s[i]);
    }
    template <class T> void write_single(const vector<T>& val) {
        auto n = val.size();
        for (size_t i = 0; i < n; i++) {
            if (i) write_single(' ');
            write_single(val[i]);
        }
    }
};

Scanner sc(stdin);
Printer pr(stdout);

const int mol = 1e9 + 7;

int f[18];
bool a[66];
int sum[10];
inline void add(int &a,int b) { a += b; if (a >= mol) a -= mol; }

int main(){
	int t; sc.read(t);
	int p = 1;
	while (t--) {
		ll n; sc.read(n);
		if (n == 1) { pr.writeln(p); continue; }
		int s = 0;
		for (register int i = 0; i <= 60; ++i) {
			if ((1ll << i) > n) break;
			if (n & (1ll << i)) { a[i] = 1; s = i; } else a[i] = 0;
		}
		for (register int i = 0; i <= 6; ++i) sum[i] = 1;
		for (register int i = s - 1; i >= 0; --i) {
			int op = a[i + 1]; int x = a[i + 1];
			for (int j = 0; j <= 6; ++j) {
				int k = a[i] + (j << 1);
				int st = j + x;
				x ^= 1;
				int l = (st - a[i + 1]) >> 1;
				int r = (j + 7 - a[i + 1]) >> 1;
				if (!l) f[k] = sum[r];
				else {
					f[k] = sum[r] - sum[l - 1];
					if (f[k] < 0) f[k] += mol;
				}
			}
			sum[0] = f[a[i]];
			for (register int j = 1; j <= 6; ++j) {
				sum[j] = sum[j - 1] + f[a[i] + (j << 1)];
				if (sum[j] >= mol) sum[j] -= mol;
			}
		}
		int ans = 0;
		for (register int i = 0; i <= 3; ++i) add(ans , f[a[0] + (i << 1)]);
		pr.writeln(ans);
	}

}


#include <stdio.h>

int main() {

    int h1, m1, h2, m2;
    int hRes, mRes;
    int horaMenos = 0;

    scanf("%d:%d", &h1, &m1);

    scanf("%d:%d", &h2, &m2);

    mRes = m1-m2;

    if(mRes < 0){
        mRes = 60 + mRes;
        horaMenos++;
    }

    hRes = h1-h2-horaMenos;

    if(hRes < 0){
        hRes = 24+hRes;
    }

    if (hRes < 10 && mRes < 10) {
        printf("0%d:0%d\n", hRes, mRes);
    }

    else if (hRes >= 10 && mRes < 10) {
        printf("%d:0%d\n", hRes, mRes);
    }

    else if (hRes < 10 && mRes >= 10) {
        printf("0%d:%d\n", hRes, mRes);
    }

    else{
        printf("%d:%d\n", hRes, mRes);
    }

    return 0;
}

// 1475086813462


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

namespace geometry {

    using type = long double;
    const type EPS = 1e-9;
    const type PI = cosl(-1.0);
    const type INF = 1e9;

    struct Point {
        type x;
        type y;

        Point(type x_ = 0.0, type y_ = 0.0): x(x_), y(y_) {}

        Point operator + (const Point o) const {
            return Point(this->x + o.x, this->y + o.y);
        }

        Point* operator += (const Point o) {
            this->x += o.x;
            this->y += o.y;
            return this;
        }

        Point operator - (const Point o) const {
            return Point(this->x - o.x, this->y - o.y);
        }

        Point* operator -= (const Point o) {
            this->x -= o.x;
            this->y -= o.y;
            return this;
        }

        Point operator * (const type c) const {
            return Point(this->x * c, this->y * c);
        }

        Point* operator *= (const type c) {
            this->x *= c;
            this->y *= c;
            return this;
        }

        Point operator / (const type c) const {
            return Point(this->x / c, this->y / c);
        }

        Point* operator /= (const type c) {
            this->x /= c;
            this->y /= c;
            return this;
        }

        Point rot(const type rad) const {
            return Point(this->x * cosl(rad) - this->y * sinl(rad), this->x * sinl(rad) + this->y * cosl(rad));
        }

        type rot_diff(const Point o) const {
            type rot1 = atan2(this->y, this->x);
            type rot2 = atan2(o.y, o.x);
            type res = rot2 - rot1;
            return res;
        }

    };

    type dot(Point a, Point b) {
        return (a.x * b.x) + (a.y * b.y);
    }

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

    int sign(type o) {
        if (o > 0) return +1;
        if (o < 0) return -1;
        return 0;
    }

    bool in_triangle(Point A, Point B, Point C, Point P) {
        /*  If P is in triangle ABC, then its orientation must be the same for
            all permutations of the cross products between P and triangle vertices.
        */

        if (sign(cross(A - C, B - C)) != sign(cross(P - C, B - C))) return false;
        if (sign(cross(B - A, C - A)) != sign(cross(P - A, C - A))) return false;
        if (sign(cross(C - B, A - B)) != sign(cross(P - B, A - B))) return false;

        if (sign(cross(B - C, A - C)) != sign(cross(P - C, A - C))) return false;
        if (sign(cross(C - A, B - A)) != sign(cross(P - A, B - A))) return false;
        if (sign(cross(A - B, C - B)) != sign(cross(P - B, C - B))) return false;

        return true;
    }

    using Shape = vector<Point>;

    type get_area(Shape s) {
        type res = 0.0;
        int sz = s.size();
        for (int i = 0; i < sz; i++) {
            res += s[i].x * s[(i + 1) % sz].y;
            res -= s[i].y * s[(i + 1) % sz].x;
        }

        res /= 2.0;
        return res;
    }

    void print_shape(Shape s) {
        int sz = s.size();
        Shape tmp;
        tmp.emplace_back(s[0]);
        for (int i = 1; i < sz; i++) if (hypotl(s[i].x - s[i - 1].x, s[i].y - s[i - 1].y) > EPS) tmp.emplace_back(s[i]);

        s = tmp;
        sz = s.size();
        cout << sz << " ";
        for (int i = 0; i < sz; i++) cout << s[i].x << " " << s[i].y << " ";
        cout << "\n";
    }

    Shape read_shape() {
        Shape res;
        Point in;
        int n; cin >> n; while (n--) {
            cin >> in.x >> in.y;
            res.emplace_back(in);
        }
        return res;
    }

}

using namespace geometry;

struct Operation {
    Shape start_shape;
    vector<Shape> cut_shapes;

    vector<Shape> tape_shapes;
    Shape final_shape;

    Operation() {}
};

class Scissors_and_Tape {

private:

    Shape Start, Target;
    type Area;

    vector<Operation> reverse_operations(vector<Operation> op) {
        reverse(op.begin(), op.end());
        for (auto &i : op) swap(i.start_shape, i.final_shape);
        for (auto &i : op) swap(i.cut_shapes, i.tape_shapes);
        return op;
    }

    void rotate_left(Point &a, Point &b, Point &c) {
        Point tmp = a; a = b; b = c; c = tmp;
    }

    void rotate_right(Point &a, Point &b, Point &c) {
        Point tmp = c; c = b; b = a; a = tmp;
    }

    struct ListOfRectangles {

        vector<type> H, W;

        ListOfRectangles() {}

        int size() {
            return H.size();
        }

    };

    /*  Terms used:
        - Total Area = area of polygons S and T
        - Side = sqrt(Total Area)
        - Ideal Rectangle = a rectangle with heighh such that (Side / 2) <= H < Side
        - Rectangle = any rectangle, no requirements
        - Triangulate = cut polygons to triangles, and cut triangles and tape them to
          get rectangles

        Main Idea:
        - Turn S and T to squares, then inverse operations done on T
        - Any polygon can be cut into triangles, and if we put the side with longest length on the
          x-axis, then cut it in 3 parts (at half height), we get a rectangle
        - A rectangle can be turned into any rectangle by turning it to ideal, then cutting it into
          3 pieces: small triangle, big triangle, and pentagon. Pentagon stays where it is, the big
          triangle is shifted diagonally up, and small triangle is moved from its original position
          to fill the gap, abpve the pentagon and on the left side of the big triangle.
    */

    ListOfRectangles triangulate_to_rectangles(Shape s, vector<Operation> &ops) {
        Operation op;
        ListOfRectangles res;
        op.start_shape = s;

        type cur_x = 0.0;
        while (s.size() > 2) {
            for (int i = 0, N = s.size(); i < N; i++) {
                Point A = s[(i + N - 1) % N], B = s[i], C = s[(i + 1) % N];
                if (sign(cross(B - A, C - A)) == -1) continue; // the angle is concave

                /* Check if there is a point inside the triangle ABC */
                bool no_point_inside_triangle = true;
                for (int j = 0; j < N; j++) {
                    if (i == j || ((i + N - 1) % N) == j || ((i + N + 1) % N) == j) continue;
                    if (in_triangle(A, B, C, s[j])) no_point_inside_triangle = false;
                }
                if (!no_point_inside_triangle) continue;

                /* Make side AB the longest side */
                type l_AB = dot(B - A, B - A), l_BC = dot(C - B, C - B), l_AC = dot(C - A, C - A);
                while (l_AB < max(l_BC, l_AC)) {
                    rotate_left(A, B, C);
                    l_AB = dot(B - A, B - A), l_BC = dot(C - B, C - B), l_AC = dot(C - A, C - A);
                }

                /* Recompute after changes */
                Point U = A + (C - A) * 0.5; // halfway on line AC
                Point V = B + (C - B) * 0.5; // halfway on line BC
                Point M = ((U * dot(V - U, V - U)) + ((V - U) * dot(C - U, V - U))) / dot(V - U, V - U); // intersection of height of UVC and line UV

                /* Cut polygons UMC, MVC, ABVU */
                Point shift = A; // vector shifting triangle to 0, 0
                type deg = (B - shift).rot_diff(Point(0, 0)); // all points needed to be rotated by this much

                if (get_area({A, B, V, U}) > 0) {
                    op.cut_shapes.push_back({A, B, V, U});
                    op.tape_shapes.push_back({Point(cur_x, 0) + (A - shift).rot(deg), Point(cur_x, 0) + (B - shift).rot(deg),
                                              Point(cur_x, 0) + (V - shift).rot(deg), Point(cur_x, 0) + (U - shift).rot(deg)});
                }

                if (get_area({U, M, C}) > 0) {
                    op.cut_shapes.push_back({U, M, C});
                    op.tape_shapes.push_back({Point(cur_x, 0) + (U - shift).rot(deg), Point(cur_x, 0) + (U + U - M - shift).rot(deg),
                                              Point(cur_x, 0) + (A - shift).rot(deg)});

                }

                if (get_area({V, C, M}) > 0) {
                    op.cut_shapes.push_back({V, C, M});
                    op.tape_shapes.push_back({Point(cur_x, 0) + (V - shift).rot(deg), Point(cur_x, 0) + (B - shift).rot(deg),
                                              Point(cur_x, 0) + (V + V - M - shift).rot(deg)});
                }

                res.W.push_back(sqrtl(l_AB));
                res.H.push_back(get_area({A, B, C}) / res.W.back());

                op.final_shape.push_back({cur_x, res.H.back()});
                op.final_shape.push_back({cur_x + res.W.back(), res.H.back()});

                cur_x += sqrtl(l_AB);
                s.erase(s.begin() + i);
                break;
            }
        }

        op.final_shape.emplace_back(cur_x, 0);
        op.final_shape.emplace_back(0, 0);
        reverse(op.final_shape.begin(), op.final_shape.end());
        ops.emplace_back(op);

        return res;
    }

    ListOfRectangles rectangles_to_ideal_rectangles(ListOfRectangles rect, vector<Operation> &ops) {
        type side = sqrtl(Area);
        vector<type> &H = rect.H;
        vector<type> &W = rect.W;

        while (true) {
            int N = rect.size();
            bool stop = true;
            ListOfRectangles nxt;
            type cut_x = 0.0;
            type tape_x = 0.0;
            Operation op;
            op.start_shape = ops.back().final_shape;

            for (int i = 0; i < N; i++) {
                if (H[i] * 2.0 < side) {
                    stop = false;
                    op.cut_shapes.push_back({{cut_x, 0}, {cut_x + W[i] / 2.0, 0}, {cut_x + W[i] / 2.0, H[i]}, {cut_x, H[i]}});
                    op.tape_shapes.push_back({{tape_x, 0}, {tape_x + W[i] / 2.0, 0}, {tape_x + W[i] / 2.0, H[i]}, {tape_x, H[i]}});

                    op.cut_shapes.push_back({{cut_x + W[i] / 2.0, 0}, {cut_x + W[i], 0}, {cut_x + W[i], H[i]}, {cut_x + W[i] / 2.0, H[i]}});
                    op.tape_shapes.push_back({{tape_x, H[i]}, {tape_x + W[i] / 2.0, H[i]}, {tape_x + W[i] / 2.0, H[i] * 2.0}, {tape_x, H[i] * 2.0}});

                    op.final_shape.emplace_back(tape_x, H[i] * 2.0);
                    op.final_shape.emplace_back(tape_x + W[i] / 2.0, H[i] * 2.0);

                    tape_x += W[i] / 2.0;
                    cut_x += W[i];

                    nxt.W.push_back(W[i] / 2.0);
                    nxt.H.push_back(H[i] * 2.0);
                } else if (H[i] >= side) {
                    stop = false;
                    op.cut_shapes.push_back({{cut_x, 0}, {cut_x + W[i], 0}, {cut_x + W[i], H[i] / 2.0}, {cut_x, H[i] / 2.0}});
                    op.tape_shapes.push_back({{tape_x, 0}, {tape_x + W[i], 0}, {tape_x + W[i], H[i] / 2.0}, {tape_x, H[i] / 2.0}});

                    op.cut_shapes.push_back({{cut_x, H[i] / 2.0}, {cut_x + W[i], H[i] / 2.0}, {cut_x + W[i], H[i]}, {cut_x, H[i]}});
                    op.tape_shapes.push_back({{tape_x + W[i], 0}, {tape_x + W[i] * 2.0, 0}, {tape_x + W[i] * 2.0, H[i] / 2.0}, {tape_x + W[i], H[i] / 2.0}});

                    op.final_shape.emplace_back(tape_x, H[i] / 2.0);
                    op.final_shape.emplace_back(tape_x + W[i] * 2.0, H[i] / 2.0);

                    tape_x += W[i] * 2.0;
                    cut_x += W[i];

                    nxt.W.push_back(W[i] * 2.0);
                    nxt.H.push_back(H[i] / 2.0);
                } else {
                    op.cut_shapes.push_back({{cut_x, 0}, {cut_x + W[i], 0}, {cut_x + W[i], H[i]}, {cut_x, H[i]}});
                    op.tape_shapes.push_back({{tape_x, 0}, {tape_x + W[i], 0}, {tape_x + W[i], H[i]}, {tape_x, H[i]}});

                    op.final_shape.emplace_back(tape_x, H[i]);
                    op.final_shape.emplace_back(tape_x + W[i], H[i]);

                    tape_x += W[i];
                    cut_x += W[i];

                    nxt.W.push_back(W[i]);
                    nxt.H.push_back(H[i]);
                }
            }

            op.final_shape.emplace_back(tape_x, 0);
            op.final_shape.emplace_back(0, 0);

            reverse(op.final_shape.begin(), op.final_shape.end());

            ops.emplace_back(op);
            rect = nxt;
            if (stop) break;
        }

        return rect;
    }

    void ideal_rectangles_to_square(ListOfRectangles rect, vector<Operation> &ops) {
        type cut_x = 0.0;
        type tape_x = 0.0;
        type side = sqrtl(Area);
        Operation op;
        op.start_shape = ops.back().final_shape;

        int N = rect.size();
        vector<type> H = rect.H;
        vector<type> W = rect.W;

        for (int i = 0; i < N; i++) {
            type new_cut_x = cut_x + W[i];
            type right_triangle = ((H[i] * W[i]) / side);
            type diff_height = side - H[i];
            /* Cut rectangle to 3 pieces: 2 triangles and pentagon */

            /* Triangles */
            op.cut_shapes.push_back({{right_triangle + cut_x, 0}, {new_cut_x, 0}, {right_triangle + cut_x, diff_height}});
            op.tape_shapes.push_back({{tape_x, side - diff_height}, {W[i] - right_triangle + tape_x, side - diff_height}, {tape_x, side}});

            op.cut_shapes.push_back({{new_cut_x, 0}, {new_cut_x, H[i]}, {W[i] - right_triangle + cut_x, H[i]}});
            op.tape_shapes.push_back({{tape_x + right_triangle, diff_height}, {tape_x + right_triangle, side}, {tape_x, side}});

            /* Pentagon */
            op.cut_shapes.push_back({{cut_x, 0}, {cut_x + right_triangle, 0}, {cut_x + right_triangle, diff_height},
                                     {cut_x + W[i] - right_triangle, H[i]}, {cut_x, H[i]}});
            op.tape_shapes.push_back({{tape_x, 0}, {tape_x + right_triangle, 0}, {tape_x + right_triangle, diff_height},
                                     {tape_x + W[i] - right_triangle, H[i]}, {tape_x, H[i]}});

            cut_x = new_cut_x;
            tape_x = tape_x + right_triangle;
        }

        op.final_shape = {{0, 0}, {side, 0}, {side, side}, {0, side}};
        ops.emplace_back(op);
    }

    vector<Operation> polygon_to_square(Shape s) {
        vector<Operation> res;
        ListOfRectangles rectangles = triangulate_to_rectangles(s, res);
        ListOfRectangles ideal_rectangles = rectangles_to_ideal_rectangles(rectangles, res);
        ideal_rectangles_to_square(ideal_rectangles, res);
        return res;
    }

public:

    Scissors_and_Tape() {};

    Scissors_and_Tape(Shape s, Shape t): Start(s), Target(t) {}

    vector<Operation> get_solution() {
        Area = get_area(Start);
        vector<Operation> start_to_square = polygon_to_square(Start);
        vector<Operation> target_to_square = reverse_operations(polygon_to_square(Target));
        vector<Operation> res;
        res.insert(res.end(), start_to_square.begin(), start_to_square.end());
        res.insert(res.end(), target_to_square.begin(), target_to_square.end());

        return res;
    }

};

int main() {
    cout << fixed << setprecision(10);

    Shape Start = read_shape();
    Shape Target = read_shape();

    Scissors_and_Tape solver(Start, Target);
    vector<Operation> solution = solver.get_solution();

    int cur_id = 0;
    for (auto op : solution) {
        int new_id = cur_id + op.cut_shapes.size() + 1;

        cout << "scissors\n";
        cout << cur_id << " " << op.cut_shapes.size() << "\n";
        for (auto s : op.cut_shapes) print_shape(s);

        cout << "tape\n";
        cout << op.tape_shapes.size();
        for (int id = cur_id + 1; id < new_id; id++) cout << " " << id;
        cout << "\n";
        for (auto s : op.tape_shapes) print_shape(s);
        print_shape(op.final_shape);

        cur_id = new_id;
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin>>n;

    int s = 0;
    for (s=1;s*(s+1)/2 < n;s++);

    if ( s*(s+1)/2 == n )
    {
        cout<<s<<endl;
        for (int i=1;i<=s;i++) cout<<i<<" ";
    }
    else
    {
        cout<<s-1<<endl;
        for (int i=1;i<s-1;i++)
            cout<<i<<" ";
        cout<<n-( (s-2)*(s-1)/2 )<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int arr[110][2], arr2[100], n, k, i, a, cnt;

bool isSuitable()
{
    for(i = 1 ; i <= 100 ; i++)
    {
        if(arr[i][0] != 0)
        {
            cnt++;
            arr2[cnt] = arr[i][1];
        }
    }
    if(cnt >= k)
        return true;
    else
        return false;
}

void readA()
{
    for(i = 1 ; i <= n ; i++)
    {
        scanf("%d", &a);
        arr[a][0]++;
        arr[a][1] = i;
    }
}
int main()
{
    scanf("%d%d", &n, &k);
    readA();
    bool suitable;
    suitable = isSuitable();
    sort(arr2, arr2 + cnt);
    printf("%s\n", suitable ? "YES" : "NO");
    if(suitable)
        for(i = 1 ; i <= k ; i ++)
            printf("%d ", arr2[i]);

    printf("\n");

}


#include <cstdio>
#include <iostream>
#include <cstdlib>
using namespace std;
const int N = 315;
int s1[N],s2[N];
int main()
{
    int x,t,a,b,d1,d2;
    while(scanf("%d%d%d%d%d%d",&x,&t,&a,&b,&d1,&d2) != EOF)
    {
        for(int i = 0; i < t; i++)
        {
            s1[i] = a - d1 * i;
            s2[i] = b - d2 * i;
        }
        s1[t] = s2[t] = 0;
        bool mark = false;
        for(int i = 0; i <= t; i++)
        {
            for(int j = 0; j <= t; j++)
            {
                if(s1[i] + s2[j] == x)
                {
                    mark = true;
                    break;
                }
            }
        }
        puts(mark ? "YES" : "NO");
    }
    return 0;
}


#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define N 200010
struct Edge{
	ll l;
	int e,n;
}e[N<<1];
int hd[N],cur[N],cnt=1;
void add(int a,int b,ll l){
	e[++cnt].e=b;e[cnt].l=l;e[cnt].n=hd[a];hd[a]=cnt;
	e[++cnt].e=a;e[cnt].l=0;e[cnt].n=hd[b];hd[b]=cnt;
}
ll inf=1e15;
int n,m,s,t;
ll a[N];
int dep[N];
queue<int>Q;
ll dfs(int p,ll flow){
	if(p==t)return flow;
	int i;
	for(i=cur[p];i;i=e[i].n){
		int q=e[i].e;
		cur[p]=i;
		if(dep[q]==dep[p]+1&&e[i].l){
			ll ans=dfs(q,min(flow,e[i].l));
			if(ans){
				e[i].l-=ans;
				e[i^1].l+=ans;
				return ans;
			}
		}
	}
	return 0;
}
int bfs(){
	memset(dep,0,sizeof(dep));
	Q.push(s);dep[s]=1;
	int i;
	while(!Q.empty()){
		int p=Q.front();Q.pop();
		for(i=hd[p];i;i=e[i].n){
			int q=e[i].e;
			if(!dep[q]&&e[i].l)dep[q]=dep[p]+1,Q.push(q);
		}
	}
	return dep[t];
}
int tot;//�ڵ�
ll dinic(){
	int i;
	ll d,ans=0;
	while(bfs()){
		for(i=0;i<=tot;i++)cur[i]=hd[i];
		while((d=dfs(s,inf)))ans+=d;
	}
	return ans;
}
int id[N],L[N],R[N];
void build(int p,int l,int r){
	id[p]=++tot;
	L[p]=l;R[p]=r;
	if(l==r){
		add(tot,l,1);
		return;
	}
	build(p<<1,l,(l+r)>>1);
	build(p<<1|1,((l+r)>>1)+1,r);
	add(id[p],id[p<<1],inf);
	add(id[p],id[p<<1|1],inf);
}
void upd(int p,int l,int r){
	if(L[p]>=l&&R[p]<=r){
		add(tot,id[p],1);
		return;
	}
	if(L[p]>r||R[p]<l)return;
	upd(p<<1,l,r);
	upd(p<<1|1,l,r);
}
map<int,int>mp[N];
int vis[N],start,ret;
void solve(int x){
	if(x>=start){ret=x-start;return;}
	map<int,int>::iterator it=mp[x].begin();
	solve(it->first);
	--it->second;
	if(!it->second)mp[x].erase(it);
}
int main(){
	int i,j,u,k,l,r,opt;
	int temp=0;
	scanf("%d%d",&n,&m);
	tot=m;
	build(1,1,m);
	s=++tot;t=++tot;
	start=tot;
	for(i=1;i<=n;i++){
		++tot;
		scanf("%d",&opt);
		if(opt==0){
			add(s,tot,1);
			scanf("%d",&k);
			while(k--)scanf("%d",&u),add(tot,u,1);
		}else if(opt==1){
			add(s,tot,1);
			scanf("%d%d",&l,&r);
			upd(1,l,r);
		}else{
			int A,B,C;
			scanf("%d%d%d",&A,&B,&C);
			add(tot,A,1);
			add(tot,B,0);e[cnt].l=1;vis[B]=1;
			add(tot,C,1);e[cnt].l=1;vis[C]=1;
			temp+=2;
		}
	}
	for(i=1;i<=m;i++)if(!vis[i])add(i,t,1);
	printf("%I64d\n",dinic()+temp);
	for(i=1;i<=tot;i++)
		for(j=hd[i];j;j=e[j].n)
			if((j&1)&&e[j].l)mp[i][e[j].e]=e[j].l;
	for(i=1;i<=m;i++){
		int flag=0;
		for(j=hd[i];j;j=e[j].n)if(e[j].e==t&&e[j].l){
			flag=1;
			break;
		}
		if(flag)continue;
		solve(i);
		printf("%d %d\n",ret,i);
	}
	return 0;
}