#include <cstdio>
#include <cstring>

using namespace std;

int tr, p[90];
long long f[90], g[90], fib[90];

int main()
{
	fib[0] = 1, fib[1] = 1;
	for (int i = 2; i < 88; i++)
		fib[i] = fib[i - 1] + fib[i - 2];
	int maxnum = 87;

	scanf("%d", &tr);
	for (int test = 0; test < tr; test++)
	{
		memset(p, 0, sizeof p);
		long long num;
		scanf("%I64d", &num);
		for (int t = maxnum; t > 0; t--)
		    if (num >= fib[t])
		    {
				p[t] = 1;
				num -= fib[t];
			}
		g[1] = f[1] = 1;
		int flag = -1;
		for (int i = 2; i <= maxnum; i++)
		{
			g[i] = f[i] = f[i - 1];
			if (p[i] == 1 && flag > 0)
				f[i] += g[flag];
		    if (p[i] == 0 && p[i - 1] == 0)
		    {
				if (flag > 0)
				    g[i] += g[flag];
		        flag = i - 1;
			}
		}
		printf("%I64d\n", f[maxnum]);

	}

	return 0;
}


#include <cstdio>

using namespace std;

const int maxn = 220;
const long long maxnum = 1000000000000000000LL;
int tr, tot;
long long n, f[maxn], s[maxn];

int slove(long long k, int h)
{
	if (k == 0)
	        return 1;
	int res = 0;
	for (int i = h; i > 0 && s[i] >= k; i--)
	        if (f[i] <= k)
	                res += slove(k - f[i], i - 1);
	return res;
}

int main()
{
	f[0] = 1, f[1] = 1, s[1] = 1;
	for (int i = 2; f[i - 1] + f[i - 2] <= maxnum; i++)
	{
		f[i] = f[i - 1] + f[i - 2];
		s[i] = s[i - 1] + f[i];
		tot = i;
	}
	scanf("%d", &tr);
	for (int test = 0; test < tr; test++)
	{
		scanf("%I64d", &n);
		printf("%d\n", slove(n, tot));
	}

	return 0;
}


#include <cstdio>

using namespace std;

const int maxn = 220;
const long long maxnum = (long long)1e18;
int tr, tot, n;
long long f[maxn], s[maxn];

long long slove(long long k, int h)
{
	if (k == 0)
	        return 1;
	long long res = 0;
	for (int i = h; i > 0 && s[i] >= k; i--)
	        if (f[i] <= k)
	                res += slove(k - f[i], i - 1);
	return res;
}

int main()
{
	f[0] = 1, f[1] = 1, s[1] = 1;
	for (int i = 2; f[i - 1] + f[i - 2] <= maxnum; i++)
	{
		f[i] = f[i - 1] + f[i - 2];
		s[i] = s[i - 1] + f[i];
		tot = i;
	}
	scanf("%d", &tr);
	for (int test = 0; test < tr; test++)
	{
		scanf("%I64d", &n);
		printf("%I64d\n", slove(n, tot));
	}

	return 0;
}


#include <cstdio>

using namespace std;

const int maxn = 220;
const long long maxnum = (long long)(1e18);
int tr, tot, n;
long long f[maxn], s[maxn];

int slove(long long k, int h)
{
	if (k == 0)
	        return 1;
	int res = 0;
	for (int i = h; i > 0 && s[i] >= k; i--)
	        if (f[i] <= k)
	                res += slove(k - f[i], i - 1);
	return res;
}

int main()
{
	f[0] = 1, f[1] = 1, s[1] = 1;
	for (int i = 2; f[i - 1] + f[i - 2] <= maxnum; i++)
	{
		f[i] = f[i - 1] + f[i - 2];
		s[i] = s[i - 1] + f[i];
		tot = i;
	}
	scanf("%d", &tr);
	for (int test = 0; test < tr; test++)
	{
		scanf("%I64d", &n);
		printf("%d\n", slove(n, tot));
	}

	return 0;
}


#include <cstdio>

using namespace std;

const int maxn = 220;
const long long maxnum = (long long)1e18;
int tr, tot, n;
long long f[maxn], s[maxn];

int slove(long long k, int h)
{
	if (k == 0)
	        return 1;
	int res = 0;
	for (int i = h; i > 0 && s[i] >= k; i--)
	        if (f[i] <= k)
	                res += slove(k - f[i], i - 1);
	return res;
}

int main()
{
	f[0] = 1, f[1] = 1, s[1] = 1;
	for (int i = 2; f[i - 1] + f[i - 2] <= maxnum; i++)
	{
		f[i] = f[i - 1] + f[i - 2];
		s[i] = s[i - 1] + f[i];
		tot = i;
	}
	scanf("%d", &tr);
	for (int test = 0; test < tr; test++)
	{
		scanf("%I64d", &n);
		printf("%d\n", slove(n, tot));
	}

	return 0;
}


#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <ctime>
#define int64 long long
#define N 100
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
int i,j,k,n,m,nn,t,F;
int a[N],b[N];
int64 f[N],s[N],K,h[N][2];
inline void work() {
	int i;
	int64 x;
	For(i,1,nn) b[i]=0;
	For(i,1,t) b[a[i]]=1;
	memset(h,0,sizeof(h));
	h[nn][0]=1;
	for (i=nn;i;i--)For(j,0,1) if (x=h[i][j]) {
		if (i>1&&!b[i-1]&&(b[i]||j)) h[i-2][1]+=x;
		if (!(j&&b[i])) h[i-1][0]+=x;
	}
	printf("%I64d\n",h[0][0]);
}
void dfs(int64 n,int m) {
	if (F) return;
	if (!n) {
		F=1;
		work();
		return;
	}
	if (m<=0) return;
	if (n>s[m]) return;
	int i;
	for (i=m;i;i--) if (f[i]<=n) {
		a[++t]=i;
		dfs(n-f[i],i-2);
		t--;
		if (F) return;
	}
}
int main() {
	//freopen("126d.in","r",stdin);
	//freopen("126d.out","w",stdout);
	nn=87;
	f[1]=1,f[2]=2; For(i,3,nn) f[i]=f[i-1]+f[i-2];
	For(i,1,nn) s[i]=s[i-1]+f[i];
	scanf("%d",&n);
	For(i,1,n) {
		scanf("%I64d",&K);
		t=F=0;
		dfs(K,nn);
		if (!F) printf("0\n");
	}
	//printf("%d\n",clock());
	//for(;;);
	return 0;
}


#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#define int64 long long
#define N 100
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
int i,j,k,n,m,nn,t,F;
int a[N],b[N];
int64 f[N],s[N],K,h[N][2];
inline void work() {
	int i;
	int64 x;
	For(i,1,nn) b[i]=0;
	For(i,1,t) b[a[i]]=1;
	memset(h,0,sizeof(h));
	h[nn][0]=1;
	for (i=nn;i;i--)For(j,0,1) if (x=h[i][j]) {
		if (i>1&&!b[i-1]&&(b[i]||j)) h[i-2][1]+=x;
		if (!(j&&b[i])) h[i-1][0]+=x;
	}
	printf("%I64d\n",h[0][0]);
}
void dfs(int64 n,int m) {
	if (F) return;
	if (!n) {
		F=1;
		work();
		return;
	}
	if (m<=0) return;
	if (n>s[m]) return;
	int i;
	For(i,1,m) {
		if (f[i]>n) return;
		a[++t]=i;
		dfs(n-f[i],i-2);
		t--;
		if (F) return;
	}
}
int main() {
	nn=87;
	f[1]=1,f[2]=2; For(i,3,nn) f[i]=f[i-1]+f[i-2];
	For(i,1,nn) s[i]=s[i-1]+f[i];
	scanf("%d",&n);
	For(i,1,n) {
		scanf("%I64d",&K);
		t=F=0;
		dfs(K,nn);
		if (!F) printf("0\n");
	}
	//for(;;);
	return 0;
}


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

using namespace std;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

#define int long long
#define rep(i, s, e) for(int i = s; i < e; i ++)
#define X first
#define Y second

typedef long long ll;
typedef long double ld;

const int maxN = 2000 + 5;
const int mod = 1000*1000*1000 + 7;
const int base = 701;
const int SQ = 600;
const int maxL = 302;

vector<int> fib;
int a[100];
int dp[2][100];
int solve(int x)
{
    for(int i = (int)fib.size()-1; i >= 0; i --)
    {
	if(x >= fib[i]) a[i] = 1, x -= fib[i];
	else a[i] = 0;
    }

    dp[1][0] = 1;
    if(a[0] == 0) dp[0][0] = 1;

    rep(i,1,(int)fib.size())
    {
	if(a[i] == 1)
	{
	    dp[0][i] = 0;
	    dp[1][i] = dp[a[i-1]][i-1];
	    if(i > 1 && a[i-1] == 0 && a[i-2] == 0)
		dp[1][i] += dp[1][i-2];
	}
	else
	{
	    dp[0][i] = dp[a[i-1]][i-1];
	    dp[1][i] = dp[0][i];
	    if(i > 1 && a[i-1] == 0 && a[i-2] == 0)
		dp[1][i] += dp[1][i-2];
	}
//	cout << dp[a[i]][i] <<
    }
    return dp[a[fib.size()-1]][fib.size()-1];
}

int32_t main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    fib.push_back(1); fib.push_back(2);
    while(fib.back() + fib[fib.size()-2] <= 1000LL*1000*1000*1000*1000*1000)
	fib.push_back(fib.back() + fib[fib.size()-2]);

    int n; cin >> n;
    rep(i,0,n)
    {
	int x; cin >> x;
	cout << solve(x) << endl;
    }
    return 0;
}


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

using namespace std;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

#define int long long
#define rep(i, s, e) for(int i = s; i < e; i ++)
#define X first
#define Y second

typedef long long ll;
typedef long double ld;

const int maxN = 2000 + 5;
const int mod = 1000*1000*1000 + 7;
const int base = 701;
const int SQ = 600;
const int maxL = 302;

vector<int> fib;
int a[100];
int dp[2][100];

int solve(int x)
{
    for(int i = (int)fib.size()-1; i >= 0; i --)
    {
	if(x >= fib[i]) a[i] = 1, x -= fib[i];
	else a[i] = 0;
    }

//    memset(dp,0,sizeof dp);
    int cnt = 0;
    int las = 0;
    rep(i,0,(int)fib.size())
    {
	if(a[i] == 0) { cnt ++; continue; }
	las = i;
	if(cnt % 2)
	{
	    if(i == cnt) { dp[0][i] = 1; dp[1][i] = cnt / 2; }
	    else
	    {
		int res = (dp[0][i-cnt-1] + dp[1][i-cnt-1]);
		dp[0][i] = res;
		dp[1][i] = res * (cnt/2);
		dp[1][i] += dp[1][i-cnt-1];
	    }
	}
	else
	{
	    if(i == cnt) { dp[0][i] = 1; dp[1][i] = cnt / 2; }
	    else
	    {
		int res = (dp[0][i-cnt-1] + dp[1][i-cnt-1]);
		dp[0][i] = res;
		dp[1][i] = res * (cnt/2);
	    }
	}

	cnt = 0;
    }

    return dp[0][las] + dp[1][las];
}

int32_t main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    fib.push_back(1); fib.push_back(2);
    while(fib.back() + fib[fib.size()-2] <= 1000LL*1000*1000*1000*1000*1000)
	fib.push_back(fib.back() + fib[fib.size()-2]);

    int n; cin >> n;
    rep(i,0,n)
    {
	int x; cin >> x;
	cout << solve(x) << endl;
    }
    return 0;
}


/*
 * D.cpp
 *
 *  Created on: Nov 10, 2011
 *      Author: carlosjosetoribio
 */

#include<iostream>
#include<map>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long Long;
vector<Long> ANS;

bool cat[100][2];
Long memo[100][2];
Long DP(int id = 0,Long add = 0)
{
    Long w = 0;
    if(id == ANS.size())return 1;
    if(cat[id][add])return memo[id][add];
    int p = id ? ANS[id-1] : -1;
    w += DP(id+1 , 0);
//  if(id==0)cout<<w<<endl;
    if((ANS[id]-p-1+add) >= 2)w += ((ANS[id]-p-1+add)/2) * DP(id+1 ,1);
    cat[id][add] = true;
    return memo[id][add] = w;
}

int main()
{
    vector<Long> V;
    V.push_back(1);
    V.push_back(2);
    for(int i = 2; V.back() <= (Long)1e18;  ++i)
    {
        V.push_back(V[i-1] + V[i-2]);
    }
    Long N;
    Long TC;
    cin>>TC;
    while(TC-- && cin>>N)
    //cin>>N;
    {
        ANS = vector<Long>();
        for(int i = V.size()-1; i >= 0 ; --i)
        {
            if(N >= V[i])
            {
//              cout<<V[i]<<", ";
                ANS.push_back(i);
                N -= V[i];
            }
        }
//      cout<<endl;
        reverse(ANS.begin(),ANS.end());
        memset(cat,false,sizeof(cat));
        cout<<DP()<<endl;

    }
}


