stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

#define pb push_back

#define rep(i,n) for(int i=0;i<(n);i++)

#define reps(i,n,s) for(int i=(s);i<(n);i++)

#define rrep(i,n) for(int i=(n-1);i>=0;i--)

#define rreps(i,n,s) for(int i=s;i>=n;i--)

#define MOD 1000000007

using ll = long long;

using namespace std;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll n;

vector<string> ans;

void dfs(string s,char mx){

    if(s.size()==n){

        ans.pb(s);

        return ;

    }

    for(char c='a';c<=mx;c++){

        dfs(s+c,(c==mx)?(char)(mx+1):mx);

    }

}



int main(){

cin.tie(0);

ios::sync_with_stdio(false);



cin>>n;

dfs("",'a');



sort(ans.begin(),ans.end());

rep(i,ans.size()){

    cout<<ans[i]<<endl;

}

// system("pause");

return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.168706976542075x):
#include <bits/stdc++.h>

#define pb push_back

#define rep(i,n) for(int i=0;i<(n);i++)

#define reps(i,n,s) for(int i=(s);i<(n);i++)

#define rrep(i,n) for(int i=(n-1);i>=0;i--)

#define rreps(i,n,s) for(int i=s;i>=n;i--)

#define MOD 1000000007

using ll = long long;

using namespace std;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll n;

vector<string> ans;

void dfs(string s,int k){

    if(s.size()==n){

        cout<<s<<endl;

        return ;

    }

    rep(j,k+1){

        char c = 'a' + j;

        dfs(s+c,(j==k)?(k+1):k);

    }

}



// void dfs(string s,char mx){

//     if(s.size()==n){

//         ans.pb(s);

//         return ;

//     }

//     for(char c='a';c<=mx;c++){

//         dfs(s+c,(c==mx)?(char)(mx+1):mx);

//     }

// }



int main(){

cin.tie(0);

ios::sync_with_stdio(false);



cin>>n;

dfs("",0);





// system("pause");

return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



signed main(){

  int n; cin >> n;

  n--;

  vector<string> now{"a"};

  while(n--){

    vector<string> next;

    for(auto const &s: now){

      int c = *max_element(s.begin(),s.end()) - 'a';

      for(int i=0; i <= c+1; i++){

        next.push_back(s + (char)(i + (int)'a'));

      }

    }

    now = next;

  }

  

  sort(now.begin(), now.end());

  for(auto const &s: now) cout << s << endl;

  

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.106490409443632x):
#include <bits/stdc++.h>

using namespace std;



signed main(){

  int n; cin >> n;

  n--;

  vector<string> now{"a"};

  while(n--){

    vector<string> next;

    for(const auto &S: now){

      char c = *(max_element(S.begin(), S.end()));

      c++;

      for(char d='a'; d<=c; d++){

        next.push_back(S + d);

      }

    }

    now = next;

  }

  

  for(const auto &S: now){

    cout << S << endl;

  }

  

  return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <string>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <iomanip>

#define ll long long

using namespace std;



int N;

vector<char> vector_of_chars = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};



int num_of_char(char ch)

{

  for (int i = 0; i < N; i++)

  {

    if (ch == vector_of_chars[i])

    {

      return i;

    }

  }

  cout << "SWW" << endl;

  return 10;

}



char next_c(char ch)

{

  int num = num_of_char(ch);

  if (num >= N)

  {

    return 'z';

  }

  return vector_of_chars[num + 1];

}



// int largest_num_of_char(string str)

// {

//   int ret = 0;

//   for (int i = 0; i < str.size(); i++)

//   {

//     ret = max(ret, num_of_char(str[i]));

//   }

//   return ret;

// }



vector<int> next_vector_of_int(vector<int> vec);



// vector<int> string_to_vector_of_int(string str)

// {

//   vector<int> vec = {};

//   for (int i = 0; i < str.size(); i++)

//   {

//     vec.push_back(num_of_char(str[i]));

//   }

//   return vec;

// }



string vector_of_int_to_string(vector<int> vec)

{

  string str = "";

  for (int i = 0; i < vec.size(); i++)

  {

    str.push_back(vector_of_chars[vec[i]]);

  }

  return str;

}



// vecの0~i番目の中で最大の整数

int largest_int(vector<int> vec, int i)

{

  int ret = 0;

  for (int j = 0; j <= i; j++)

  {

    ret = max(ret, vec[j]);

  }

  return ret;

}



int main()

{

  cin >> N;

  vector_of_chars.resize(N);



  vector<int> last_vector_of_int = {};

  for (int i = 0; i < N; i++)

  {

    last_vector_of_int.push_back(i);

  }



  vector<int> vec(N, 0);



  while (vec != last_vector_of_int)

  {

    cout << vector_of_int_to_string(vec) << endl;

    vec = next_vector_of_int(vec);

  }

  cout << vector_of_int_to_string(last_vector_of_int) << endl;

  return 0;

}



vector<int> next_vector_of_int(vector<int> vec)

{

  vector<int> next_v = vec;



  while (true)

  {

    // 左からi番目(0-index)の整数を+1できるか？

    bool ok = false;

    for (int i = N - 1; i > 0; i--)

    {

      int lar = largest_int(vec, i - 1);

      if (vec[i] <= lar)

      {

        next_v[i]++;

        if (i != N - 1)

        {

          for (int j = i + 1; j < N; j++)

          {

            next_v[j] = 0;

          }

        }

        ok = true;

        break;

      }

    }

    if (ok)

    {

      break;

    }

  }



  return next_v;

}

// Faster C++ solution for the same problem (measured speedup: 1.1573186006136855x):
#include <iostream>

#include <vector>

#include <string>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <iomanip>

#define ll long long

using namespace std;



int N;



void dfs(string s, char mx)

{

  if (s.length() == N)

  {

    cout << s << endl;

  }

  else

  {

    for (char c = 'a'; c <= mx; c++)

    {

      dfs(s + c, (mx == c) ? mx + 1 : mx);

    }

  }

}



int main()

{

  cin >> N;

  dfs("", 'a');

  return 0;

}
// Slower C++ solution:
// pana1-4

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

typedef pair<ll, P>IP;

typedef vector<ll> V;

typedef vector<V> V2;

typedef vector<vector<P> > G;

void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}

