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
#include <cstdio>
#include <cstdlib>

int main() {
	int n;
	long long k;
    std::scanf("%d %lld", &n, &k);
    if (n <= 60 && (k - 1) / ((1ULL << n) - 1) > 2) {
		std::printf("NIE");
	} else {
		int p = 'd';
		int i = n - 60;
		if (k < i)
			i = k;
		if (i > 0) {
			k -= i;
			n -= i;
			k %= (2ULL << n) - 1;
			p = 'b';
			while (i--) {
				std::putchar(p ^= 3);
			}
		}
		while (k--) {
			std::lldiv_t d = std::div(k, (1ULL << n--) - 1);
			k = d.rem;
			int r = 'a' + d.quot;
			std::putchar(p = r + (r >= p));
		}
	}
    return 0;
}