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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define FOR(i,l,r) for(int i=(l);i<=(r);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) int(x.size())
template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';}
template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';}
#ifdef DEBUG
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...)<<'\n';}(x)
#else
#define debug(...) {}
#endif

int main() {
	cin.tie(0)->sync_with_stdio(0);
	LL N;
	cin >> N;

	auto ml = [&](string s, LL n) {
		string ret = "";

		if (n == 0)
			return ret;

		vector<int> tym;
		while (n) {
			tym.emplace_back(n % 9);
			n /= 9;
		}
		REP (i, ssize(tym) - 1) {
			ret += "9[";
		}
		while (ssize(tym) > 1) {
			if (tym.back()) {
				ret += char(tym.back() + '0');
				ret += "[" + s + "]";
			}
			tym.pop_back();
			ret += "]";
		}
		if (tym.back()) {
			ret += char(tym.back() + '0');
			ret += "[" + s + "]";
		}
		return ret;
	};

	function<string(LL)> solve = [&](LL n) {
		if (n == 0)
			return string("");
		if (n == 1)
			return string("A");
		 
		string ret = "";
		if (n & 1) {
			ret += ml("A", n - 1);
			ret += ml("EC", n - 2);
			ret += "E";
		}
		ret += "A";
		LL m = (n - 2) / 2;
		
		if (m > 0) {
			ret += "2[";
			ret += solve(m);
			ret += "]";
		}
		
		ret += ml("E", m);
		ret += ml(ml("E", m) + ml("CA", m) + "C", m);
		ret += ml("E", m);
		ret += ml("C", m);
		ret += ml("EA", m * 2);
		ret += "EAC";
		ret += ml("AC", m * 2);
		ret += "A";
		if (n & 1) {
			ret += "CA";
		}
		return ret;
	};

	auto odp = solve(N);
	odp += ml("E", N);
	odp += ml("C", N);

	auto check = [&](string s) {
		assert(ssize(s) <= 150'000);

		function<string(int, int)> parse = [&](int l, int r) {
			assert(l <= r);
			string ret = "";
			FOR (i, l, r) {
				assert(('0' < s[i] && s[i] <= '9') || ('A' <= s[i] && s[i] <= 'F'));
				if ('0' < s[i] && s[i] <= '9') {
					assert(i < r);
					assert(s[i + 1] == '[');
					int ile = 1;
					int x = i + 1;
					while (ile) {
						++x;
						assert(x <= r);
						if (s[x] == '[')
							++ile;
						if (s[x] == ']')
							--ile;
					}
					string g = parse(i + 2, x - 1);
					REP (j, s[i] - '0')
						ret += g;
					i = x;
					continue;
				}
				else {
					ret += s[i];
				}
			}
			return ret;
		};
		string t = parse(0, ssize(s) - 1);
#ifdef DEBUG
		REP (i, ssize(t))
			cerr << t[i];
		cerr << endl;
#endif
		
		set<pair<pair<int, int>, pair<int, int>>> S;

		auto add = [&](int x, int y, int a, int b) {
			if (x > a) {
				swap(x, a);
				swap(y, b);
			}
			if (x == a) {
				if (y > b) {
					swap(y, b);
				}
			}
			S.insert({{x, y}, {a, b}});
		};

		int x = 0, y = 0;
		REP (i, ssize(t)) {
			int nx = x, ny = y;
			if (t[i] == 'A') {
				++nx;
			}
			else if (t[i] == 'B') {
				--ny;
			}
			else if (t[i] == 'C') {
				--nx;
				--ny;
			}
			else if (t[i] == 'D') {
				--nx;
			}
			else if (t[i] == 'E') {
				++ny;
			}
			else if (t[i] == 'F') {
				++nx;
				++ny;
			}
			else {
				assert(false);
			}
			add(x, y, nx, ny);
			x = nx;
			y = ny;
			assert(0 <= x && x <= N && 0 <= y && y <= x);
		}

		assert(ssize(t) == 3 * N * (N + 1) / 2);
		assert(ssize(S) == 3 * N * (N + 1) / 2);
		return true;
	};

#ifdef LOCAL
	assert(check(odp) == true);
	cout << "OK\n";
	return 0;
#endif

	REP (i, ssize(odp))
		cout << odp[i];
}