#include<bits/stdc++.h>
using namespace std;

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define ppb           pop_back()
#define ppb           pop_back()
#define B(c)          (c).begin()
#define E(c)          (c).end()
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(2e18)
#define err           cerr << "move" << '\n';
#define endl          '\n'
#define pow(x, n)     (int)(pow(x, n))
#define mp            make_pair
#define tp            template
#define ty            typename

typedef vector<int>                           vi;
typedef pair<int,int>                         pii;
typedef vector<pii>                           vpi;
typedef priority_queue<pii, vector<pii>, greater<pii> > pq;

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

tp<ty T1, ty T2, ty T3> struct query{
    T1 ss; T2 x; T3 y;
};
tp<ty T1, ty T2, ty T3> bool operator<(query<T1, T2, T3> &o1, query<T1, T2, T3> &o2){
    return o1.x < o2.x;
}
tp<ty T1, ty T2, ty T3> istream& operator>>(istream& in, query<T1, T2, T3> &q){
    in >> q.ss >> q.x >> q.y; return in;
}
tp<ty T1, ty T2, ty T3> ostream& operator<<(ostream& out, query<T1, T2, T3> &q){
    out << q.ss << " " << q.x << " " << q.y; return out;
}

std::vector<string> V;

void get_string(string tt, int len, string str){
    if(len == 0){
    	if(si(str))V.pb(str);
    	return;
    }
    for(auto u : tt)
    	str.pb(u),get_string(tt, len-1, str), str.pop_back();
}

void solve(){  
    int n;
    cin >> n;
    vector<string> v;
    string ss = "a";
    for(int i = 1; i < n; i++)ss.pb('#');
    for(int i = 0; i < n; i++){
        for(int j = 0; j < (1<<(n-1)); j++){
            if(__builtin_popcountll(j) == i){
                string s = ss;
                int cnt = 1;
                for(int k = 0; k < (n-1); k++){
                    if((j>>k)&1)s[k+1] = 'a'+cnt, cnt++;
                }
                std::vector<string> tt;
                tt.pb(s);
                set<char> st;
                //if(i != 1 || j != 1)continue;
                //cout << s << " " << j << endl;
                for(int k = 0; k < n;){
                    int j = k+1; st.insert(s[k]);
                    while(j < n && s[j] == '#')j++;
                    string temp = "", kk;
                    for(auto& u : st)kk.pb(u);
                    get_string(kk, j-k-1, temp);
                    //cout << j-k-1 << " " << endl;
                    std::vector<string> ttt;
                    for(auto u : tt){
                        string str = u;
                        for(auto uu : V){
                            for(int ll = k+1; ll < j; ll++){
                                str[ll] = uu[ll-k-1];
                            }
                            ttt.pb(str);
                        }
                    }
                    if(si(V)) tt = ttt, V.clear();
                    k = j;
                }
                for(auto u : tt)v.pb(u);
            }
        }
    }
    sort(all(v));
    for(auto u : v){
        cout << u << endl;
    }
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif

    //cin >> t;
    
    while(t--){
        solve();
    }

    double time_taken = double(clock() - start) / double(CLOCKS_PER_SEC); 
    //cerr << time_taken;
}


Measured memory_bytes: 7924