/*
 * D.cpp
 *
 *  Created on: Nov 10, 2011
 *      Author: carlosjosetoribio
 */

#include<iostream>
#include<map>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long Long;
vector<int> ANS;

bool cat[50][2];
int memo[50][2];
int DP(int id = 0,int add = 0)
{
    int w = 0;
    if(id == ANS.size())return 1;
    if(cat[id][add])return memo[id][add];
    int p = id ? ANS[id-1] : -1;
    w += DP(id+1 , 0);
//  if(id==0)cout<<w<<endl;
    if((ANS[id]-p-1+add) >= 2)w += ((ANS[id]-p-1+add)/2) * DP(id+1 ,1);
    cat[id][add] = true;
    return memo[id][add] = w;
}

int main()
{
    vector<Long> V;
    V.push_back(1);
    V.push_back(2);
    for(int i = 2; V.back() <= (Long)1e5;  ++i)
    {
        V.push_back(V[i-1] + V[i-2]);
    }
    int N;
    int TC;
    cin>>TC;
    while(TC-- && cin>>N)
    //cin>>N;
    {
        ANS = vector<int>();
        for(int i = V.size()-1; i >= 0 ; --i)
        {
            if(N >= V[i])
            {
//              cout<<V[i]<<", ";
                ANS.push_back(i);
                N -= V[i];
            }
        }
        //cout<<endl;
        reverse(ANS.begin(),ANS.end());
        memset(cat,false,sizeof(cat));
        cout<<DP()<<endl;

    }
}


/*
 * D.cpp
 *
 *  Created on: Nov 10, 2011
 *      Author: carlosjosetoribio
 */

#include<iostream>
#include<map>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long Long;
vector<int> ANS;

bool cat[50][2];
Long memo[50][2];
Long DP(int id = 0,int add = 0)
{
    Long w = 0;
    if(id == ANS.size())return 1;
    if(cat[id][add])return memo[id][add];
    int p = id ? ANS[id-1] : -1;
    w += DP(id+1 , 0);
//  if(id==0)cout<<w<<endl;
    if((ANS[id]-p-1+add) >= 2)w += ((ANS[id]-p-1+add)/2) * DP(id+1 ,1);
    cat[id][add] = true;
    return memo[id][add] = w;
}

int main()
{
    vector<Long> V;
    V.push_back(1);
    V.push_back(2);
    for(int i = 2; V.back() <= (Long)1e5;  ++i)
    {
        V.push_back(V[i-1] + V[i-2]);
    }
    int N;
    int TC;
    cin>>TC;
    while(TC-- && cin>>N)
    //cin>>N;
    {
        ANS = vector<int>();
        for(int i = V.size()-1; i >= 0 ; --i)
        {
            if(N >= V[i])
            {
//              cout<<V[i]<<", ";
                ANS.push_back(i);
                N -= V[i];
            }
        }
        //cout<<endl;
        reverse(ANS.begin(),ANS.end());
        memset(cat,false,sizeof(cat));
        cout<<DP()<<endl;

    }
}


/*
 * D.cpp
 *
 *  Created on: Nov 10, 2011
 *      Author: carlosjosetoribio
 */

#include<iostream>
#include<map>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long Long;
map<Long,int> M;

int main()
{
    vector<Long> V;
    V.push_back(1);
    V.push_back(2);
    for(int i = 2; V.back() <= (Long)1e5;  ++i)
    {
        V.push_back(V[i-1] + V[i-2]);
    }
    int N;
    int TC;
    cin>>TC;
    while(cin>>N && TC--)
    //cin>>N;
    {
        vector<int> ANS;
        for(int i = V.size()-1; i >= 0 ; --i)
        {
            if(N >= V[i])
            {
                //cout<<V[i]<<", ";
                ANS.push_back(i);
                N -= V[i];
            }
        }
        reverse(ANS.begin(),ANS.end());

        //cout<<endl;
        bool can[1000]; memset(can,0,sizeof(can));
        int cnt = 1, p = -1;
        for(int i = 0; i < ANS.size(); ++i)
        {
            cnt *= ((ANS[i]-p-1)/2+1);
            p = ANS[i];
        }
        cout<<cnt<<endl;
    }
}


/*
 * D.cpp
 *
 *  Created on: Nov 10, 2011
 *      Author: carlosjosetoribio
 */

#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef long long Long;
map<Long,int> M;

int main()
{
    vector<Long> V;
    V.push_back(1);
    V.push_back(2);
    for(int i = 2; V.back() <= (Long)1e5;  ++i)
    {
        V.push_back(V[i-1] + V[i-2]);
    }
    int N;
    int TC;
    cin>>TC;
    while(cin>>N && TC--)
    //cin>>N;
    {
        vector<int> ANS;
        for(int i = V.size()-1; i >= 0 ; --i)
        {
            if(N >= V[i])
            {
                //cout<<V[i]<<", ";
                ANS.push_back(i);
                N -= V[i];
            }
        }
        reverse(ANS.begin(),ANS.end());

        //cout<<endl;
        bool can[1000]; memset(can,0,sizeof(can));
        int cnt = 1, p = -1;
        for(int i = 0; i < ANS.size(); ++i)
        {
            cnt *= ((ANS[i]-p-1)/2+1);
            p = ANS[i];
        }
        cout<<cnt<<endl;
    }
}


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

typedef __int64 int64;
const int MAX = 90;

int64 F[MAX];
int get_index[MAX];
int64 dp[MAX][2];

void Fib()
{
	F[0] = 1;	F[1] = 1;
	for (int i = 2; i < 87; ++i) {
		F[i] = F[i - 1] + F[i - 2];
	}
}

int64 Solve(int len)
{
	dp[0][1] = 1;
	dp[0][0] = (get_index[0] - 1) >> 1;
	for (int i = 1; i < len; ++i) {
		dp[i][1] = dp[i - 1][1] + dp[i - 1][0];
		dp[i][0] =
				dp[i - 1][0] * ((get_index[i] - get_index[i - 1]) >> 1)
			+	dp[i - 1][1] * ((get_index[i] - get_index[i - 1] - 1) >> 1);
	}
	return (dp[len - 1][0] + dp[len - 1][1]);
}

int main()
{
	Fib();
	int T;
	scanf("%d", &T);
	while (T--) {
		int64 n;
		int len = 0;
		scanf("%I64d", &n);
		for (int i = 86; i >= 1; --i) {
			if (F[i] <= n) {
				n -= F[i];
				get_index[len++] = i;
			}
		}
		if (n) {
			printf("0\n");
			continue;
		}
		reverse(get_index, get_index + len);
		printf("%I64d\n", Solve(len));
	}
	return 0;
}


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

typedef __int64 int64;
const int MAX = 90;

int64 F[MAX];
int get_index[MAX];
int64 dp[MAX][2];

void Fib()
{
	F[0] = 1;	F[1] = 1;
	for (int i = 2; i < 87; ++i) {
		F[i] = F[i-1] + F[i - 2];
	}
}

int64 Solve(int len)
{
	dp[0][1] = 1;
	dp[0][0] = (get_index[0] - 1) >> 1;
	for (int i = 1; i < len; ++i) {
		dp[i][1] = dp[i - 1][1] + dp[i - 1][0];
		dp[i][0] = dp[i - 1][0] * ((get_index[i] - get_index[i - 1]) / 2)
				+ dp[i - 1][1] * ((get_index[i] - get_index[i - 1] - 1) / 2);
	}
	return (dp[len - 1][0] + dp[len - 1][1]);
}

int main()
{
	Fib();
	int T;
	scanf("%d", &T);
	while (T--) {
		int64 n;
		int len = 0;
		scanf("%I64d", &n);
		for (int i = 86; i >= 1; --i) {
			if (F[i] <= n) {
				n -= F[i];
				get_index[len++] = i;
			}
		}
		reverse(get_index, get_index + len);
		printf("%I64d\n", Solve(len));
	}
	return 0;
}


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

typedef __int64 int64;
const int MAX = 90;

int64 F[MAX];
int get_index[MAX];
int64 dp[MAX][2];

void Fib()
{
	F[0] = 1;	F[1] = 1;
	for (int i = 2; i < 87; ++i) {
		F[i] = F[i - 1] + F[i - 2];
	}
}

int64 Solve(int len)
{
	dp[0][1] = 1;
	dp[0][0] = (get_index[0] - 1) >> 1;
	for (int i = 1; i < len; ++i) {
		dp[i][1] = dp[i - 1][1] + dp[i - 1][0];
		dp[i][0] =
				dp[i - 1][0] * ((get_index[i] - get_index[i - 1]) >> 2)
			+	dp[i - 1][1] * ((get_index[i] - get_index[i - 1] - 1) >> 2);
	}
	return (dp[len - 1][0] + dp[len - 1][1]);
}

int main()
{
	Fib();
	int T;
	scanf("%d", &T);
	while (T--) {
		int64 n;
		int len = 0;
		scanf("%I64d", &n);
		for (int i = 86; i >= 1; --i) {
			if (F[i] <= n) {
				n -= F[i];
				get_index[len++] = i;
			}
		}
		if (n) {
			printf("0\n");
			continue;
		}
		reverse(get_index, get_index + len);
		printf("%I64d\n", Solve(len));
	}
	return 0;
}


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

typedef __int64 int64;
const int MAX = 90;

int64 F[MAX];
int get_index[MAX];
int dp[MAX][2];

void Fib()
{
	F[0] = 1;	F[1] = 1;
	for (int i = 2; i < 87; ++i) {
		F[i] = F[i-1] + F[i - 2];
	}
}

int Solve(int len)
{
	dp[0][1] = 1;
	dp[0][0] = (get_index[0] - 1) >> 1;
	for (int i = 1; i < len; ++i) {
		dp[i][1] = dp[i - 1][1] + dp[i - 1][0];
		dp[i][0] = dp[i - 1][0] * ((get_index[i] - get_index[i - 1]) / 2)
				+ dp[i - 1][1] * ((get_index[i] - get_index[i - 1] - 1) / 2);
	}
	return (dp[len - 1][0] + dp[len - 1][1]);
}

int main()
{
	Fib();
	int T;
	scanf("%d", &T);
	while (T--) {
		int64 n;
		int len = 0;
		scanf("%I64d", &n);
		for (int i = 86; i >= 1; --i) {
			if (F[i] <= n) {
				n -= F[i];
				get_index[len++] = i;
			}
		}
		reverse(get_index, get_index + len);
		printf("%d\n", Solve(len));
	}
	return 0;
}


#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <complex>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <string>
#include <cmath>
#include <ctime>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>

#define all(x) (x).begin(), (x).end()
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)

#ifdef KAZAR
    #define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
    #define eprintf(...) 0
#endif

using namespace std;

template<class T> inline void umax(T &a,T b){if(a<b) a = b ; }
template<class T> inline void umin(T &a,T b){if(a>b) a = b ; }
template<class T> inline T abs(T a){return a>0 ? a : -a;}
template<class T> inline T gcd(T a,T b){return __gcd(a, b);}
template<class T> inline T lcm(T a,T b){return a/gcd(a,b)*b;}

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

const int inf = 1e9 + 143;
const ll longinf = 1e18 + 143;

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

const int N = 92;

ll f[N];
bool take[N];

ll dp[N][3][3];

ll calc(int pos,int a,int b){
    if(a > 2 || b > 2)
        return 0;
    if(pos == 1){
        return a <= 1 && b <= 1;
    }
    ll &rev = dp[pos][a][b];
    if(rev != -1)
        return rev;
    rev = 0;
    rev += calc(pos - 1, b + take[pos - 1], a + b);
    if(b > 0)
        rev += calc(pos - 1, b - 1 + take[pos - 1], a + b - 1);
    return rev;
}

int main(){

#ifdef KAZAR
    freopen("f.input","r",stdin);
    freopen("f.output","w",stdout);
    freopen("error","w",stderr);
#endif

    f[0] = 1;
    f[1] = 1;
    for(int i = 2; i < N; i++)
        f[i] = f[i - 1] + f[i - 2];

    int tc = read();
    while(tc--){
        ll x;
        scanf(" %I64d", &x);
        for(int i = N - 1; i >= 0; i--){
            if(f[i] <= x){
                x -= f[i];
                take[i] = 1;
            }else{
                take[i] = 0;
            }
        }
        memset(dp, -1, sizeof dp);
        printf("%I64d\n", calc(N - 1, 0, 0));
    }

    return 0;
}


#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <complex>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <string>
#include <cmath>
#include <ctime>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>

#define all(x) (x).begin(), (x).end()
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)

#ifdef KAZAR
    #define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
    #define eprintf(...) 0
#endif

using namespace std;

