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<iostream>
using namespace std;

string format(long long k, string t) {
    if (k < 10) {
        if (k > 1) {
            string s = "";
            s.push_back('0' + k);
            return s + ((t.size() > 1) ? "[" + t + "]" : t);
        }
        return t;
    }
    for (int i = 9; i >= 2; i--) {
        if (k % i == 0) {
            string s = "";
            s.push_back('0' + i);
            return s + "[" + format(k / i, t) + "]";
        }
    }
    return "2[" + format(k / 2, t) + "]" + t;
}


string triangle_(long long n) {
    if (n == 1) {
        return "FB";
    }
    else if (n == 2) {
        return "FFBDBFB";
    }
    else {
        if (n % 2 == 1) {
            long long a = n / 2, b = n - a;
            string s;
            s.append(format(n, "F"));
            s.append(format(a, format(b, "B") + format(a, "DF") + "D"));
            s.append(format(a, "BD") + "B");
            return s + format(2, triangle_(a));
        }
        else {
            long long a = n / 2;
            string s;
            s.append(format(n, "F"));
            s.append(format(a - 1, format(a + 1, "B") + format(a, "DF") + "D"));
            s.append("BDBFB");
            s.append(format(a - 1, "DDBFB"));
            return s + format(2, triangle_(a - 1));
        }
    }
}

string triangle(long long n) {
    return triangle_(n) + format(n, "D");
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    long long n;
    cin >> n;
    cout << triangle(n) << endl;

    return 0;
}