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
61
62
63
64
65
66
67
#include<cstdio>

char S[] = { 'a', 'b', 'c' };

bool check(int x, long long int k, int c) {
	long long curr = 0;

	for (int i = 0; i < x; i++)
	{
		curr = curr * 2 + c;

		if (curr >= k)
			return true;
	}

	return false;
}

long long int skip(int x) {
	long long curr = 0;

	for (int i = 0; i < x; i++)
	{
		curr = curr * 2 + 1;
	}

	return curr;
}

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

	if (!check(n, k, 3))
	{
		printf("NIE");
	}
	else
	{
		int prevc = -1;
		int c = 0;

		while (k > 0)
		{
			if (c == prevc)
				c = (c + 1) % 3;

			if (check(n, k, 1))
			{
				printf("%c", S[c]);
				n--;
				k--;
				prevc = c;
				c = 0;
			}
			else
			{
				c++;
				k -= skip(n);
			}
		}		
	}

	return 0;
}