template<class T> inline void umax(T &a,T b){if(a<b) a = b ; }
template<class T> inline void umin(T &a,T b){if(a>b) a = b ; }
template<class T> inline T abs(T a){return a>0 ? a : -a;}
template<class T> inline T gcd(T a,T b){return __gcd(a, b);}
template<class T> inline T lcm(T a,T b){return a/gcd(a,b)*b;}

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

const int inf = 1e9 + 143;
const ll longinf = 1e18 + 143;

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

const int N = 92;

ll f[N];
bool take[N];

ll dp[N][N][N];

ll calc(int pos,int a,int b){
    if(pos == 1){
        return a <= 1 && b <= 1;
    }
    ll &rev = dp[pos][a][b];
    if(rev != -1)
        return rev;
    rev = 0;
    rev += calc(pos - 1, b + take[pos - 1], a + b);
    if(b > 0)
        rev += calc(pos - 1, b - 1 + take[pos - 1], a + b - 1);
    return rev;
}

int main(){

#ifdef KAZAR
    freopen("f.input","r",stdin);
    freopen("f.output","w",stdout);
    freopen("error","w",stderr);
#endif

    f[0] = 1;
    f[1] = 1;
    for(int i = 2; i < N; i++)
        f[i] = f[i - 1] + f[i - 2];

    int tc = read();
    while(tc--){
        ll x;
        scanf(" %I64d", &x);
        for(int i = N - 1; i >= 0; i--){
            if(f[i] <= x){
                x -= f[i];
                take[i] = 1;
            }else{
                take[i] = 0;
            }
        }
        memset(dp, -1, sizeof dp);
        printf("%I64d\n", calc(N - 1, 0, 0));
    }

    return 0;
}


#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)

#ifdef KAZAR
    #define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
    #define eprintf(...) 0
#endif

using namespace std;

template<class T> inline void umax(T &a,T b){if(a<b) a = b ; }
template<class T> inline void umin(T &a,T b){if(a>b) a = b ; }
template<class T> inline T abs(T a){return a>0 ? a : -a;}
template<class T> inline T gcd(T a,T b){return __gcd(a, b);}
template<class T> inline T lcm(T a,T b){return a/gcd(a,b)*b;}

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

const int inf = 1e9 + 143;
const ll longinf = 1e18 + 143;

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

