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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

string shift(string s, int sh){
    while(sh > 0){
        for(auto &c : s){
            c += 2;
            if(c > 'F') c-=6;
        }
        --sh;
    }
    return s;
}

string rep(const string &s, ll k){
    string res = "";
    int cntBrackets=0;
    while(k>0){
        if((k%9)>0){
            string x = string(1,(char)('0'+(k%9)));
            x = x + "[" + s + "]";
            if(x.size() < s.size()*(k%9)){
                res += x;
            }else{
                for(int i=0; i<k%9; ++i){
                    res += s;
                }
            }
        }
        k/=9;
        if(k>0){
            res += "9[";
            ++cntBrackets;
        }
    }
    while(cntBrackets>0){
        res += "]";
        --cntBrackets;
    }
    return res;
}

string rect(ll b, ll g, int sh){ // B w bok, G w gore
    if(b==0) return shift("F",sh);
    string level = "";
    level = rep(shift("FB",sh),b);
    level += shift("F",sh);
    level += rep(shift("D",sh),b);
    return rep(level,g);
}

ll ROGX1,ROGY1;
ll ROGX2,ROGY2;
ll X=0,Y=0;

string triangle(ll n, int sh, bool koncz){ // Startujemy z lewego rogu
    cout << "T" << sh << ": " << n << endl;
    if(n<=0){
        return "";
    }
    if(n==1){
        if((X==ROGX1&&Y==ROGY1) || (X==ROGX2&&Y==ROGY2)){
            if(sh==0){
                ++X;--Y;
            }else if(sh==1){
                --X;
            }else{
                ++Y;
            }
            return shift("FB",sh);
        }else{
            if(sh==0){
                ++X;
            }else if(sh==1){
                --Y;
            }else{
                --X;++Y;
            }
            return shift("F",sh);
        }
    }
    ll b=n/2;
    ll g=n/2;
    cout << " " << n << " " << b << endl;
    if(n%2==1) ++b;
    string res = "";
    res += rect(b,g,sh);
    if(sh==0) X += g;
    else if(sh==1) Y-=g;
    else if(sh==2) X-=g;
    if(n>1){
//        res += triangle(b,sh,1&koncz);
        res += triangle(b,sh,1);
    }
    if(koncz && n>1){
        res += triangle(g,(sh+1)%3,0);

    }
    return res;
}

int main(){
    ios_base::sync_with_stdio(0);
    ll n;
    cin >> n;
    ROGX1=n;
    ROGY1=0;
    ROGX1=n;
    ROGY1=-n;
    string res = "";
    for(int i=n-1; i>=0; --i){
        res += rep("FB", i);
        res += "F";
        res += rep("D",i);
    }
    res += rep("B",n);
    res += rep("D",n);
    cout << res;

    return 0;
}