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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include<cstdio>

long long int n,k,N,tmp,sum, group, flag;

long long int const K = 1000000000000000000;
char tab[4];
char TAB[4][3];

int main(){
	tab[0]='c';
	tab[1]='a';
	tab[2]='b';
	tab[3]='c';
	TAB[0][0]='b';
	TAB[0][1]='a';
	TAB[0][2]='b';
	TAB[1][0]='c';
	TAB[1][1]='b';
	TAB[1][2]='c';
	TAB[2][0]='c';
	TAB[2][1]='a';
	TAB[2][2]='c';
	TAB[3][0]='b';
	TAB[3][1]='a';
	TAB[3][2]='b';
	scanf("%lld %lld", &n, &k);
	tmp = n;
	N = 0;
	sum = 3;
	tmp--;
	N+=sum;
	while(tmp > 0 && N < K){
		tmp--;
		sum*=2;
		N+=sum;
	}
	//printf("%lld\n", N);
	if(N < k){
		printf("NIE");
	}else{
		N/=3;
		group=k/N;
		k=k%N;
		if(k==0){
				printf("%c", tab[group]);
				k=N;
				flag=group;
			}else{
				printf("%c", tab[group+1]);
				flag=group+1;
			}
		N-=1;
		k-=1;
		while(N>1 && k > 0){
			N/=2;
			group=k/N;
			k=k%N;
			if(k==0){
				printf("%c", TAB[flag][group]);
				k=N;
				if(TAB[flag][group]=='a'){
					flag=1;
				}else
				if(TAB[flag][group]=='b'){
					flag=2;
				}else
				if(TAB[flag][group]=='c'){
					flag=3;
				}else{
					printf("DUPA\n");
					printf("%lld\n", group);
				}
			}else{
				printf("%c", TAB[flag][group+1]);
				if(TAB[flag][group+1]=='a'){
					flag=1;
				}else
				if(TAB[flag][group+1]=='b'){
					flag=2;
				}else
				if(TAB[flag][group+1]=='c'){
					flag=3;
				}else{
					printf("DUPA\n");
				}
			}
			N-=1;
			k-=1;
			//printf("\n%lld %lld %lld %lld\n", N, k, group, flag);
		}
	}
}