int main(){

#ifdef KAZAR
    freopen("f.input","r",stdin);
    freopen("f.output","w",stdout);
    freopen("error","w",stderr);
#endif

    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <utility>
#include <sstream>
#include <algorithm>
using namespace std;
#define ll long long
const long long LINF = ~(((long long)0x1)<<63)/2;
const int INF=0X3F3F3F3F;
const double eps=1e-7;
const ll LIM=1000000000000000000LL;
ll f[100];
bool ok[100];
int main()
{
    int i,j,k,n;
    ll value;
    f[0]=1;f[1]=2;
    for(n=2;;n++)
    {
        f[n]=f[n-1]+f[n-2];
        if(f[n]>LIM)
            break;
    }
    //cout<<n<<" "<<f[n]<<endl;
    ll d=0;
    int T;
    cin>>T;
    while(T--){
        cin>>value;
        memset(ok,false,sizeof(ok));
        for(i=n;i>=0;i--)
            if(value>=f[i])
                value-=f[i],ok[i]=true;
        d=1;
        ll yes=1,no=0;
        for(i=0;i<=n;i++)
        {
            d++;
            if(ok[i])
            {
                d--;
                ll nowyes=yes+no;
                ll nowno=no*(d/2)+yes*((d-1)/2);
                yes=nowyes;
                no=nowno;
                d=1;
            }
        }
        cout<<yes+no<<endl;
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <utility>
#include <sstream>
#include <algorithm>
using namespace std;
#define ll long long
const long long LINF = ~(((long long)0x1)<<63)/2;
const int INF=0X3F3F3F3F;
const double eps=1e-7;
const ll LIM=1000000000000000000LL;
ll f[100];
bool ok[100];
int main()
{
    int i,j,k,n;
    ll value;
    f[0]=1;f[1]=2;
    for(n=2;;n++)
    {
        f[n]=f[n-1]+f[n-2];
        if(f[n]>LIM)
            break;
    }
//  cout<<n<<endl;
    ll d=0;
    int T;
    cin>>T;
    while(T--){
        cin>>value;
        memset(ok,false,sizeof(ok));
        for(i=n;i>=0;i--)
            if(value>=f[i])
                value-=f[i],ok[i]=true;
        d=0;
        ll yes=1,no=0;
        for(i=0;i<=n;i++)
        {
            d++;
            if(ok[i])
            {
                //d--;
                ll nowyes=yes+no;
                ll nowno=no*d/2+yes*(d-1)/2;
                yes=nowyes;
                no=nowno;
                d=0;
            }
        }
        cout<<yes+no<<endl;
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <utility>
#include <sstream>
#include <algorithm>
using namespace std;
#define ll long long
const long long LINF = ~(((long long)0x1)<<63)/2;
const int INF=0X3F3F3F3F;
const double eps=1e-7;
const ll LIM=1000000000000000000ll;
ll f[100];
bool ok[100];
int main()
{
    int i,j,k,n;
    ll value;
    f[0]=1;f[1]=2;
    for(n=2;;n++)
    {
        f[n]=f[n-1]+f[n-2];
        if(f[n]>LIM)
            break;
    }
    ll d=0;
    int T;
    cin>>T;
    while(T--){
        cin>>value;
        memset(ok,false,sizeof(ok));
        for(i=n;i>=0;i--)
            if(value>=f[i])
                value-=f[i],ok[i]=true;
        d=1;
        ll yes=1,no=0;
        for(i=0;i<=n;i++)
        {
            d++;
            if(ok[i])
            {
                d--;
                ll nowyes=yes+no;
                ll nowno=no*d/2+yes*(d-1)/2;
                yes=nowyes;
                no=nowno;
                d=1;
            }
        }
        cout<<yes+no<<endl;
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#define N 1000010
#define P 100000007
using namespace std;
long long n,f[N],Q,ans,g[N];
int s[N],tot;
int i;
int main()
{
    f[1]=1;
    f[2]=2;
    Q=1000000000;
    Q=Q*Q;
    for (i=3;i<=100;i++)
    {
     f[i]=f[i-2]+f[i-1];
     if (f[i]>Q) break;
    }
    g[1]=1;
    for (i=2;i<=100;i++)
    if (i%2)
    g[i]=g[i-1]+1;
    else
    g[i]=g[i-1];
    int test;
    scanf("%d",&test);
    while (test)
    {
    test--;tot=0;
    scanf("%I64d",&n);
    for (i=86;i>=1;i--)
    if (n-f[i]>=0)
    {
                  tot++;s[tot]=i;
                  n=n-f[i];
    }
    ans=1;s[tot+1]=0;
    for (i=1;i<=tot;i++)
    ans=ans*g[s[i]-s[i+1]];
    printf("%I64d\n",ans);
    }
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef long long ll;

const int max_fib = 95;
ll fib[max_fib];
ll dyn1[max_fib], dyn2[max_fib];
int A[max_fib];

ll solve(ll & n)
{
  int cur_fib = 0;
  while (fib[cur_fib + 1] <= n) {
    ++cur_fib;
  }
  int m = 0;
  for (int i = cur_fib; i > 0; --i) {
    if (n >= fib[i]) {
      n -= fib[i];
      A[m++] = i;
    }
  }
  A[m] = 0;

  dyn1[m] = 1, dyn2[m] = 0;
  for (int i = m - 1; i >= 0; --i) {
    dyn1[i] = dyn1[i + 1] + dyn2[i + 1];
    dyn2[i] = (A[i] - A[i + 1] - 1) / 2 * dyn1[i + 1] + (A[i] - A[i + 1]) / 2 * dyn2[i + 1];
  }

  return dyn1[0] + dyn2[0];
}

int main()
{
  ios::sync_with_stdio(0);
  fib[0] = fib[1] = 1;
  for (int i = 2; i < max_fib; ++i) {
    fib[i] = fib[i - 1] + fib[i - 2];
  }

  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    ll n;
    cin >> n;
    cout << solve(n) << '\n';
  }

  return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef long long ll;

const int max_fib = 95;
const int max_len = 20;

ll fib[max_fib];
ll dyn1[max_len], dyn2[max_len];
int A[max_len];

ll solve(ll & n)
{
  int cur_fib = 0;
  while (fib[cur_fib + 1] <= n) {
    ++cur_fib;
  }
  int m = 0;
  for (int i = cur_fib; i > 0; --i) {
    if (n >= fib[i]) {
      n -= fib[i];
      A[m++] = i;
    }
  }
  A[m] = 0;

  dyn1[m] = 1, dyn2[m] = 0;
  for (int i = m - 1; i >= 0; --i) {
    dyn1[i] = dyn1[i + 1] + dyn2[i + 1];
    dyn2[i] = (A[i] - A[i + 1] - 1) / 2 * dyn1[i + 1] + (A[i] - A[i + 1]) / 2 * dyn2[i + 1];
  }

  return dyn1[0] + dyn2[0];
}

int main()
{
  fib[0] = fib[1] = 1;
  for (int i = 2; i < max_fib; ++i) {
    fib[i] = fib[i - 1] + fib[i - 2];
  }

  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    ll n;
    cin >> n;
    cout << solve(n) << '\n';
  }

  return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef long long ll;

const int max_fib = 95;
const int max_len = 20;

ll fib[max_fib];
int dyn1[max_len], dyn2[max_len];
int A[max_len];

int solve(ll & n)
{
  int cur_fib = 0;
  while (fib[cur_fib + 1] <= n) {
    ++cur_fib;
  }
  int m = 0;
  for (int i = cur_fib; i > 0; --i) {
    if (n >= fib[i]) {
      n -= fib[i];
      A[m++] = i;
    }
  }
  A[m] = 0;

  dyn1[m] = 1, dyn2[m] = 0;
  for (int i = m - 1; i >= 0; --i) {
    dyn1[i] = dyn1[i + 1] + dyn2[i + 1];
    dyn2[i] = (A[i] - A[i + 1] - 1) / 2 * dyn1[i + 1] + (A[i] - A[i + 1]) / 2 * dyn2[i + 1];
  }

  return dyn1[0] + dyn2[0];
}

int main()
{
  fib[0] = fib[1] = 1;
  for (int i = 2; i < max_fib; ++i) {
    fib[i] = fib[i - 1] + fib[i - 2];
  }

  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    ll n;
    cin >> n;
    cout << solve(n) << '\n';
  }

  return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef long long ll;

const int max_fib = 95;
ll fib[max_fib];
ll dyn1[max_fib], dyn2[max_fib];
int A[max_fib];

ll solve(ll & n)
{
  int cur_fib = 0;
  while (fib[cur_fib + 1] <= n) {
    ++cur_fib;
  }
  int m = 0;
  for (int i = cur_fib; i > 0; --i) {
    if (n >= fib[i]) {
      n -= fib[i];
      A[m++] = i;
    }
  }
  A[m] = 0;

  dyn1[m] = 1, dyn2[m] = 0;
  for (int i = m - 1; i >= 0; --i) {
    dyn1[i] = dyn1[i + 1] + dyn2[i + 1];
    dyn2[i] = (A[i] - A[i + 1] - 1) / 2 * dyn1[i + 1] + (A[i] - A[i + 1]) / 2 * dyn2[i + 1];
  }

  return dyn1[0] + dyn2[0];
}

int main()
{
  fib[0] = fib[1] = 1;
  for (int i = 2; i < max_fib; ++i) {
    fib[i] = fib[i - 1] + fib[i - 2];
  }

  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    ll n;
    cin >> n;
    cout << solve(n) << '\n';
  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,int> gr;
ll hi = 1000000000;
ll f[105];
int main()
{
hi = hi * hi;
gr[0] = 0;
f[1] = 1; f[2] = 2;
int i;
gr[1] = 1;
gr[2] = 2;
for(i=3;;i++)
{
f[i] = f[i-1] + f[i-2];
if(f[i] >hi)break;
gr[f[i]] = i;
}
//printf("total %d les than %lld\n",i,hi);
int t;
scanf("%d",&t);
while(t--)
{
int j;
vector<ll> v;
j = i-1;
ll n;
cin>>n;
ll m = n;
//printf("%lld = ",n);
while(m)
{
if(f[j] <=m){
v.push_back(f[j]);
m-=f[j];
}
j--;
}
v.push_back(0);
//for(j=0;j<v.size();j++)
//printf("%lld ",v[j]);
//printf("\n");
ll ans = 1;
int l = v.size();
for(j=0;j<l-1;j++)
{
int w = gr[v[j]] - gr[v[j+1]];
//printf("w is %d\n",w);
ans = ans*(w+1)/2;
//printf("count way of %lld greater than %lld\n",v[j],v[j+1]);
}
cout<<ans<<endl;
}

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,int> gr;
ll hi = 1000000000;
ll f[105];
int di[105];
ll taken[105],nottaken[105];
int main()
{
hi = hi * hi;
gr[0] = 0;
f[1] = 1; f[2] = 2;
int i;
gr[1] = 1;
gr[2] = 2;
for(i=3;;i++)
{
f[i] = f[i-1] + f[i-2];
if(f[i] >hi)break;
gr[f[i]] = i;
}
//printf("total %d les than %lld\n",i,hi);
int t;
scanf("%d",&t);
while(t--)
{
int j;
vector<ll> v;
j = i-1;
ll n;
cin>>n;
ll m = n;
//printf("%lld = ",n);

for(j=86;j>=0;j--)
{
di[j] = 0;
if(f[j]<=m){
di[j] = 1;
m-=f[j];
}
}
taken[0] = 1;
nottaken[0] = 0;
int last = 0;
int l = 0;
for(j=1;j<=86;j++)
{
l++;
if(di[j])
{
//printf("taking %lld\n",f[j]);
taken[i] = taken[last] + nottaken[last];
nottaken[i] = taken[last]*(l-1)/2 + nottaken[last]*(l/2);
l = 0;
last = i;
}
}
cout<<taken[last] + nottaken[last]<<endl;
}

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,int> gr;
ll hi = 1000000000;
ll f[105];
int di[105];
ll taken[105],nottaken[105];
int main()
{
hi = hi * hi;
gr[0] = 0;
f[1] = 1; f[2] = 2;
int i;
gr[1] = 1;
gr[2] = 2;
for(i=3;;i++)
{
f[i] = f[i-1] + f[i-2];
if(f[i] >hi)break;
gr[f[i]] = i;
}
//printf("total %d les than %lld\n",i,hi);
int t;
scanf("%d",&t);
while(t--)
{
int j;
vector<ll> v;
j = i-1;
ll n;
cin>>n;
ll m = n;
//printf("%lld = ",n);

for(j=86;j>=0;j--)
{
di[j] = 0;
if(f[j]<=m){
di[j] = 1;
m-=f[j];
}
}
taken[0] = 1;
nottaken[0] = 0;
int last = 0;
int l = 0;
for(j=1;j<=86;j++)
{
l++;
if(di[j])
{
//printf("taking %lld\n",f[j]);
taken[j] = taken[last] + nottaken[last];
nottaken[j] = taken[last]*((l-1)/2) + nottaken[last]*(l/2);
l = 0;
last = j;
}
}
cout<<taken[last] + nottaken[last]<<endl;
}

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,int> gr;
ll hi = 1000000000;
ll f[105];
int main()
{
hi = hi * hi;
gr[0] = 0;
f[1] = 1; f[2] = 2;
int i;
gr[1] = 1;
gr[2] = 2;
for(i=3;;i++)
{
f[i] = f[i-1] + f[i-2];
if(f[i] >hi)break;
gr[f[i]] = i;
}
//printf("total %d les than %lld\n",i,hi);
int t;
scanf("%d",&t);
while(t--)
{
int j;
vector<ll> v;
j = i-1;
ll n;
cin>>n;
ll m = n;
//printf("%lld = ",n);
while(m)
{
if(f[j] <=m){
v.push_back(f[j]);
m-=f[j];
}
j--;
}
v.push_back(0);
//for(j=0;j<v.size();j++)
//printf("%lld ",v[j]);
//printf("\n");
ll ans = 1;
int l = v.size();
for(j=0;j<l-1;j++)
{
int w = gr[v[j]] - gr[v[j+1]];
//printf("w is %d\n",w);
if(v[j]!=2)
ans = ans*(w+1)/2;
//printf("count way of %lld greater than %lld\n",v[j],v[j+1]);
}
cout<<ans<<endl;
}

}


#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef __int64 LL;
LL biao[70];
void init(){
    biao[0]=1;biao[1]=2;
    for(int i=2;i<=60;i++){
        biao[i]=biao[i-1]+biao[i-2];
    }
    //printf("%I64d %I64d\n",biao[30],biao[60]);
}
LL dp[70][2];
int num[70];

int main(){
    #ifdef DouBi
    freopen("in.cpp","r",stdin);
    #endif // DouBi
    init();
    int T;scanf("%d",&T);
    while(T--){
        LL a;scanf("%I64d",&a);
        for(int i=60;i>=0;i--){
            if(a>=biao[i]){
                num[i]=1;
                a-=biao[i];
            }
            else {
                num[i]=0;
            }
        }
        memset(dp,-1,sizeof(dp));
        int pre=-1;
        LL ans=1;
        for(int i=0;i<=60;i++){
            if(num[i]){
                //printf("%d ",i);
                ans=ans*(1+(i-pre-1)/2);
                pre=i;
            }
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef __int64 LL;
LL biao[100];
void init(){
    biao[0]=1;biao[1]=2;
    for(int i=2;i<=90;i++){
        biao[i]=biao[i-1]+biao[i-2];
    }
    //printf("%I64d %I64d\n",biao[30],biao[90]);
}
LL dp[100][2];
int num[100];

int main(){
    #ifdef DouBi
    freopen("in.cpp","r",stdin);
    #endif // DouBi
    init();
    int T;scanf("%d",&T);
    while(T--){
        LL a;scanf("%I64d",&a);
        for(int i=90;i>=0;i--){
            if(a>=biao[i]){
                num[i]=1;
                a-=biao[i];
            }
            else {
                num[i]=0;
            }
        }
        memset(dp,-1,sizeof(dp));
        int pre=-1;
        LL ans1=1,ans2=0;
        for(int i=0;i<=90;i++){
            if(num[i]){
                LL tmp=ans1;
                ans1+=ans2;
                ans2=(i-pre-1)/2*tmp+(i-pre)/2*ans2;
                pre=i;
                //printf("%d %I64d %I64d\n",i,ans1,ans2);
            }
        }
        printf("%I64d\n",ans1+ans2);
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef __int64 LL;
LL biao[70];
void init(){
    biao[0]=1;biao[1]=2;
    for(int i=2;i<=60;i++){
        biao[i]=biao[i-1]+biao[i-2];
    }
    //printf("%I64d %I64d\n",biao[30],biao[60]);
}
LL dp[70][2];
int num[70];

int main(){
    #ifdef DouBi
    freopen("in.cpp","r",stdin);
    #endif // DouBi
    init();
    int T;scanf("%d",&T);
    while(T--){
        LL a;scanf("%I64d",&a);
        for(int i=60;i>=0;i--){
            if(a>=biao[i]){
                num[i]=1;
                a-=biao[i];
            }
            else {
                num[i]=0;
            }
        }
        memset(dp,-1,sizeof(dp));
        int pre=-1;
        LL ans1=1,ans2=0;
        for(int i=0;i<=60;i++){
            if(num[i]){
                LL tmp=ans1;
                ans1+=ans2;
                ans2=(i-pre-1)/2*tmp+(i-pre)/2*ans2;
                pre=i;
                //printf("%d %I64d %I64d\n",i,ans1,ans2);
            }
        }
        printf("%I64d\n",ans1+ans2);
    }
    return 0;
}


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

using namespace std;

typedef long long ll ;

ll n , d1 , d2 ;
vector<ll> fib ;

int main()
{
    fib.push_back(1LL);
    fib.push_back(2LL);
    while (fib[fib.size()-1] < (ll)1e18)
    {
        ll temp = fib[fib.size()-1] + fib[fib.size()-2] ;
        fib.push_back(temp) ;
    }
    int _;
    scanf("%d",&_);
    while (_--)
    {
        cin >> n ;
        vector<int> pos ;
        for (int i = fib.size()-1 ; i >= 0 ; i--)
            if (n >= fib[i])
            {
                pos.push_back(i) ;
                n -= fib[i] ;
            }
        int las = -1 ;
        d1 = 1LL ; d2 = 0LL ;
        for (int i = pos.size()-1 ; i >= 0 ; i--){

            ll t1 = d1 + d2 ;
            ll t2 = d2 * ((pos[i]-las) / 2) + d1 * ((pos[i]-las-1) / 2) ;
            d1 = t1 ; d2 = t2 ;
            las = pos[i] ;
        }
        cout << d1 + d2 << endl ;
    }
    return 0 ;
}


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

using namespace std;

typedef long long ll ;

ll n , res ;
vector<ll> fib ;

int main()
{
    fib.push_back(1LL);
    fib.push_back(2LL);
    while (fib[fib.size()-1] < (ll)1e18)
    {
        ll temp = fib[fib.size()-1] + fib[fib.size()-2] ;
        fib.push_back(temp) ;
    }
    int _;
    scanf("%d",&_);
    while (_--)
    {
        cin >> n ;
        vector<int> pos ;
        for (int i = fib.size()-1 ; i >= 0 ; i--)
            if (n >= fib[i])
            {
                pos.push_back(i) ;
                n -= fib[i] ;
            }
        ll res = 1LL ;
        pos.push_back(-1) ;
        for (int i = 1 ; i < pos.size() ; i++)
            res = res * ( (pos[i-1] - pos[i] - 1) / 2 + 1) ;
        cout << res << endl ;
    }
    return 0 ;
}


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

using namespace std;

typedef long long ll ;

ll n , d1 , d2 ;
vector<ll> fib ;

int main()
{
    fib.push_back(1LL);
    fib.push_back(2LL);
    while (fib[fib.size()-1] < (ll)1e18)
    {
        ll temp = fib[fib.size()-1] + fib[fib.size()-2] ;
        fib.push_back(temp) ;
    }
    int _;
    scanf("%d",&_);
    while (_--)
    {
        cin >> n ;
        vector<int> pos ;
        for (int i = fib.size()-1 ; i >= 0 ; i--)
            if (n >= fib[i])
            {
                pos.push_back(i) ;
                n -= fib[i] ;
            }
        int las = 0 ;
        d1 = 1LL ; d2 = 0LL ;
        for (int i = pos.size()-1 ; i >= 0 ; i--){

            ll t1 = d1 + d2 ;
            ll t2 = d2 * (pos[i]-las) / 2 + d1 * (pos[i]-las-1) / 2 ;
            d1 = t1 ; d2 = t2 ;
            las = pos[i] ;
        }
        cout << d1 + d2 << endl ;
    }
    return 0 ;
}


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

using namespace std;

typedef long long ll ;

ll n , d1 , d2 ;
vector<ll> fib ;

int main()
{
    fib.push_back(1LL);
    fib.push_back(2LL);
    while (fib[fib.size()-1] < (ll)1e18)
    {
        ll temp = fib[fib.size()-1] + fib[fib.size()-2] ;
        fib.push_back(temp) ;
    }
    int _;
    scanf("%d",&_);
    while (_--)
    {
        cin >> n ;
        vector<int> pos ;
        for (int i = fib.size()-1 ; i >= 0 ; i--)
            if (n >= fib[i])
            {
                pos.push_back(i) ;
                n -= fib[i] ;
            }
        int las = -1 ;
        d1 = 1LL ; d2 = 0LL ;
        for (int i = pos.size()-1 ; i >= 0 ; i--){

            ll t1 = d1 + d2 ;
            ll t2 = d2 * (pos[i]-las) / 2 + d1 * (pos[i]-las-1) / 2 ;
            d1 = t1 ; d2 = t2 ;
            las = pos[i] ;
        }
        cout << d1 + d2 << endl ;
    }
    return 0 ;
}


/*
��һ�ַ�����ʱ�ˡ�
��ʵ�϶���n,���ǿ��Կ������fibonacci��ʽ����Ψһ��)
����˵13��Ӧ
000001
Ҫ��ľ����ж�����01���У�����11->001�Ĳ������Ա䵽000001ȥ��
��ô��ת��f[i] = 1(ֱ��ѡ��iλ) + f[i-2](ѡ��i-1λ,��i-2λ�ճ���)
��ӦnҲ�������ƴ���
f[i][j]:����s[1..i]��01���У�ͬʱ��iλ��Ҫ�Ӹ�1�ķ�����
f[i][1] = f[i-2][1] or 0(s[i] = 1, s[i-1] = 0/1)
		= f[i-1][0](ֱ��+��1) + (��i-1λ+��1������Ҫ��s[i-1]=0) f[i-2][1]
f[i][0] = (s[i] = 0) f[i-1][0]
		= (s[i] = 1) f[i-1][0] + (��i-1λ+��1������Ҫ��s[i-1]=0) f[i-2][1]
*/
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long LL;
const LL lim = 1000000000000000000LL;
const int maxN = 90;

LL f[maxN];
int st[maxN], T;
LL dp[maxN][2], n;

int main()
{
	f[0] = f[1] = 1;
	for(int i = 2; i < maxN; ++i) {
		f[i] = f[i-1] + f[i-2];
		if(f[i] > lim + 5) f[i] = lim + 5;
	}
	scanf("%d", &T);
	while(T--) {
		scanf("%I64d", &n);
		for(int i = maxN-1; i > 0; --i)
			if(f[i] <= n) {
				st[i] = 1;
				n -= f[i];
			} else
				st[i] = 0;
		dp[0][1] = 0; dp[0][0] = 1;
		dp[1][1] = (st[1] == 0);
		dp[1][0] = 1;
		for(int i = 2; i < maxN; ++i) {
			if(st[i] == 1) {
				if(st[i-1] == 0) dp[i][1] = dp[i-2][1];
				else dp[i][1] = 0;
				dp[i][0] = dp[i-1][0];
				if(st[i-1]==0)
					dp[i][0] += dp[i-2][1];
			} else {
				dp[i][1] = dp[i-1][0];
				if(st[i-1] == 0)
					dp[i][1] += dp[i-2][1];
				dp[i][0] = dp[i-1][0];
			}
		}
		printf("%I64d\n", dp[maxN-1][0]);
	}
	return 0;
}


/*
��n<=10^18,��n�ж�����fibonacci�ֽ���ʽ��(ÿ����ͬ)
��13 = 13, 5 + 8, 2 + 3 + 8����
sol��
��Ū��fib[0..64]
����nö������f[i],��Ȼf[i]>=n/2��ע����ʱӦ�ü�¼һ���Ͻ����j����
���Ӷ�Ϊ64*64*64
*/
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
const LL lim = 1000000000000000000LL;
int T, nn;
LL f[100];
LL n;

LL solve(LL sum, int upper)
{
	if(sum == 0) return 1;
	if(sum > 0 && upper == 0) return 0;
	LL res = 0;
	for(int i = upper; i >= 1; --i) {
		if(f[i] > sum) continue;
		if(f[i] * 2 < sum) break;
		res += solve(sum - f[i], i-1);
	}
	return res;
}

int main()
{
	f[0] = f[1] = 1;
	for(int i = 2; i < 100; ++i) {
		f[i] = f[i-1] + f[i-2];
		if(f[i] >= lim) {
			nn = i;
			break;
		}
	}
	scanf("%d", &T);
	for(int i = 0; i < T; ++i) {
		scanf("%I64d", &n);
		printf("%I64d\n", solve(n, nn));
	}

	return 0 ;
}


/*
��n<=10^18,��n�ж�����fibonacci�ֽ���ʽ��(ÿ����ͬ)
��13 = 13, 5 + 8, 2 + 3 + 8����
sol��
��Ū��fib[0..64]
����nö������f[i],��Ȼf[i]>=n/2��ע����ʱӦ�ü�¼һ���Ͻ����j����
���Ӷ�Ϊ64*64*64
*/
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
const LL lim = 1000000000000000000LL;
int T, nn;
LL f[100], s[100];
LL n;

LL solve(LL sum, int upper)
{
	if(sum == 0) return 1;
	if(sum > 0 && upper == 0) return 0;
	LL res = 0;
	for(int i = upper; i >= 1; --i) {
		if(f[i] > sum) continue;
		if(s[i] < sum) break;
		res += solve(sum - f[i], i-1);
	}
	return res;
}

int main()
{
	f[0] = f[1] = 1;
	s[1] = 1;
	for(int i = 2; i < 100; ++i) {
		f[i] = f[i-1] + f[i-2];
		s[i] = s[i-1] + f[i];
		if(s[i] > lim) s[i] = lim;
		if(f[i] >= lim) {
			nn = i;
			break;
		}
	}
	scanf("%d", &T);
	for(int i = 0; i < T; ++i) {
		scanf("%I64d", &n);
		printf("%I64d\n", solve(n, nn));
	}

	return 0 ;
}


/*
��n<=10^18,��n�ж�����fibonacci�ֽ���ʽ��(ÿ����ͬ)
��13 = 13, 5 + 8, 2 + 3 + 8����
sol��
��Ū��fib[0..64]
����nö������f[i],��Ȼs[i] >= n(f[1]+f[2]+...+f[n])��ע����ʱӦ�ü�¼һ���Ͻ����j����
���Ӷ�Ϊ64*64*64
*/
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
const LL lim = 1000000000000000000LL;
const int maxN = 1000000;

int T, nn;
LL f[100], s[100];
LL n;
LL ret[maxN][30];

LL solve(LL sum, int upper)
{
	if(sum == 0) return 1;
	if(sum > 0 && upper == 0) return 0;
	if(s[upper] < sum) return 0;
	if(s[upper] == sum) return 1;
	if(sum < maxN && upper < 30 && ret[sum][upper] > 0) return ret[sum][upper];
	LL res = 0;
	for(int i = upper; i >= 1; --i) {
		if(f[i] > sum) continue;
		if(s[i] < sum) break;
		res += solve(sum - f[i], i-1);
	}
	if(sum < maxN && upper < 30) ret[sum][upper] = res;
	return res;
}

int main()
{
	f[0] = f[1] = 1;
	s[1] = 1;
	for(int i = 2; i < 100; ++i) {
		f[i] = f[i-1] + f[i-2];
		s[i] = s[i-1] + f[i];
		if(s[i] > lim+5) s[i] = lim+5;
		if(f[i] >= lim) {
			nn = i;
			break;
		}
	}
	scanf("%d", &T);
	for(int i = 0; i < T; ++i) {
		scanf("%I64d", &n);
		printf("%I64d\n", solve(n, nn));
	}
	return 0 ;
}


/*
��һ�ַ�����ʱ�ˡ�
��ʵ�϶���n,���ǿ��Կ������fibonacci��ʽ����Ψһ��)
����˵13��Ӧ
000001
Ҫ��ľ����ж�����01���У�����11->001�Ĳ������Ա䵽000001ȥ��
��ô��ת��f[i] = 1(ֱ��ѡ��iλ) + f[i-2](ѡ��i-1λ,��i-2λ�ճ���)
��ӦnҲ�������ƴ���
f[i][j]:����s[1..i]��01���У�ͬʱ��iλ��Ҫ�Ӹ�1�ķ�����
f[i][1] = 0(s[i] = 1)
		= f[i-1][0](ֱ��+��1) + (��i-1λ+��1������Ҫ��s[i-1]=0) f[i-2][1]
f[i][0] = (s[i] = 0) f[i-1][0]
		= (s[i] = 1) f[i-1][0] + (��i-1λ+��1������Ҫ��s[i-1]=0) f[i-2][1]
*/
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long LL;
const LL lim = 1000000000000000000LL;
const int maxN = 90;

LL f[maxN];
int st[maxN], T;
LL dp[maxN][2], n;

int main()
{
	f[0] = f[1] = 1;
	for(int i = 2; i < maxN; ++i) {
		f[i] = f[i-1] + f[i-2];
		if(f[i] > lim + 5) f[i] = lim + 5;
	}
	scanf("%d", &T);
	while(T--) {
		scanf("%I64d", &n);
		for(int i = maxN-1; i > 0; --i)
			if(f[i] <= n) {
				st[i] = 1;
				n -= f[i];
			} else
				st[i] = 0;
		dp[0][1] = 0; dp[0][0] = 1;
		dp[1][1] = (st[1] == 0);
		dp[1][0] = 1;
		for(int i = 2; i < maxN; ++i) {
			if(st[i] == 1) {
				dp[i][1] = 0;
				dp[i][0] = dp[i-1][0];
				if(st[i-1]==0)
					dp[i][0] += dp[i-2][1];
			} else {
				dp[i][1] = dp[i-1][0];
				if(st[i-1] == 0)
					dp[i][1] += dp[i-2][1];
				dp[i][0] = dp[i-1][0];
			}
		}
		printf("%I64d\n", dp[maxN-1][0]);
	}
	return 0;
}


/*
��n<=10^18,��n�ж�����fibonacci�ֽ���ʽ��(ÿ����ͬ)
��13 = 13, 5 + 8, 2 + 3 + 8����
sol��
��Ū��fib[0..64]
����nö������f[i],��Ȼs[i] >= n(f[1]+f[2]+...+f[n])��ע����ʱӦ�ü�¼һ���Ͻ����j����
���Ӷ�Ϊ64*64*64
*/
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
const LL lim = 1000000000000000000LL;
const int maxN = 10000000;

int T, nn;
LL f[100], s[100];
LL n;
LL ret[maxN];

LL solve(LL sum, int upper)
{
	if(sum == 0) return 1;
	if(sum > 0 && upper == 0) return 0;
	if(s[upper] < sum) return 0;
	if(s[upper] == sum) return 1;
	if(sum < maxN && ret[sum] > 0) return ret[sum];
	LL res = 0;
	for(int i = upper; i >= 1; --i) {
		if(f[i] > sum) continue;
		if(s[i] < sum) break;
		res += solve(sum - f[i], i-1);
	}
	if(sum < maxN) ret[sum] = res;
	return res;
}

int main()
{
	f[0] = f[1] = 1;
	s[1] = 1;
	for(int i = 2; i < 100; ++i) {
		f[i] = f[i-1] + f[i-2];
		s[i] = s[i-1] + f[i];
		if(s[i] > lim+5) s[i] = lim+5;
		if(f[i] >= lim) {
			nn = i;
			break;
		}
	}
	scanf("%d", &T);
	for(int i = 0; i < T; ++i) {
		scanf("%I64d", &n);
		printf("%I64d\n", solve(n, nn));
	}

	return 0 ;
}


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<String> strings = new ArrayList<String>();
        int id = 0, max = 0;
        while (scanner.hasNextLine()) {
            strings.add(scanner.nextLine());
            max = Math.max(max, strings.get(id).length());
            //System.out.println(max);
            id++;
        }

      /*  for (int i = 0; i <= max + 1; i++) {
            System.out.print("*");
            //System.out.println("holla");
        }*/
        boolean chooseLeft = true;
        System.out.println();
        for (int i = 0; i < id; i++) {
            System.out.print("*");
            int len = strings.get(i).length();
            int pos = (max - len);
            if (pos % 2 != 0) {
                pos /= 2;
                if (chooseLeft) {
                    //pos--;
                    chooseLeft = !chooseLeft;
                } else {
                    pos++;
                    chooseLeft = !chooseLeft;
                }
            }
            else pos /= 2;
            for (int j = 0; j < pos; j++) System.out.print(" ");
            System.out.print(strings.get(i));
            for (int j = pos + len - 1; j < max - 1; j++) System.out.print(" ");
            System.out.println("*");
        }
        for (int i = 0; i <= max + 1; i++) System.out.print("*");
    }
}


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<String> strings = new ArrayList<>();
        int id = 0, max = 0;
        while (scanner.hasNextLine()) {
            strings.add(scanner.nextLine());
            max = Math.max(max, strings.get(id).length());
            id++;
        }

        for (int i = 0; i <= max + 1; i++) System.out.print("*");
        boolean chooseLeft = true;
        System.out.println();
        for (int i = 0; i < id; i++) {
            System.out.print("*");
            int pos = (max - strings.get(i).length());
            if (pos % 2 != 0) pos = pos / 2 + 1;
            else pos /= 2;
            if (max - 2 * pos - strings.get(i).length() != 0) {
                if (chooseLeft) {
                    pos--;
                    chooseLeft = !chooseLeft;
                } else {
                    //pos++;
                    chooseLeft = !chooseLeft;
                }
            }
            for (int j = 0; j < pos; j++) System.out.print(" ");
            System.out.print(strings.get(i));
            for (int j = pos + strings.get(i).length() - 1; j < max - 1; j++) System.out.print(" ");
            System.out.println("*");
        }
        for (int i = 0; i <= max + 1; i++) System.out.print("*");
    }
}


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<String> strings = new ArrayList<>();
        int id = 0, max = 0;
        while (scanner.hasNextLine()) {
            strings.add(scanner.nextLine());
            max = Math.max(max, strings.get(id).length());
            id++;
        }

        for (int i = 0; i <= max + 1; i++) {
            System.out.print("*");
            //System.out.println("holla");
        }
        boolean chooseLeft = true;
        System.out.println();
        for (int i = 0; i < id; i++) {
            System.out.print("*");
            int pos = (max - strings.get(i).length());
            if (pos % 2 != 0) pos = pos / 2 + 1;
            else pos /= 2;
            if (max - 2 * pos - strings.get(i).length() != 0) {
                if (chooseLeft) {
                    pos--;
                    chooseLeft = !chooseLeft;
                } else {
                    //pos++;
                    chooseLeft = !chooseLeft;
                }
            }
            for (int j = 0; j < pos; j++) System.out.print(" ");
            System.out.print(strings.get(i));
            for (int j = pos + strings.get(i).length() - 1; j < max - 1; j++) System.out.print(" ");
            System.out.println("*");
        }
        for (int i = 0; i <= max + 1; i++) System.out.print("*");
    }
}


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<String> strings = new ArrayList<String>();
        int id = 0, max = 0;
        while (scanner.hasNextLine()) {
            strings.add(scanner.nextLine());
            max = Math.max(max, strings.get(id).length());
            id++;
        }

        for (int i = 0; i <= max + 1; i++) {
            System.out.print("*");
            //System.out.println("holla");
        }
        boolean chooseLeft = true;
        System.out.println();
        for (int i = 0; i < id; i++) {
            System.out.print("*");
            int len = strings.get(i).length();
            int pos = (max - len);
            if (pos % 2 != 0) {
                pos /= 2;
                if (chooseLeft) {
                    //pos--;
                    chooseLeft = !chooseLeft;
                } else {
                    pos++;
                    chooseLeft = !chooseLeft;
                }
            }
            else pos /= 2;
            for (int j = 0; j < pos; j++) System.out.print(" ");
            System.out.print(strings.get(i));
            for (int j = pos + len - 1; j < max - 1; j++) System.out.print(" ");
            System.out.println("*");
        }
        for (int i = 0; i <= max + 1; i++) System.out.print("*");
    }
}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        ArrayList<String> strings = new ArrayList<String>();
        int id = 0, max = 0;
        while (scanner.hasNextLine()) {
            strings.add(scanner.nextLine());
            max = Math.max(max, strings.get(id).length());
            //System.out.println(max);
            id++;
        }

        for (int i = 0; i <= max + 1; i++) {
            pw.print("*");
            //System.out.println("holla");
        }
        boolean chooseLeft = true;
        pw.println();
        for (int i = 0; i < id; i++) {
            pw.print("*");
            int len = strings.get(i).length();
            int pos = (max - len);
            if (pos % 2 != 0) {
                pos /= 2;
                if (chooseLeft) {
                    //pos--;
                    chooseLeft = !chooseLeft;
                } else {
                    pos++;
                    chooseLeft = !chooseLeft;
                }
            }
            else pos /= 2;
            for (int j = 0; j < pos; j++) pw.print(" ");
            pw.print(strings.get(i));
            for (int j = pos + len - 1; j < max - 1; j++) pw.print(" ");
            pw.println("*");
        }
        for (int i = 0; i <= max + 1; i++) pw.print("*");
        pw.close();
    }
}


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<String> strings = new ArrayList<>();
        int id = 0, max = 0;
        while (scanner.hasNextLine()) {
            strings.add(scanner.nextLine());
            max = Math.max(max, strings.get(id).length());
            id++;
        }

        for (int i = 0; i <= max + 1; i++) {
            System.out.print("*");
            //System.out.println("holla");
        }
        boolean chooseLeft = true;
        System.out.println();
        for (int i = 0; i < id; i++) {
            System.out.print("*");
            int len = strings.get(i).length();
            int pos = (max - len);
            if (pos % 2 != 0) pos = pos / 2 + 1;
            else pos /= 2;
            if (max - 2 * pos - len != 0) {
                if (chooseLeft) {
                    pos--;
                    chooseLeft = !chooseLeft;
                } else {
                    //pos++;
                    chooseLeft = !chooseLeft;
                }
            }
            for (int j = 0; j < pos; j++) System.out.print(" ");
            System.out.print(strings.get(i));
            for (int j = pos + len - 1; j < max - 1; j++) System.out.print(" ");
            System.out.println("*");
        }
        for (int i = 0; i <= max + 1; i++) System.out.print("*");
    }
}


import java.util.Scanner;

import java.util.List;

import java.util.ArrayList;

public class b {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    List<String> msg = new ArrayList<>();

    int maxLength = 0;

    while (sc.hasNextLine()) {

      String line = sc.nextLine();

      maxLength = Math.max(maxLength, line.length());

      msg.add(line);

    }

    int blockLength = maxLength + 2;

    int placeLeft = 1;

    System.out.println(repeat('*', blockLength));

    for (String line: msg) {

      int whitespaces = maxLength - line.length();

      if (whitespaces % 2 == 0) {

        System.out.print('*' + repeat(' ', whitespaces / 2));

        System.out.print(line);

        System.out.println(repeat(' ', whitespaces / 2) + '*');

      } else {

        int alignLeft, alignRight;

        if (placeLeft > 0) {

          alignLeft = whitespaces / 2;

          alignRight = whitespaces - alignLeft;

        } else {

          alignRight = whitespaces / 2;

          alignLeft = whitespaces - alignRight;

        }

        System.out.print('*' + repeat(' ', alignLeft));

        System.out.print(line);

        System.out.println(repeat(' ', alignRight) + '*');

        placeLeft = 1 - placeLeft;

      }

    }

    System.out.println(repeat('*', blockLength));

  }

  private static String repeat(char chr, int n) {

    char[] chars = new char[n];

    for (int i = 0; i < n; ++i) {

      chars[i] = chr;

    }

    return new String(chars);

  }

}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<String> lineList = new ArrayList<>();

		String line;
		int maxLength = 0;

		while ((line = br.readLine()) != null) {
			lineList.add(line);
			if (maxLength < line.length())
				maxLength = line.length();
		}

		boolean blockEven = false;
		boolean lineEven = false;
		int counter = 1;

		if (maxLength % 2 == 0)
			blockEven = true;

		// print out first line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
		System.out.println();

		// print each line of output strings
		for(int i = 0; i < lineList.size(); i++){

			boolean roundLeft = true;

			if (counter % 2 == 0)
				roundLeft = false;

			if (lineList.get(i).length() % 2 == 0)
				lineEven = true;

			int leadSpaces = (maxLength - lineList.get(i).length()) / 2;
			int trailSpaces = leadSpaces;

			System.out.print("*");

			// print leading spaces
			if (lineEven == blockEven){
				for (int j = 0; j < leadSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < leadSpaces + (roundLeft ? 0 : 1); j++)
					System.out.print(" ");
			}

			// print string
			System.out.print(lineList.get(i));

			// print trailing spaces
			if (lineEven == blockEven){
				for (int j = 0; j < trailSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < trailSpaces + (roundLeft ? 1 : 0); j++)
					System.out.print(" ");
				counter++;
			}

			System.out.print("*");
			System.out.println();

			lineEven = false;
		}

		// print out last line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<String> lineList = new ArrayList<>();

		String line;
		int maxLength = 0;

		while ((line = br.readLine()) != null) {
			lineList.add(line);
			if (maxLength < line.length())
				maxLength = line.length();
		}

		boolean blockEven = false;
		boolean lineEven = false;
		int counter = 1;

		if (maxLength % 2 == 0)
			blockEven = true;

		// print out first line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
		System.out.println();

		// print each line of output strings
		for(int i = 0; i < lineList.size(); i++){

			boolean roundLeft = true;
			if (counter % 2 == 0)
				roundLeft = false;

			if (lineList.get(i).length() % 2 == 0)
				lineEven = true;

			int leadSpaces = (maxLength - lineList.get(i).length()) / 2;
			int trailSpaces = leadSpaces;

			System.out.print("*");

			// print leading spaces
			if (lineEven == blockEven){
				for (int j = 0; j < leadSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven && roundLeft){
				//for (int j = 0; j < leadSpaces + (roundLeft ? 0 : 1); j++)
				for (int j = 0; j < leadSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven && !roundLeft){
				//for (int j = 0; j < leadSpaces + (roundLeft ? 0 : 1); j++)
				for (int j = 0; j < leadSpaces + 1; j++)
					System.out.print(" ");
			}
			// print string
			System.out.print(lineList.get(i));

			// print trailing spaces
			if (lineEven == blockEven){
				for (int j = 0; j < trailSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven && roundLeft){
				//for (int j = 0; j < trailSpaces + (roundLeft ? 1 : 0); j++)
				for (int j = 0; j < trailSpaces + 1; j++)
					System.out.print(" ");
				counter++;
			}
			if (lineEven != blockEven && !roundLeft){
				//for (int j = 0; j < trailSpaces + (roundLeft ? 1 : 0); j++)
				for (int j = 0; j < trailSpaces; j++)
					System.out.print(" ");
				counter++;
			}

			System.out.print("*");
			System.out.println();

			lineEven = false;
		}

		// print out last line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<String> lineList = new ArrayList<>();

		String line;
		int maxLength = 0;

		while ((line = br.readLine()) != null) {
			lineList.add(line);
			if (maxLength < line.length())
				maxLength = line.length();
		}

		boolean blockEven = false;
		boolean lineEven = false;
		int counter = 1;

		if (maxLength % 2 == 0)
			blockEven = true;

		/*// print out first line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
		System.out.println();
		*/
		String block;
		char[] c = new char[maxLength + 2];
		Arrays.fill(c, '*');
		block = new String(c);
		System.out.println(block);

		// print each line of output strings
		for(int i = 0; i < lineList.size(); i++){

			boolean roundLeft = true;

			if (counter % 2 == 0)
				roundLeft = false;

			if (lineList.get(i).length() % 2 == 0)
				lineEven = true;

			int leadSpaces = (maxLength - lineList.get(i).length()) / 2;
			int trailSpaces = leadSpaces;

			System.out.print("*");

			// print leading spaces
			if (lineEven == blockEven){
				for (int j = 0; j < leadSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < leadSpaces + (roundLeft ? 0 : 1); j++)
					System.out.print(" ");
			}

			// print string
			System.out.print(lineList.get(i));

			// print trailing spaces
			if (lineEven == blockEven){
				for (int j = 0; j < trailSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < trailSpaces + (roundLeft ? 1 : 0); j++)
					System.out.print(" ");
				counter++;
			}

			System.out.print("*");
			System.out.println();

			lineEven = false;
		}

		/*// print out last line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
		*/
		System.out.println(block);
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out = new StringBuilder();
		List<String> lineList = new ArrayList<>();

		String line;
		int maxLength = 0;

		while ((line = br.readLine()) != null) {
			lineList.add(line);
			if (maxLength < line.length())
				maxLength = line.length();
		}

		boolean blockEven = false;
		boolean lineEven = false;
		int counter = 1;

		if (maxLength % 2 == 0)
			blockEven = true;

		// print out first line of output block
		for(int i = 0; i < maxLength + 2; i++)
			out.append("*");
		out.append("\n");
		//System.out.print(out.toString());

		// print each line of output strings
		for(int i = 0; i < lineList.size(); i++){

			boolean roundLeft = true;

			if (counter % 2 == 0)
				roundLeft = false;

			if (lineList.get(i).length() % 2 == 0)
				lineEven = true;

			int leadSpaces = (maxLength - lineList.get(i).length()) / 2;
			int trailSpaces = leadSpaces;

			out.append("*");

			// print leading spaces
			if (lineEven == blockEven){
				for (int j = 0; j < leadSpaces; j++)
					out.append(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < leadSpaces + (roundLeft ? 0 : 1); j++)
					out.append(" ");
			}

			// print string
			out.append(lineList.get(i));

			// print trailing spaces
			if (lineEven == blockEven){
				for (int j = 0; j < trailSpaces; j++)
					out.append(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < trailSpaces + (roundLeft ? 1 : 0); j++)
					out.append(" ");
				counter++;
			}

			out.append("*");
			out.append("\n");

			lineEven = false;
		}

		// print out last line of output block
		for(int i = 0; i < maxLength + 2; i++)
			out.append("*");
		System.out.println(out.toString());

	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<String> lineList = new ArrayList<>();

		String line;
		int maxLength = 0;

		while ((line = br.readLine()) != null) {
			lineList.add(line);
			if (maxLength < line.length())
				maxLength = line.length();
		}

		boolean blockEven = false;
		boolean lineEven = false;
		int counter = 1;

		if (maxLength % 2 == 0)
			blockEven = true;

		//System.out.println(blockEven);

		// print out first line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
		System.out.println();

		// print each line of output strings
		for(int i = 0; i < lineList.size(); i++){

			boolean roundLeft = true;
			if (counter % 2 == 0)
				roundLeft = false;

			if (lineList.get(i).length() % 2 == 0)
				lineEven = true;

			int leadSpaces = (maxLength - lineList.get(i).length()) / 2;
			int trailSpaces = leadSpaces;

			System.out.print("*");

			// print leading spaces
			if (lineEven == blockEven){
				for (int j = 0; j < leadSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < leadSpaces + (roundLeft ? 0 : 1); j++)
					System.out.print(" ");
			}

			// print string
			System.out.print(lineList.get(i));

			// print trailing spaces
			if (lineEven == blockEven){
				for (int j = 0; j < trailSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < trailSpaces + (roundLeft ? 1 : 0); j++)
					System.out.print(" ");
					counter++;
			}

			System.out.print("*");
			System.out.println();

			lineEven = false;
		}

		// print out last line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<String> lineList = new ArrayList<>();

		String line;
		int maxLength = 0;

		while ((line = br.readLine()) != null) {
			lineList.add(line);
			if (maxLength < line.length())
				maxLength = line.length();
		}

		boolean blockEven = false;
		boolean lineEven = false;
		int counter = 1;

		if (maxLength % 2 == 0)
			blockEven = true;

		/*// print out first line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
		System.out.println();
		*/
		String block;
		char[] c = new char[maxLength + 2];
		Arrays.fill(c, '*');
		block = new String(cc);
		System.out.println(block);

		// print each line of output strings
		for(int i = 0; i < lineList.size(); i++){

			boolean roundLeft = true;

			if (counter % 2 == 0)
				roundLeft = false;

			if (lineList.get(i).length() % 2 == 0)
				lineEven = true;

			int leadSpaces = (maxLength - lineList.get(i).length()) / 2;
			int trailSpaces = leadSpaces;

			System.out.print("*");

			// print leading spaces
			if (lineEven == blockEven){
				for (int j = 0; j < leadSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < leadSpaces + (roundLeft ? 0 : 1); j++)
					System.out.print(" ");
			}

			// print string
			System.out.print(lineList.get(i));

			// print trailing spaces
			if (lineEven == blockEven){
				for (int j = 0; j < trailSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < trailSpaces + (roundLeft ? 1 : 0); j++)
					System.out.print(" ");
				counter++;
			}

			System.out.print("*");
			System.out.println();

			lineEven = false;
		}

		/*// print out last line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
		*/
		System.out.println(block);
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<String> lineList = new ArrayList<>();

		String line;
		int maxLength = 0;

		while ((line = br.readLine()) != null) {
			lineList.add(line);
			if (maxLength < line.length())
				maxLength = line.length();
		}

		boolean blockEven = false;
		boolean lineEven = false;
		int counter = 1;

		if (maxLength % 2 == 0)
			blockEven = true;

		/*// print out first line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
		System.out.println();
		*/
		char[] c = new char[maxLength + 2];
		Arrays.fill(c, '*');
		block = new String(cc);
		System.out.println(block);

		// print each line of output strings
		for(int i = 0; i < lineList.size(); i++){

			boolean roundLeft = true;

			if (counter % 2 == 0)
				roundLeft = false;

			if (lineList.get(i).length() % 2 == 0)
				lineEven = true;

			int leadSpaces = (maxLength - lineList.get(i).length()) / 2;
			int trailSpaces = leadSpaces;

			System.out.print("*");

			// print leading spaces
			if (lineEven == blockEven){
				for (int j = 0; j < leadSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < leadSpaces + (roundLeft ? 0 : 1); j++)
					System.out.print(" ");
			}

			// print string
			System.out.print(lineList.get(i));

			// print trailing spaces
			if (lineEven == blockEven){
				for (int j = 0; j < trailSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < trailSpaces + (roundLeft ? 1 : 0); j++)
					System.out.print(" ");
				counter++;
			}

			System.out.print("*");
			System.out.println();

			lineEven = false;
		}

		/*// print out last line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
		*/
		System.out.println(block);
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<String> lineList = new ArrayList<>();

		String line;
		int maxLength = 0;

		while ((line = br.readLine()) != null) {
			lineList.add(line);
			if (maxLength < line.length())
				maxLength = line.length();
		}

		boolean blockEven = false;
		boolean lineEven = false;
		int counter = 1;

		if (maxLength % 2 == 0)
			blockEven = true;

		// print out first line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
		System.out.println();

		// print each line of output strings
		for(int i = 0; i < lineList.size(); i++){

			boolean roundLeft = true;
			if (counter % 2 == 0)
				roundLeft = false;

			if (lineList.get(i).length() % 2 == 0)
				lineEven = true;

			int leadSpaces = (maxLength - lineList.get(i).length()) / 2;
			int trailSpaces = leadSpaces;

			System.out.print("*");

			// print leading spaces
			if (lineEven == blockEven){
				for (int j = 0; j < leadSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < leadSpaces + (roundLeft ? 0 : 1); j++)
					System.out.print(" ");
			}

			// print string
			System.out.print(lineList.get(i));

			// print trailing spaces
			if (lineEven == blockEven){
				for (int j = 0; j < trailSpaces; j++)
					System.out.print(" ");
			}
			if (lineEven != blockEven){
				for (int j = 0; j < trailSpaces + (roundLeft ? 1 : 0); j++)
					System.out.print(" ");
					counter++;
			}

			System.out.print("*");
			System.out.println();

			lineEven = false;
		}

		// print out last line of output block
		for(int i = 0; i < maxLength + 2; i++)
			System.out.print("*");
	}
}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class B5 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        List<String> lines = new ArrayList<>();
        int maxWidth = 0;
        while (in.hasNextLine()) {
            String line = in.nextLine();
            if ("-".equals(line)) { // just for local testing
                break;
            }
            maxWidth = Math.max(maxWidth, line.length());
            lines.add(line);
        }
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<maxWidth+2; i++) {
            sb.append('*');
        }
        sb.append('\n');
        boolean left = false;
        for (String line : lines) {
            sb.append('*');
            int space = maxWidth - line.length();
            int leftSpace = space/2;
            int righSpace = leftSpace;
            if (leftSpace + righSpace != space) {
                if (left) {
                    leftSpace++;
                } else {
                    righSpace++;
                }
                left = !left;
            }
            for (int i=0; i<leftSpace; i++) {
                sb.append(' ');
            }
            sb.append(line);
            for (int i=0; i<righSpace; i++) {
                sb.append(' ');
            }
            sb.append('*').append('\n');
        }
        for (int i=0; i<maxWidth+2; i++) {
            sb.append('*');
        }
        System.out.println(sb);
    }

}


import java.io.*;

public class Main {
    static final int N = 1010;
    static String[] arr = new String[N];
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
//        br = new BufferedReader(new InputStreamReader(new FileInputStream("/Users/huangweixuan/testdata.txt")));
        int i = 0, max = 0x80000000;
        String str = "";
        while ((str = br.readLine()) != null) {
            arr[i++] = str;
            if (max < arr[i - 1].length()) {
                max = arr[i - 1].length();
            }
        }
        int j = max + 2, n = i;
        for (i = 0; i < j; ++i) {
            bw.write('*');
        }
        bw.write("\n");
        int tmp = 0, k = 0, d = 0;
        for (i = 0; i < n; ++i) {
            bw.write('*');
            tmp = max - arr[i].length();
            if (tmp == max) {
                for (int k1 = 0; k1 < max; ++k1) {
                    bw.write(" ");
                }
            } else {
                if (tmp % 2 == 0) {
                    k = tmp >> 1;
                    for (int k1 = 0; k1 < k; ++k1) {
                        bw.write(" ");
                    }
                    bw.write(arr[i]);
                    for (int k1 = 0; k1 < k; ++k1) {
                        bw.write(" ");
                    }
                } else {
                    k = (tmp >> 1) + d;
                    for (int k1 = 0; k1 < k; ++k1) {
                        bw.write(" ");
                    }
                    bw.write(arr[i]);
                    k += d == 0 ? 1 : -1;
                    d = d == 0 ? 1 : 0;
                    for (int k1 = 0; k1 < k; ++k1) {
                        bw.write(" ");
                    }
                }
            }
            bw.write('*');
            bw.write("\n");
        }
        for (i = 0; i < j; ++i) {
            bw.write('*');
        }
        bw.close();
    }
}


import java.io.*;
import java.util.*;

public class Main {
    static final int N = 1010;
    static String[] arr = new String[N];
    static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        //        System.setIn(new FileInputStream("/Users/huangweixuan/testdata.txt"));
        Scanner sc = new Scanner(System.in);
        int i = 0, max = 0x80000000;
        while (sc.hasNext()) {
            arr[i++] = sc.nextLine();
            if (max < arr[i - 1].length()) {
                max = arr[i - 1].length();
            }
        }
        int j = max + 2, n = i;
        for (i = 0; i < j; ++i) {
            bw.write('*');
        }
        bw.write("\n");
        int tmp = 0, k = 0, d = 0;
        for (i = 0; i < n; ++i) {
            bw.write('*');
            tmp = max - arr[i].length();
            if (tmp == max) {
                for (int k1 = 0; k1 < max; ++k1) {
                    bw.write(" ");
                }
            } else {
                if (tmp % 2 == 0) {
                    k = tmp >> 1;
                    for (int k1 = 0; k1 < k; ++k1) {
                        bw.write(" ");
                    }
                    bw.write(arr[i]);
                    for (int k1 = 0; k1 < k; ++k1) {
                        bw.write(" ");
                    }
                } else {
                    k = (tmp >> 1) + d;
                    for (int k1 = 0; k1 < k; ++k1) {
                        bw.write(" ");
                    }
                    bw.write(arr[i]);
                    k += d == 0 ? 1 : -1;
                    d = d == 0 ? 1 : 0;
                    for (int k1 = 0; k1 < k; ++k1) {
                        bw.write(" ");
                    }
                }
            }
            bw.write('*');
            bw.write("\n");
        }
        bw.close();
    }
}


