Problem:
Score : 1000 points

Problem Statement

#nck {
width: 30px;
height: auto;
}

Welcome to CODE FESTIVAL 2016!
In order to celebrate this contest, find a string s that satisfies the following conditions:

The length of s is between 1 and 5000, inclusive.

s consists of uppercase letters.

s contains exactly K occurrences of the string "FESTIVAL" as a subsequence.
In other words, there are exactly K tuples of integers (i_0, i_1, ..., i_7) such that 0 ≤ i_0 < i_1 < ... < i_7 ≤ |s|-1 and s[i_0]='F', s[i_1]='E', ..., s[i_7]='L'.

It can be proved that under the given constraints, the solution always exists.
In case there are multiple possible solutions, you can output any.

Constraints

1 ≤ K ≤ 10^{18}

Input

The input is given from Standard Input in the following format:

K

Output

Print a string that satisfies the conditions.

Sample Input 1

7

Sample Output 1

FESSSSSSSTIVAL

Sample Input 2

256

Sample Output 2

FFEESSTTIIVVAALL

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

const int N=8;
const string s="FESTIVAL";
ll n;

int main(){
	cin>>n;
	int t=1,B=0,l=0;
	vl dp(N+1),a,c;
	dp[0]=1;
	while(1){
		vl DP=dp;
		for(int i=0;i<N;i++) for(int j=0;j<t;j++) DP[i+1]+=DP[i];
		if(DP[N]>n) break;
		dp=DP;
		a.push_back(DP[N-1]);
		c.push_back(t);
		l+=t*N;
		if(B%6<5) t++;
		B++;
	}
	while(t>0){
		vl DP=dp;
		for(int i=0;i<N;i++) for(int j=0;j<t;j++) DP[i+1]+=DP[i];
		if(DP[N]>n){
			t--;
			continue;
		}
		dp=DP;
		l+=N*t;
		a.push_back(DP[N-1]);
		c.push_back(t);
	}
	n-=dp[N];
	int S=a.size();
	vl b(S);
	while(n){
		for(int i=S-1;i>=0;i--) if(a[i]<=n){
			n-=a[i];
			b[i]++;
			l++;
		}
	}
	assert(l<=5000);
	for(int i=0;i<S;i++){
		for(int j=0;j<N;j++) for(int k=0;k<c[i];k++) cout<<s[j];
		for(int j=0;j<b[i];j++) cout<<'L';
	}
	cout<<endl;
}