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
#include <bits/stdc++.h>

using namespace std;

int64_t n;

string f(string s, int64_t x) {
	if (s.empty())
		return "";
	if (!x)
		return "";
	if (x < 10) {
		return to_string(x) + "[" + s + "]";
	}
	return "9[" + f(s, x / 9) + "]" + f(s, x % 9);
}

string solve(int64_t n) {
	if (n == 1)
		return "D";
	if (n == 2)
		return "DFDBD";
	int64_t mid = n >> 1;
	if (n % 2) {
		return f(solve(mid), 2) + f("EA", n - 1) + 
			f(f("CA", mid) + "C" + f("E", mid), mid) +
			f("C", mid) + "D";
	}
	else {
		return solve(n - 1) + f("F", n - 1) + f("DB", n - 1) + "D";
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin >> n;
	cout << solve(n) << f("F", n) << f("B", n) << '\n';
}