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
#include <iostream>
#include <functional>

using namespace std;

using ll = long long;

void A() {
	cout << "A";
}
void B() {
	cout << "B";
}
void C() {
	cout << "C";
}
void D() {
	cout << "D";
}
void E() {
	cout << "E";
}
void F() {
	cout << "F";
}

function<void()> repeat(ll n, function<void()> fun) {
	return [=]() {
		cout << n << "[";
		fun();
		cout << "]";
	};
}

function<void()> big_repeat(ll n, function<void()> fun) {
	if (n == 0){
		return [](){};
	}
	if (n == 1) return fun;
	if (n < 9) return repeat(n, fun);
	function<void()> akt = [](){};
	if (n % 9 != 0) {
		akt = [=]() {
			repeat(n % 9, fun)();
		};
	}
	return [=]() {
		akt();
		repeat(9, big_repeat(n / 9, fun))();
	};
}

function<void()> square_line(ll n) {
	return [=](){
		big_repeat(n, D)();
		big_repeat(n, [](){B(); F();})();
		B();
	};
}

function<void()> square(ll n) {
	return big_repeat(n, square_line(n));
}

function<void()> smol_triangle(ll n) {
	if (n == 0) return [](){};
	if (n % 2 == 1) {
		return [=](){
			F();
			smol_triangle(n - 1)();
			big_repeat(n - 1, D)();
			big_repeat(n - 1, [](){B(); F();})();
			B();
		};
	}
	return [=](){
		ll k = (n - 2) / 2;
		repeat(2, [=](){
			smol_triangle(k)();
			big_repeat(k, [](){F();D();})();
			F();
		})();
		big_repeat(k + 1, B)();
		square(k + 1)();
	};
}

void triangle(ll n) {
	smol_triangle(n)();
	big_repeat(n, D)();
}

int main() {
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
	ll n;
	cin >> n;
	triangle(n);
}