import java.io.*;
import java.util.*;

public class Main {
    static final int N = 1010;
    static String[] arr = new String[N];
    static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        //        System.setIn(new FileInputStream("/Users/huangweixuan/testdata.txt"));
        Scanner sc = new Scanner(System.in);
        int i = 0, max = 0x80000000;
        while (sc.hasNext()) {
            arr[i++] = sc.nextLine();
            if (max < arr[i - 1].length()) {
                max = arr[i - 1].length();
            }
        }
        int j = max + 2, n = i;
        for (i = 0; i < j; ++i) {
            bw.write('*');
        }
        bw.write("\n");
        int tmp = 0, k = 0, d = 0;
        for (i = 0; i < n; ++i) {
            bw.write('*');
            tmp = max - arr[i].length();
            if (tmp == max) {
                for (int k1 = 0; k1 < max; ++k1) {
                    bw.write(" ");
                }
            } else {
                if (tmp % 2 == 0) {
                    k = tmp >> 1;
                    for (int k1 = 0; k1 < k; ++k1) {
                        bw.write(" ");
                    }
                    bw.write(arr[i]);
                    for (int k1 = 0; k1 < k; ++k1) {
                        bw.write(" ");
                    }
                } else {
                    k = (tmp >> 1) + d;
                    for (int k1 = 0; k1 < k; ++k1) {
                        bw.write(" ");
                    }
                    bw.write(arr[i]);
                    k += d == 0 ? 1 : -1;
                    d = d == 0 ? 1 : 0;
                    for (int k1 = 0; k1 < k; ++k1) {
                        bw.write(" ");
                    }
                }
            }
            bw.write('*');
            bw.write("\n");
        }
        for (i = 0; i < j; ++i) {
            bw.write('*');
        }
        bw.close();
    }
}


