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

int N;
int len = 0;
void printOut(int cnt, string S) {
    if (cnt == 0)
        return;
    int curMul = 1;
    vector<int> st = {1};
    string res;
    while (curMul <= cnt) {
        curMul *= 9;
        st.push_back(9);
    }
    curMul /= 9;
    st.pop_back();
    for (int i = 0; i < (int)st.size() - 1; i++) {
        res += "9[";
    }

    while (!st.empty()) {
        int i = 9;
        for (; i > 0; i--) {
            if (curMul * i <= cnt) {
                cnt -= curMul * i;
                if (i > 2) {
                    if (S.size() > 1)
                        res += (to_string(i) + "[" + S + "]");
                    else
                        res += (to_string(i) + S);
                }
                if (i == 2)
                    res += (S + S);
                if (i == 1)
                    res += S;
                break;
            }
        }
        st.pop_back();
        if (st.size())
            res += "]";
        curMul /= 9;
    }
    cout << res;
}

void solve() {
    printOut(N, "F");
    for (int level = 1; level <= N; level++) {
        printOut(level - 1, "BF");
        printOut(1, "B");
        printOut(level, "D");
    }
    cout << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N;
    solve();
    return 0;
}