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
102
#include <iostream>
#include <vector>

using namespace std;

long long int potega( long long int a, int wyk )
{
    if ( wyk == 0 ) return 1;
    if ( wyk > 60 ) return potega( a, 60 );
    if ( wyk % 2 == 1 )
    {
        long long int wynik = potega( a, wyk - 1 ) * a;
        //cout<<wynik<<endl;
        return wynik;
    }
    long long int t = potega( a, wyk/2 );
    //cout<<t*t;
    return t * t;
}

char nast( char ch, int a )
{
    if ( ch == 'a' )
    {
        if ( a ) return 'c';
        return 'b';

    }
    else if ( ch == 'b' )
    {
        if ( a ) return 'c';
        return 'a';
    }
    else if ( ch == 'c' )
    {
        if ( a ) return 'b';
        return 'a';
    }
}

int main()
{
    long long int n;
    long long int k;
    cin>>n>>k;
    long long int pot = potega( 2, n );
    long long int ile = pot - 1;
    //cout<<ile;
    //cout<<ile;
    //cout<<ile<<" ";
    int licz = 0;
    while( k > ile )
    {
        k -= ile;
        licz++;
    }
    //cout<<licz;
    if ( licz <= 2 )
    {
        char ch = 'a' + licz;
        string s;
        s += ch;

        while ( k > 1 )
        {
            //cout<<s<<endl;
            if ( n > 60 )
            {
                n--;
            }
            else
            {
                pot /= 2;
            }

            ile = pot;

            int wsk = 0;
            if ( k > ile )
            {
                k -= ile;
                wsk = 1;
            }
            else
            {
                k--;
            }
            char klucz = s[ s.size() - 1 ];
            s += nast( klucz, wsk );


        }
        cout<<s;


    }
    else
    {
        cout<<"NIE";
    }
    return 0;
}