import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.String.*;
import javax.print.DocFlavor;

public class Main {

    public static void main(String[] args) throws IOException {
        //BufferedReader in = new BufferedReader(new InputStreamReader(System.in));                                    //(new FileReader("input.in"));
        //StringBuilder out = new StringBuilder();
        //StringTokenizer tk;
        Scanner Reader = new Scanner(System.in);
       // Reader.init(System.in);
        //tk = new StringTokenizer(in.readLine());
     int n = 7,upper=0;
     boolean T=true;
     StringBuilder a=new StringBuilder();
     ArrayList<String>x=new ArrayList<>();
     int j=0;
        while(Reader.hasNextLine()){
            x.add(Reader.nextLine());
            if(x.get(j).length()>upper){
                if(x.get(j).length()%2==0)
                upper=x.get(j).length();
                else upper=x.get(j).length();
            }
            j++;
        }
       // System.out.println("u"+ upper);
        for (int i = 0; i <= upper+1; i++) {
            a.append('*');
        }
        a.append("\n*");
        for (int i = 0; i < x.size(); i++) {
            if (x.get(i).length() % 2 == 0) {
                int v = (upper - x.get(i).length()) / 2, k = 0;
                while (k++ < v) {
                    a.append(" ");
                }
                a.append(x.get(i));
                k = 0;
                while (k++ < v) {
                    a.append(" ");
                }
                a.append("*\n*");

            }else {
                int v=0,k=0;
                if(T){
               v = (upper - x.get(i).length()) / 2; k = 0;

                }
                else {v = (upper - x.get(i).length()) / 2+1; k = 0;

                }

                while (k++ < v) {
                    a.append(" ");
                }
                a.append(x.get(i));
                k = 0;
                if(T)
                while (k++ < v+1) {
                    a.append(" ");
                }
                else {
                while (k++ < v-1) {
                    a.append(" ");
                }
                }
                T=T==true?false:true;
                a.append("*\n*");
            }

        }
        for (int i = 0; i < upper+1; i++) {
            a.append('*');

        }
        System.out.println(a);
        }

       }

