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
103
104
105
106
107
#include<iostream>
#include<vector>

using namespace std;

long long myPow(int base,int n){
    long long result = 1;

    for(int i=0;i<n;++i){
        result*=base;
    }

    return result;
}

vector<char> generate(int n,long long k){
    vector<char> tab;
    int count = n;
    long long tmp; 
    
    if(n>62){
        int liczba;
        if((n-62)>=k){
            liczba = k;
            k = 0;
        }
        else
            liczba = n-62;

        for(int i=0;i<liczba;++i){
            if((i % 2) == 0)
                tab.push_back('a');
            else
                tab.push_back('b');
        }
        k-=(n-62);
        count = 62;
    }
    else{
        tmp = myPow(2,count) - 1;
        if(k>(2*tmp)){
            tab.push_back('c');
            k-=2*tmp;
        }
        else if(k>tmp){
            tab.push_back('b');
            k-=tmp;
        }
        else {
            tab.push_back('a');
        }

        k-=1;
        count-=1;    
    }
    while(count>0 && k>0){
        tmp = myPow(2,count) - 1;
        char first,second;

        if(tab.back() == 'a'){
            first = 'b';
            second = 'c';
        }
        else if(tab.back() == 'b'){
            first = 'a';
            second = 'c';
        }
        else {
            first = 'a';
            second = 'b';
        }

        if(k>tmp){
            tab.push_back(second);
            k-=tmp;
        }
        else {
            tab.push_back(first);
        }
            k-=1;
            count-=1;
    }

    return tab;
}



int main(){
    long long k;
    int n;


    cin>>n>>k;
    if(n<63 && (3*(myPow(2,n)-1))<k){
        cout<<"NIE"<<endl;
        return 0;
    }
    vector<char> result = generate(n,k);
    for(int i=0;i<result.size();++i){
        cout<<result[i];
    }
    cout<<""<<endl;


return 0;
}