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
#include <cstdio>
#define lld long long int


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

lld n, k;
char buff[1000005];
int main() {
    scanf("%lld%lld", &n, &k);
    if (n < 60ll && k > 3ll * (1ll << n) - 3ll) {
        printf("NIE\n");
        return 0;
    }
    char prev = 'x';
    lld left = n - 1;
    int index = 0;
    while (k) {
        k--;
        lld cpl = left >= 61ll ? 1ll << 61ll : (1ll << (left + 1ll)) - 1;
        lld res = k / cpl;
        k = k % cpl;
        buff[index] =  next(prev, res);
        prev = buff[index];
        left--;
        index++;
    }
    buff[index] = 0;
    printf("%s\n", buff);
    return 0;
}