//class Book {
//
//    String a;
//    int b, c,ind;
//
//    public Book(String x, int y) {
//        a = x;
//        b = y;
//
//
//    }
//
//    @Override
//    public boolean equals(Object object) {
//        boolean sameSame = false;
//
//        if (object != null && object instanceof Book) {
//            sameSame = (this.a == null ? ((Book) object).a == null : this.a.equals(((Book) object).a));
//        }
//        if (object != null && object instanceof Book) {
//            sameSame = this.b == ((Book) object).b;
//        }
//
//        return sameSame;
//    }
//}
//
//class MyComparator implements Comparator<Book> {
//
//    @Override
//    public int compare(Book o1, Book o2) {
//        if (o1.c > o2.c) {
//            return 1;
//        } else if (o1.c < o2.c) {
//            return -1;
//        }
//        return 0;
//    }
//
//}

class Reader {

    static StringTokenizer tokenizer;
    static BufferedReader reader;

    public static void init(InputStream input) throws UnsupportedEncodingException {
        reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
        tokenizer = new StringTokenizer("");
    }

    public static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    public static String nextLine() throws IOException {
        return reader.readLine();
    }

    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}


import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.String.*;
import javax.print.DocFlavor;

public class Main {

    public static void main(String[] args) throws IOException {
        //BufferedReader in = new BufferedReader(new InputStreamReader(System.in));                                    //(new FileReader("input.in"));
        //StringBuilder out = new StringBuilder();
        //StringTokenizer tk;
        Scanner Reader = new Scanner(System.in);
       // Reader.init(System.in);
        //tk = new StringTokenizer(in.readLine());
     int n = 7,upper=0;
     boolean T=true;
     StringBuilder a=new StringBuilder();
     ArrayList<String>x=new ArrayList<>();
     int j=0;
        while(Reader.hasNextLine()){
       // for (int i = 0; i < n; i++) {

            x.add(Reader.nextLine());
            if(x.get(j).length()>upper){
                if(x.get(j).length()%2==0)
                upper=x.get(j).length();
                else upper=x.get(j).length();
            }
            j++;
        }
       // System.out.println("u"+ upper);
        for (int i = 0; i <= upper+1; i++) {
            a.append('*');
        }
        a.append("\n*");
        if(upper%2==0){
        for (int i = 0; i < x.size(); i++) {
            if (x.get(i).length() % 2 == 0) {
                int v = (upper - x.get(i).length()) / 2, k = 0;
                while (k++ < v) {
                    a.append(" ");
                }
                a.append(x.get(i));
                k = 0;
                while (k++ < v) {
                    a.append(" ");
                }
                a.append("*\n*");

            }else {
                int v=0,k=0;
                if(T){
               v = (upper - x.get(i).length()) / 2; k = 0;

                }
                else {v = (upper - x.get(i).length()) / 2+1; k = 0;

                }

                while (k++ < v) {
                    a.append(" ");
                }
                a.append(x.get(i));
                k = 0;
                if(T)
                while (k++ < v+1) {
                    a.append(" ");
                }
                else {
                while (k++ < v-1) {
                    a.append(" ");
                }
                }
                T=T==true?false:true;
                a.append("*\n*");
            }

        }}
        else{
               for (int i = 0; i < x.size(); i++) {
            if (x.get(i).length() % 2 != 0) {
                int v = (upper - x.get(i).length()) / 2, k = 0;
                while (k++ < v) {
                    a.append(" ");
                }
                a.append(x.get(i));
                k = 0;
                while (k++ < v) {
                    a.append(" ");
                }
                a.append("*\n*");

            }else {
                int v=0,k=0;
                if(T){
               v = (upper - x.get(i).length()) / 2; k = 0;

                }
                else {v = (upper - x.get(i).length()) / 2+1; k = 0;

                }

                while (k++ < v) {
                    a.append(" ");
                }
                a.append(x.get(i));
                k = 0;
                if(T)
                while (k++ < v+1) {
                    a.append(" ");
                }
                else {
                while (k++ < v-1) {
                    a.append(" ");
                }
                }
                T=T==true?false:true;
                a.append("*\n*");
            }

        }}
        for (int i = 0; i < upper+1; i++) {
            a.append('*');

        }
        System.out.println(a);
        }

       }

