1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h>

using namespace std;

const int MAX_LEN = 60;

int n, j, last = -1;
long long m;

int main() {
    scanf("%d %lld", &n, &m);

    if (n > MAX_LEN || 3 * ((1LL << n) - 1) >= m) {
        do {
            if (n <= MAX_LEN) {
                for (j = 0; m > (1LL << n) - 1; j++, m -= (1LL << n) - 1);
                last = (last == 1 && j == 1 ? 2 : j + !last);
            } else last = (last + 1) % 2;
            printf("%c", last + 'a');
        } while (--m && --n);
    } else printf("NIE");

    return 0;
}