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
 93
 94
 95
 96
 97
 98
 99
100
101
#include <cstdio>
#include <cstdlib>
#include <string>

unsigned long long int pow(unsigned long long int base, unsigned long long int exp)
{
	unsigned long long ret = base;
	for(unsigned long long int i = 2; i <= exp; i++)
	{
		ret *= base;
	}
	return ret;
}
unsigned int bit(unsigned long long int base)
{
	unsigned long long int b = 0x8000000000000000ll;
	int ret = 63;
	while(b >= 0)
	{
		if(base & b) return ret;
		ret--;
		b/=2;
	}
	return 0;
}

unsigned long long int mod(unsigned long long k, unsigned long long n)
{
	if(n >= 63) return k;
	for(unsigned long long int i = 63; i >= n; i--)
	{
		unsigned long long int mask = 1ll << i;
		k &= ~mask;
	}
	return k;
}

int main(int argc, char *argv[])
{
	unsigned long long int n, k;
	scanf("%llu %llu", &n, &k);
	std::string ret;

	if(n < 62) // (3 * (2^62 - 1)) = 13835058055282163709 > 10^18
	{
		unsigned long long int len = 3ll * (pow(2ll, n) - 1ll);
		if(len < k)
		{
			printf("NIE");
			return 0;
		}
	}
	char letter = 0;

	unsigned long long int bit_k = bit(k);

	if(bit_k <= n - 1ll)
	{
		k -= 1ll;
		letter = 'a';
	}
	else
	{
		bit_k = bit(k + 1ll);
		if(bit_k <= n)
			letter = 'b';
		else
		{
			letter = 'c';
			k += 1ll;
		}
	}

	ret += letter;
	
	unsigned long long int k_mod = k;
	
	while(n > 1)
	{
		k_mod = mod(k_mod, n);
		if(k_mod == 0)
		{
			printf("%s", ret.c_str());
			return 0;
		}
		unsigned long long int bit_mod = bit(k_mod);
		if(bit_mod < n - 1ll)
		{
			letter = (letter == 'a' ? 'b' : 'a');
			k_mod -= 1ll;
		}
		else
		{
			letter = (letter == 'c' ? 'b' : 'c');
		}
		ret += letter;
		n -= 1ll;
	}
	printf("%s", ret.c_str());
	return 0;
}