//class Book {
//
//    String a;
//    int b, c,ind;
//
//    public Book(String x, int y) {
//        a = x;
//        b = y;
//
//
//    }
//
//    @Override
//    public boolean equals(Object object) {
//        boolean sameSame = false;
//
//        if (object != null && object instanceof Book) {
//            sameSame = (this.a == null ? ((Book) object).a == null : this.a.equals(((Book) object).a));
//        }
//        if (object != null && object instanceof Book) {
//            sameSame = this.b == ((Book) object).b;
//        }
//
//        return sameSame;
//    }
//}
//
//class MyComparator implements Comparator<Book> {
//
//    @Override
//    public int compare(Book o1, Book o2) {
//        if (o1.c > o2.c) {
//            return 1;
//        } else if (o1.c < o2.c) {
//            return -1;
//        }
//        return 0;
//    }
//
//}

class Reader {

    static StringTokenizer tokenizer;
    static BufferedReader reader;

    public static void init(InputStream input) throws UnsupportedEncodingException {
        reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
        tokenizer = new StringTokenizer("");
    }

    public static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    public static String nextLine() throws IOException {
        return reader.readLine();
    }

    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}


//package Contest5;

import java.util.ArrayList;
import java.util.Scanner;
public class main5B {
    public static Scanner enter = new Scanner(System.in);
    public static void main(String[] args) {
        ArrayList<String> notepade = new ArrayList<>(1000);
        int maxlenght=0;
        while(enter.hasNext()){
            String tmp=enter.nextLine();
            notepade.add(tmp);
            maxlenght=(tmp.length()>maxlenght) ? tmp.length(): maxlenght;
        }
        print(notepade,maxlenght);
    }

    public static int counter=0;
    public static void print(ArrayList<String> arrayList, int N){
        String first="";
        for (int i = 0; i <N+1 ; i++) first+="*";
        System.out.println(first);
        for (int i = 0; i <arrayList.size() ; i++) System.out.println(getSctr(arrayList.get(i),N));
        System.out.println(first);
    }
    public static String getSctr(String slovo,int max){
        String tmp="";
        int delta=max-slovo.length();
        for (int i = 0; i <delta/2 ; i++) tmp+=" ";
        if(delta%2==0){
            return "*"+tmp+slovo+tmp+"*";
        }
        else{
            if(counter==0) {
                counter=1;
                return "*"+tmp+" "+slovo+tmp+"*";
            }
            else{
                counter=0;
                return "*"+tmp+slovo+tmp+" "+"*";
            }
        }
    }
}


//package Contest5;

import java.util.ArrayList;
import java.util.Scanner;
public class main5B {
    public static Scanner enter = new Scanner(System.in);
    public static void main(String[] args) {
        ArrayList<String> notepade = new ArrayList<>(1000);
        int maxlenght=0;
        while(enter.hasNext()){
            String tmp=enter.nextLine();
            notepade.add(tmp);
            maxlenght=(tmp.length()>maxlenght) ? tmp.length(): maxlenght;
        }
        print(notepade,maxlenght);
    }

    public static int counter=0;
    public static void print(ArrayList<String> arrayList, int N){
        String first="";
        for (int i = 0; i <N+2; i++) first+="*";
        System.out.println(first);
        for (int i = 0; i <arrayList.size() ; i++) System.out.println(getSctr(arrayList.get(i),N));
        System.out.println(first);
    }
    public static String getSctr(String slovo,int max){
        String tmp="";
        int delta=max-slovo.length();
        for (int i = 0; i <delta/2 ; i++) tmp+=" ";
        if(delta%2==0){
            return "*"+tmp+slovo+tmp+"*";
        }
        else{
            if(counter==0) {
                counter=1;
                return "*"+tmp+" "+slovo+tmp+"*";
            }
            else{
                counter=0;
                return "*"+tmp+slovo+tmp+" "+"*";
            }
        }
    }
}


//package Contest5;

import java.util.ArrayList;
import java.util.Scanner;
public class main5B {
    public static Scanner enter = new Scanner(System.in);
    public static void main(String[] args) {
        ArrayList<String> notepade = new ArrayList<>(1000);
        int maxlenght=0;
        while(enter.hasNext()){
            String tmp=enter.nextLine();
            notepade.add(tmp);
            maxlenght=(tmp.length()>maxlenght) ? tmp.length(): maxlenght;
        }
        print(notepade,maxlenght);
    }

    public static int counter=0;
    public static void print(ArrayList<String> arrayList, int N){
        String first="";
        for (int i = 0; i <N+1 ; i++) first+="*";
        for (int i = 0; i <arrayList.size() ; i++) System.out.println(getSctr(arrayList.get(i),N));
    }
    public static String getSctr(String slovo,int max){
        String tmp="";
        int delta=max-slovo.length();
        for (int i = 0; i <delta/2 ; i++) tmp+=" ";
        if(delta%2==0){
            return "*"+tmp+slovo+tmp+"*";
        }
        else{
            if(counter==0) {
                counter=1;
                return "*"+tmp+" "+slovo+tmp+"*";
            }
            else{
                counter=0;
                return "*"+tmp+slovo+tmp+" "+"*";
            }
        }
    }
}


//package Contest5;

import java.util.ArrayList;
import java.util.Scanner;
public class main5B {
    public static Scanner enter = new Scanner(System.in);
    public static void main(String[] args) {
        ArrayList<String> notepade = new ArrayList<>(1000);
        int maxlenght=0;
        while(enter.hasNextLine()){
            String tmp=enter.nextLine();
            notepade.add(tmp);
            maxlenght=(tmp.length()>maxlenght) ? tmp.length(): maxlenght;
        }
        print(notepade,maxlenght);
    }

    public static int counter=1;
    public static void print(ArrayList<String> arrayList, int N){
        String first="";
        for (int i = 0; i <N+2; i++) first+="*";
        System.out.println(first);
        for (int i = 0; i <arrayList.size() ; i++) System.out.println(getSctr(arrayList.get(i),N));
        System.out.println(first);
    }
    public static String getSctr(String slovo,int max){
        String tmp="";
        int delta=max-slovo.length();
        for (int i = 0; i <delta/2 ; i++) tmp+=" ";
        if(delta%2==0){
            return "*"+tmp+slovo+tmp+"*";
        }
        else{
            if(counter==0) {
                counter=1;
                return "*"+tmp+" "+slovo+tmp+"*";
            }
            else{
                counter=0;
                return "*"+tmp+slovo+tmp+" "+"*";
            }
        }
    }
}


//package Contest5;

import java.util.ArrayList;
import java.util.Scanner;
public class main5B {
    public static Scanner enter = new Scanner(System.in);
    public static void main(String[] args) {
        ArrayList<String> notepade = new ArrayList<>(1000);
        int maxlenght=0;
        while(enter.hasNext()){
            String tmp=enter.nextLine();
            notepade.add(tmp);
            maxlenght=(tmp.length()>maxlenght) ? tmp.length(): maxlenght;
        }
        print(notepade,maxlenght);
    }

    public static int counter=1;
    public static void print(ArrayList<String> arrayList, int N){
        String first="";
        for (int i = 0; i <N+2; i++) first+="*";
        System.out.println(first);
        for (int i = 0; i <arrayList.size() ; i++) System.out.println(getSctr(arrayList.get(i),N));
        System.out.println(first);
    }
    public static String getSctr(String slovo,int max){
        String tmp="";
        int delta=max-slovo.length();
        for (int i = 0; i <delta/2 ; i++) tmp+=" ";
        if(delta%2==0){
            return "*"+tmp+slovo+tmp+"*";
        }
        else{
            if(counter==0) {
                counter=1;
                return "*"+tmp+" "+slovo+tmp+"*";
            }
            else{
                counter=0;
                return "*"+tmp+slovo+tmp+" "+"*";
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
		String str=s.readLine();
		ArrayList<String> arr=new ArrayList<>();
		int maxlength=0;
		while(true) {
			try {
				arr.add(str);
				maxlength=maxlength<str.length()?str.length():maxlength;
				if(str==null)break;
				str=s.readLine();
			}catch(Exception e){
				break;
			}
		}
		String[] strarr=new String[arr.size()];
		arr.toArray(strarr);
		for(int i=0;i<maxlength+2;i++) {
			System.out.print("*");
		}
		boolean pos=false;
		System.out.println();
		for(int i=0;i<strarr.length;i++)
		{

				System.out.print("*");
				int space=maxlength-strarr[i].length();
				int right=space%2==0?space/2:(!pos?space/2+1:space/2);
				int left=space%2==0?space/2:(pos?space/2+1:space/2);
				pos=space%2==0?pos:!pos;
				while(left>0) {
					System.out.print(" ");
					left--;
				}
				System.out.print(strarr[i]);
				while(right>0) {
					System.out.print(" ");
					right--;
				}
				System.out.print("*");

			System.out.println();
		}
		for(int i=0;i<maxlength+2;i++) {
			System.out.print("*");
		}
	}

}