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
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define pi pair<int,int>
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define pl pair<long long,long long>
#define pb push_back

long long w[1000005];
long long inf=1000000000000000000LL;

int main()
{
    int a,b,n,l,i;
    long long k;

    scanf ("%d%lld", &n, &k);

    w[1]=1;

    for (a=2; a<=n+1; a++)
        w[a]=min(2*w[a-1],inf);

    if (k>6*w[n]-3)
        printf ("NIE");
    else
    {
        l=3;
        a=n;

        while (k)
        {
            for (b=0; b<3; b++)
                if (b!=l)
                {
                    if (k<=2*w[a]-1)
                        break;
                    else
                        k-=2*w[a]-1;
                }

            l=b;
            printf("%c", 'a'+l);
            a--;
            k--;
        }
    }

    return 0;
}