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

#define fwd(i, a, b) for(int i=(a);i<(int)(b);i++)
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(X) (X).begin(), (X).end()
#define sz(X) ((int)(X).size())
#define mp make_pair
#define st first
#define nd second
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;


string repeatA(ll k, string code) {
    assert(k != 0);
    string res = code;
    if(k == 1)
        return code;
    if(k < 10)
        return string(1, (char)(k+'0'))+"["+code+"]";    
    return repeatA(k/9, "9["+code+"]")+(k%9 == 0 ? "" : repeatA(k%9, code));
}

string repeatB(ll k, string code) {
    string pref;
    string suf;
    for(int i=9;i>=2;i--) {
        while(k%i == 0) {
            k /= i;
            pref += (char)('0'+i);
            pref += '[';
            suf += ']';
        }
    }
    if(k <= 9) return pref+repeatA(k,code)+suf;
    return pref+(repeatB(k-k%9, code) + repeatA(k%9, code))+suf;
}

string repeat(ll k, string code) {
    auto sA = repeatA(k, code);
    auto sB = repeatB(k, code);
    if(sA.size() < sB.size())
        return sA;
    return sB;
}

string parallelogramC(ll l, ll r) {
    string rcol;
    if(r == 1) rcol = "BD";
    else rcol = repeat(r,"B")+repeat(r-1,"DF")+"D";
    return repeat(l, rcol);
}

string teethE(ll k) { return repeat(k, "FD"); }


string upperPart(ll k) {
    return teethE(2*k)+parallelogramC(k+1,k)+repeat(k+2, "F") + repeat(2*k+2,"B");
}

string lowerPart(ll k) {
    return "DEAC"+repeat(k+1,"D")+repeat(k+2,"BF");
}

string noBaseAndOneEedgeFromRightCorner(ll k) {
    if(k == 1)
        return "FFBDBF";
    if(k == 2)
        return "2[FBFD]FBBDBF";
    if(k%2 == 1)
        return repeat(k+1, "F") + repeat(k, "BD")+"B"+noBaseAndOneEedgeFromRightCorner(k-1);
    return repeat(2, noBaseAndOneEedgeFromRightCorner(k/2-1))+upperPart(k/2-1)+lowerPart(k/2-1);       
}

string fullTriangle(ll k) {
    if(k == 1) return "FBD";
    return noBaseAndOneEedgeFromRightCorner(k-1)+"B"+repeat(k,"D");
}

int32_t main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    string s = fullTriangle(n);
    cout<<s<<"\n";
    return 0;
}