#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
set<string> ss;
string f(string s) {
  char c = 'a';
  string res = s;
  vector<int> v(s.size());
  for (int i = 0; i < v.size(); i++) v[i] = i;
  do {
    string t = s;
    for (int i = 0; i < t.size(); i++) {
      t[i] = 'a' + v[t[i] - 'a'];
    }
    if (res > t) res = t;
  } while (next_permutation(v.begin(), v.end()));
  return res;
}
void rec(string now, vector<char> alpha) {
  if (now.size() == alpha.size()) {
    ss.insert(f(now));
    return;
  }
  for (int i = 0; i < alpha.size(); i++) {
    rec(now + alpha[i], alpha);
  }
}
int main() {
  int n;
  cin >> n;
  vector<char> alpha(n);
  for (int i = 0; i < n; i++) alpha[i] = 'a' + i;
  rec("", alpha);
  for (auto it = ss.begin(); it != ss.end(); it++) {
    cout << *it << endl;
  }
  cout << ss.size() << endl;
  return 0;
}
