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
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<deque>
#include<vector>
#define C 2
using namespace std;
typedef long long ll;

string rep(ll x, string s){
    deque < char > sq;
    vector < int > P;
    while(x != 0){
        P.push_back(x%9);
        x /= 9;
    }
    reverse(P.begin(),P.end());
    for(int i = 0; i < P.size();i++){
        if(i != 0){
            sq.push_front('[');
            sq.push_front('9');
            sq.push_back(']');
        }
        if(P[i] == 0)
            continue;

        if(P[i] != 1)
            sq.push_back('0' + P[i]);

        if(P[i] != 1 && s.size() > 1){
            sq.push_back('[');
        }

        for(int j = 0; j < s.size();j++)
            sq.push_back(s[j]);

        if(P[i] != 1 && s.size() > 1){
            sq.push_back(']');
        }
    }
    string ans;
    while(!sq.empty()){
        ans.push_back(sq.front());
        sq.pop_front();
    }
    return ans;
}

char getChar(int phase){
    if(phase < 0)
        phase += 6;
    if(phase >= 6)
        phase -= 6;
    return 'A' + phase;
}

void romb(ll h, ll w, int phase){
    string f = rep(w, string{getChar(phase+5),getChar(phase+1)});
    f += getChar(phase+5);
    string b = rep(w, string{getChar(phase+3)});
    //cout << f + b << "\n";
    string ans = rep(h,f+b);
    cout << ans;
    //return ans;
}

void trojkat(ll x, int phase){
    if(x == 0)
        return;
    if(x <= C){
        for(int i = (int)x; i >= 1;i--){
            if(i > 2){
                cout << i-1 << '[' << getChar(phase+5) << getChar(phase+1) << ']';
                cout << getChar(phase+5);
                cout << i-1 << getChar(phase+3);
            }else if(i == 2){
                cout << getChar(phase+5) << getChar(phase+1) << getChar(phase+5);
                cout << getChar(phase+3);
            }else{
                cout << getChar(phase+5);
            }
        }
        if(x > 1)
            cout << x;
        cout << getChar(phase+1);
        return;
    }

    ll y = x/C;
    ll y2 = x/C + x%C;
    romb(y2,x-y2,phase);
    ll x2 = x - y2;
    for(int i = 2; i < C;i++){
        romb(y,x2-y,phase);
        x2 -= y;
    }
    //cout << y << " " << y2 << "**\n";
    cout << rep(y,string{getChar(phase+5)});
    cout << C << '[';
    trojkat(y-1,(phase+2)%6);
    cout << rep(y-1, string{getChar(phase+1),getChar(phase+5)});
    cout << getChar(phase+1);
    cout << ']';
    for(ll i = y; i < y2; i++){
        cout << rep(i, string{getChar(phase+3)});
        cout << rep(i, string{getChar(phase+1),getChar(phase+5)});
        cout << getChar(phase+1);
    }
}

int main(void){
    ll n;
    scanf("%lld",&n);
    trojkat(n,0);
    cout << rep(n, "D");
    return 0;
}