void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}

#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)

#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)

#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)

#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)

template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}

template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

const ll INF = 1145141919;

const ll MOD = 1000000007;

const ll NUM = 101010;



ll v[10];

void inc(ll pos){

    v[pos]++;

    if(pos == 0)return;

    ll flg = 0;

    for(ll i = 0; i < pos; i++){

        if(v[i] + 1 >= v[pos])return;

    }

    v[pos] = 0;

    inc(pos - 1);

}





int main(){



    ll N;

    cin >> N;

    for(;v[0] == 0;){

        rep(i, N)cout << (char)(v[i] + 'a');

        cout << endl;

        inc(N - 1);

    }



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1611902680073658x):
//

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

typedef pair<ll, P>IP;

typedef vector<ll> V;

typedef vector<V> V2;

typedef vector<vector<P> > G;

void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}

void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}

#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)

#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)

#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)

#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)

template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}

template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

const ll INF = 1145141919;

const ll MOD = 1000000007;

const ll NUM = 101010;



void inc(string &s, ll pos){

    s[pos]++;

    if(pos == 0)return;

    rep(i, pos)if(s[i] + 1 >= s[pos])return;

    s[pos] = 'a';

    inc(s, pos - 1);

}



int main(){



    ll N;

    cin >> N;

    string ans(N, 'a');

    while(ans[0] == 'a'){

        cout << ans << endl;

        inc(ans, N - 1);

    }



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define rep(i, n) for (int i = 0; i < (n); i++)



using namespace std;



using int64 = int64_t;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  int n;

  cin >> n;

  if (n == 1) {

    cout << 'a';

  }

  queue<string> q;

  q.push("a");

  while (true) {

    string s = q.front();

    q.pop();

    if ((int)s.length() == n + 1) break;

    char mxS = *max_element(s.begin(), s.end());

    for (char c = 'a'; c <= mxS + 1; c++) {

      string ss = s;

      ss += c;

      if ((int)ss.length() == n) {

        cout << ss << '\n';

      }

      q.push(ss);

    }

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1499281837134139x):
#include <bits/stdc++.h>



#define rep(i, n) for (int i = 0; i < (n); i++)



using namespace std;



using int64 = int64_t;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  int n;

  cin >> n;

  if (n == 1) {

    cout << 'a';

  }

  queue<string> q;

  q.push("a");

  while (true) {

    string s = q.front();

    q.pop();

    if ((int)s.length() == n) break;

    char mxS = *max_element(s.begin(), s.end());

    for (char c = 'a'; c <= mxS + 1; c++) {

      string ss = s;

      ss += c;

      if ((int)ss.length() == n) {

        cout << ss << '\n';

      }

      q.push(ss);

    }

  }

  return 0;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

vector<string> vs;

int n;

void dfs(string s,int cnt,char c){

  if(cnt==n){

    vs.push_back(s);

    return;

  }

  for(int i=0;i<c-'a'+2;i++){

    char x=i+'a';

    dfs(s+x,cnt+1,max(c,x));

  }

}

int main(){

  cin >> n;

  string s="a";

  dfs(s,1,'a');

  sort(vs.begin(),vs.end());

  for(auto& x:vs)cout << x << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.1571969855709943x):
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

vector<string> vs;

int n;

void dfs(string s,int cnt,char c){

  if(cnt==n){

    cout << s << endl;

    return;

  }

  for(int i=0;i<c-'a'+2;i++){

    char x=i+'a';

    dfs(s+x,cnt+1,max(c,x));

  }

}

int main(){

  cin >> n;

  string s="a";

  dfs(s,1,'a');

  sort(vs.begin(),vs.end());

  for(auto& x:vs)cout << x << endl;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

vector<string> vs;

int n;

void dfs(string s,int cnt,char c){

  if(cnt==n){

    vs.push_back(s);

    return;

  }

  for(int i=0;i<c-'a'+2;i++){

    char x=i+'a';

    dfs(s+x,cnt+1,max(c,x));

  }

}

int main(){

  cin >> n;

  string s="a";

  dfs(s,1,'a');

  sort(vs.begin(),vs.end());

  for(auto& x:vs)cout << x << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.1555439731716104x):
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

int n;

void dfs(string s,int cnt,char c){

  if(cnt==n){

    cout << s << endl;

    return;

  }

  for(char i='a';i<=c+1;i++){

    dfs(s+i,cnt+1,max(c,i));

  }

}

int main(){

  cin >> n;

  dfs("a",1,'a');

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

vector<string> vs;

int n;

void dfs(string s,int cnt,char c){

  if(cnt==n){

    vs.push_back(s);

    return;

  }

  for(int i=0;i<c-'a'+2;i++){

    char x=i+'a';

    dfs(s+x,cnt+1,max(c,x));

  }

}

int main(){

  cin >> n;

  string s="a";

  dfs(s,1,'a');

  sort(vs.begin(),vs.end());

  for(auto& x:vs)cout << x << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.156099071174898x):
#include<iostream>

#include<algorithm>

using namespace std;

int n;

void dfs(string s,int cnt,char c){

  if(cnt==n)cout << s << endl;

  else for(char i='a';i<=c+1;i++)dfs(s+i,cnt+1,max(c,i));

}

int main(){

  cin >> n;

  dfs("a",1,'a');

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

#define MOD 1000000007

#define MAX 100



int main(){

  int N;

  cin>>N;

  vector<vector<pair<string,int>>> S(N);

  S.at(0).push_back(make_pair("a",1));

  for(int i=1;i<N;i++){

    for(auto T :S.at(i-1)){

      for(int j=0;j<T.second+1;j++){

        string TT=T.first;

        TT.push_back((char)('a'+j));

        S.at(i).push_back(make_pair(TT,max(T.second,j+1)));

      }

    }

  }

  sort(S.at(N-1).begin(),S.at(N-1).end());

  int n=S.at(N-1).size();

  for(int i=0;i<n;i++){

    cout<<S.at(N-1).at(i).first<<endl;

  }

}


// Faster C++ solution for the same problem (measured speedup: 1.2335388298755916x):
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

#define MAX 300003

#define MOD 1000000007

#define INF 1000000000000000000

using Graph=vector<vector<int>>;



int N;



void dfs(string S,int n){

  if(S.size()==N){

    cout<<S<<endl;

    return ;

  }

  for(int i=0;i<=n;i++){

    char c=(char)('a'+i);

    S.push_back(c);

    dfs(S,max(n,i+1));

    S.pop_back();

  }

}



int main(){

  string S;

  cin>>N;

  dfs(S,0);

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

using namespace std;

int n;

int ans[11];

bool vis[30];

void dfs(int x) {

	if (x == n) {

		for (int i = 1; i <= n; i++) {

			cout << (char)(ans[i] + 'a');

		}

		puts("");

		return;

	}

	for (int i = 0; i <= 26; i++) {

		if (vis[i]) {

			ans[x + 1] = i;

			dfs(x + 1);

		} else {

			vis[i] = 1;

			ans[x + 1] = i;

			dfs(x + 1);

			vis[i] = 0;

			break;

		}

		

	}

}

int main() {

	cin >> n;

	dfs(0);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1104987172079672x):
# include <bits/stdc++.h>

# define rr register

const int N=15;

int a[N];

int n;

int ans;

inline int read(void){

	int res,f=1;

	char c;

	while((c=getchar())<'0'||c>'9')

		if(c=='-')f=-1;

	res=c-48;

	while((c=getchar())>='0'&&c<='9')

		res=res*10+c-48;

	return res*f;	

}

void dfs(int i,int maxx){

	if(i>n){

		for(rr int j=1;j<=n;++j){

			putchar(a[j]+'a'-1);

		}

		puts("");

		return;

	}



	for(rr int j=1;j<=maxx;++j){

		a[i]=j;		

		dfs(i+1,maxx);		

	}



	a[i]=maxx+1;

	dfs(i+1,maxx+1);

	return;

}

int main(void){

//	freopen("testdata.out","w",stdout);

	n=read();

	if(n==1){

		printf("a");

		return 0;

	}

	dfs(1,0);

	

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

typedef long long ll;



vector<string> ans;

int n;



void dfs(string &s, char c, int i){

    if(i == n){

        ans.push_back(s);

        return;

    }

    for(char a = 'a'; a <= c+1; a++){

        s += a;

        dfs(s, max(a,c), i+1);

        s.pop_back();

    }

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin >> n;

    string tmp = "a";

    dfs(tmp, 'a', 1);

    sort(ans.begin(), ans.end());

    for(string &s : ans)    cout << s << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1142083966201595x):
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

typedef long long ll;



vector<string> ans;

int n;



void dfs(string &s, char c, int i){

    if(i == n){

        ans.push_back(s);

        return;

    }

    for(char a = 'a'; a <= c+1; a++){

        s += a;

        dfs(s, max(a,c), i+1);

        s.pop_back();

    }

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin >> n;

    string tmp = "a";

    dfs(tmp, 'a', 1);

    //sort(ans.begin(), ans.end());

    for(string &s : ans)    cout << s << endl;

    return 0;

}
// Slower C++ solution:


/**

 *    Coded by : lucky_21

 *               --------Lokesh Singh

**/



#include<bits/stdc++.h>

using namespace std;



#include <ext/pb_ds/tree_policy.hpp>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define     F           first

#define     S           second

#define     pb          push_back

#define     lb          lower_bound

#define     ub          upper_bound

#define     pii         pair<int,int>

#define     all(x)      x.begin(),x.end()

#define     fix         fixed<<setprecision(10)

#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)

#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)

#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)



typedef double d;

typedef long long ll;



const int N=2e5+5;

const int mod=1e9+7;



int n;

vector<string>v;

void rec(int i,string s){

    int maxi=-1;

    bool ok[10]{0};

    for(char c:s){

        ok[c-'a']=1;

        maxi=max(maxi,int(c-'a'));

    }

    rep(j,0,maxi){

        if(!ok[j]) return;

    }

    if(i==n){

        v.pb(s);

        return;

    }

    rep(j,0,i){

        rec(i+1,s+char('a'+j));

    }

}

signed main(){

    FastIO;

    cin>>n;

    rec(0,"");

    sort(all(v));

//    cout<<v.size();

    for(string s:v) cout<<s<<'\n';

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.2221806527257497x):


/**

 *    Coded by : lucky_21

 *               --------Lokesh Singh

**/



#include<bits/stdc++.h>

using namespace std;



#include <ext/pb_ds/tree_policy.hpp>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define     F           first

#define     S           second

#define     pb          push_back

#define     lb          lower_bound

#define     ub          upper_bound

#define     pii         pair<int,int>

#define     all(x)      x.begin(),x.end()

#define     fix         fixed<<setprecision(10)

#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)

#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)

#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)



typedef double db;

typedef long long ll;



const int N=2e5+5;

const int mod=1e9+7;



int n;

void solve(string s,char mx){

    if(s.size()==n){

        cout<<s<<'\n';

        return;

    }

    for(char c='a';c<=mx;c++){

        solve(s+c,(c==mx?mx+1:mx));

    }

}

signed main(){

    FastIO;

    cin>>n;

    solve("",'a');

    return 0;

}
// Slower C++ solution:
#include <vector>

#include <list>

#include <map>

#include <set>

#include <queue>

#include <deque>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cstring>



using namespace std;



#define MAX 100000

#define INF 2140000000

#define MOD 1000000007



vector<string> ans;



void fun(string s, int k, int dist, int n) {

	if (k == n) {

		ans.push_back(s);

	}

	else {

		for (int i = 0; i < dist; ++i) {

			string temp = s + (char)('a' + i);



			if (i == dist - 1) {

				fun(temp, k + 1, dist + 1, n);

			}

			else {

				fun(temp, k + 1, dist, n);

			}

		}

	}



	return;

}



int main() {

	int n;

	cin >> n;



	string s = "a";



	fun(s, 1, 2, n);



	sort(ans.begin(), ans.end());



	for (int i = 0; i < (int) ans.size(); ++i) {

		cout << ans[i] << endl;

	}



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1597681768634547x):
#include <vector>

#include <list>

#include <map>

#include <set>

#include <queue>

#include <deque>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cstring>



using namespace std;



#define MAX 100000

#define INF 2140000000

#define MOD 1000000007



vector<string> ans;



void fun(string s, int k, int dist, int n) {

	if (k == n) {

		cout << s << endl;

	}

	else {

		for (int i = 0; i < dist; ++i) {

			string temp = s + (char)('a' + i);



			if (i == dist - 1) {

				fun(temp, k + 1, dist + 1, n);

			}

			else {

				fun(temp, k + 1, dist, n);

			}

		}

	}



	return;

}



int main() {

	int n;

	cin >> n;



	string s = "a";



	fun(s, 1, 2, n);



	return 0;

}
// Slower C++ solution:
#include "bits/stdc++.h"

using namespace std;

#define ll long long int

#define rep(i,n) for( int i = 0; i < n; i++ )

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000



vector<string> v;

int N; 

void dfs(string& S, int p, int depth) {

    //cout << S << " " << depth << endl;

    if (depth >= N) {

        v.push_back(S);

        return;

    }

    rep(i, p + 1) {

        S += 'a' + i;

        dfs(S, max(i + 1, p), depth + 1);

        S.pop_back();

    }

}





int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin >> N;

    string S = "";

    dfs(S, 0, 0);

    sort(v.begin(), v.end());

    rep(i, v.size()) {

        cout << v[i] << endl;

    }





    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.1063656046696697x):
#include <iostream>

#include <fstream>

#include <set>

#include <map>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <stack>

#include <functional>

#include <algorithm>

#include <climits>

#include <cmath>

#include <iomanip>

using namespace std;

#define ll long long int

#define rep(i,n) for( int i = 0; i < n; i++ )

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000



vector<string> T;

int N;

void dfs(string S = "", int depth = 0, int c = 1) {

    if (depth >= N) {

        T.push_back(S);

        return;

    }

    rep(i, c) {

        S.push_back('a' + i);

        dfs(S, depth + 1, max(c, i + 2));

        S.pop_back();

    }

}



int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin >> N;

    dfs();

    for(auto& e: T) {

        cout << e << endl;

    }



    return 0;

}