#include <bits/stdc++.h>
using namespace std;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int INF = (long long)1e9;
const long long INFLL = (long long)1e18 + 1;
const long long MOD = (long long)1e9 + 7;
const double PI = acos(-1.0);
int N;
set<string> xx;
map<string, int> mapz;
string int_2_string(long long x) {
  map<char, int> mapx;
  map<char, char> mapy;
  string ss = to_string(x);
  string res = "";
  int cnt = 0;
  for (int j = 0; j < int(ss.size()); ++j) {
    if (mapx[ss[j]] == 0) {
      res.push_back(char(cnt + 'a'));
      mapy[ss[j]] = char(cnt + 'a');
      cnt++;
      mapx[ss[j]]++;
    } else {
      res.push_back(mapy[ss[j]]);
    }
  }
  return res;
}
void dfs(int i, long long s, long long minn) {
  if (s != 0 && mapz[int_2_string(s)] > 0) {
    return;
  }
  if (s != 0) mapz[int_2_string(s)]++;
  if (i == N) {
    string res = int_2_string(s);
    xx.insert(res);
    return;
  }
  for (long long nxt = 1; nxt <= N; nxt++) {
    long long nxtmin = max((long long)minn, (long long)nxt);
    long long tmp = s * 10 + nxt;
    dfs(i + 1, tmp, nxtmin);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  cin >> N;
  dfs(0, 0, 1);
  for (auto y : xx) {
    cout << y << endl;
  }
}
