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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
vector<string> v;

vector<string> get(int n , int pos){
	vector<string> aa;
	string ans = "";
	if(pos == n+1){
		aa.pb(ans);
		return aa;
	}
	
	for(int i=1 ; i<=pos ; i++){
		for(auto s : get(n,pos+1)){
			string  ans = to_string(i) + s;
			aa.pb(ans);
		}
	}
	return aa;
}
bool check(string a , string b){
	int ok = 1;
	for(int i=0 ; i<sz(a) ; i++){
		for(int j=0 ; j<sz(b) ; j++){
			if(a[i] == a[j] && b[i] != b[j]) ok = 0;
			if(a[i] != a[j] && b[i] == b[j]) ok = 0;
		}
	}
	return ok;
}
int32_t main(){
	fast;
	int n;
	cin >> n;
	
	auto v = get(n,1);
	sort(all(v));
	int vis[sz(v) + 1] = {0};
	for(int i=0 ; i<sz(v) ; i++){
		for(int j=i+1 ; j<sz(v) ; j++){
			if(check(v[i],v[j]) && vis[j] == 0){
				vis[j] = 1;
			}
		}
	}
	
	for(int i=0 ; i<sz(v) ; i++){
		if(vis[i])  continue;
		for(auto x : v[i]){
			char cc = x - '1' + 'a';
			cout << cc;
		}
		cout << "\n";
	}
}
