1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (auto i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define PPC(x) __builtin_popcountll(x)
#define MSB(x) (63 - __builtin_clzll(x))
#define LSB(x) __builtin_ctzll(x)
#define ARG(x, i) (get<i>(x))
#define ithBit(m, i) ((m) >> (i) & 1)
#define pb push_back
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

#define dbg(...) 0

template <typename T1, typename T2> inline void remin(T1& a, T2 b) { a = min(a, (T1)b);	}
template <typename T1, typename T2> inline void remax(T1& a, T2 b) { a = max(a, (T1)b);	}

const int maxN = 1 << 12, INF = 1 << 30;


string stringExpSummand(const string& T, long long n) // p | n => p < 10
{
	if (n == 1ll)
		return T;

	int brackets = 0;
	string ret {""};
	
	FORD(d, 9, 1)
	{
		for (; n % d == 0; n /= d)
			ret += std::to_string(d) + "[", brackets++;
	}
	assert(n == 1ll);
	
	if (SZ(T) == 1)
		ret.pop_back(), brackets--;
		
	ret += T + string(brackets, ']');
	return ret;
}

auto breakIntoSummands(long long n) // n > 0
{
	vector <long long> ret {};
	long long pow9 = 1ll;
	for (; n != 0; n /= 9)
	{
		int d = n % 9;
		if (d != 0)
			ret.pb(pow9 * d);
		pow9 *= 9;
	}

	return ret;	
}

string stringExp(const string& T, long long n) // n > 0
{
	string ret {""};
	for (auto s : breakIntoSummands(n))
		ret += stringExpSummand(T, s);
	return ret;
}

string getTwoRows(long long n, string& a, string& b, string& c, string& d) // n > 0
{
	if (n == 1ll)
		return a;
	else
		return a + stringExp(b + a, n-1) + c + stringExp(d + c, n-2);
}

string combine(int digit, string& a, string& b, string& c, string& d) // 0 <= d <= 9
{
	string ret {""};
	for (; digit > 0; digit -= 2)
		ret += getTwoRows(1ll * digit, a, b, c, d);
	return ret;
}

auto genWords(long long n, string& upperFull, string& lowerFull, string& upPart, string& lowPart)
{
	auto uf = combine(n, upperFull, lowerFull, upPart, lowPart);
	auto lf = combine(n, lowerFull, upperFull, lowPart, upPart);
	auto up = combine(n, upPart, lowPart, upperFull, lowerFull);
	auto lp = combine(n, lowPart, upPart, lowerFull, upperFull);

	return tuple <string, string, string, string> (uf, lf, up, lp);
}

pair <long long, long long> getStep(long long n)
{
	if (n < 10)
		return {n, n+1};
	
	long long s = 0;
	while (s < n)
	{
		FORD(d, 9, 1)
			if ((n - s) % d == 0)
				return {s, d};
		s += 2;
	}
	return {n, n+1};
}

void solve()
{
	long long n;
	scanf ("%lld", &n);
	
	string A {"AE"};
	string B {"AC"};
	string C {"E"};
	string D {"C"};
	
	string suf = stringExp(D, n);
	string res {""};
	
	while (n > 0)
	{
		auto [s, d] = getStep(n);
		for (; s > 0; s -= 2)
		{
			res += getTwoRows(n, A, B, C, D);
			n -= 2;
		}
		
		if (n > 9)
		{
			assert(n % d == 0);
			tie(A, B, C, D) = genWords(d, A, B, C, D);
			n /= d;
		}
	}
	
	res += suf;
	printf("%s\n", res.c_str());
	
//	std::cerr << "[" << SZ(res) << "]\n";
}
 
int main()
{
	int t = 1;
	//scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}