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
#include <iostream>
using namespace std;
#define ll long long

ll p2[61]={0,1},ps[61]={0,1};

void init() {
    for(int i=2;i<61;i++) {
        p2[i]=p2[i-1]*2;
        ps[i]=ps[i-1]+p2[i];
        //cout << p2[i]<< " " << ps[i]<< endl;
    }
}

char next(char c, int k) { // k=1,2
    if (c=='a') return k==1 ? 'b' : 'c';
    if (c=='b') return k==1 ? 'a' : 'c';
    return k==1 ? 'a' : 'b';
}

char ans[1000001];

void go(int p,char pref, int n, ll k) {
	//cout << pref<<n<<" "<<k<<endl;
    if (k==1) {ans[p]=pref; return;}
    if (n>60) 
    	go(p+1,next(pref,1),n-1,k-1);
    else if (k>p2[n]) 
    	go(p+1,next(pref,2),n-1,k-p2[n]);
    else
    	go(p+1,next(pref,1),n-1,k-1);
   	ans[p]=pref; return;
}

int main() {
    init();
    int n; ll k;
    cin >> n >> k;
    if (n<60 && 3*ps[n]<k) { cout << "NIE"; return 0;}
    //cout << ps[n] << endl;
    if (n>=60)
    	go(0,'a',n,k);
    else if (k<=ps[n])
        go(0,'a',n,k);
    else if (k<=2*ps[n])
        go(0,'b',n,k-ps[n]);
    else
        go(0,'c',n,k-2*ps[n]);
    cout << ans << endl;
    return 0;
}