#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;

bool doit(const vector<int>& poss, const vector<set<int>>& restrict, vector<int>& cur, vector<vector<int>>& s) {
  int i;
  for (i = 0; i < 26; i++) if (cur[i] == -1 && (poss[i] == 1 || poss[i] == 2 || poss[i] == 4)) goto found;
  for (i = 0; i < 26; i++) if (cur[i] == -1 && poss[i] > 0 && poss[i] < 7) goto found;
  for (i = 0; i < 26; i++) if (cur[i] == -1 && poss[i] > 0) goto found;
  return true;
found:
  for (cur[i] = 0; cur[i] <= 2; cur[i]++) if (poss[i] & (1<<cur[i])) if (s[cur[i]].size() < 6) {
    vector<int> poss2 = poss;
    for (auto j : restrict[i]) {
      poss2[j] &= ~(1<<cur[i]);
      if (poss2[j] == 0) goto fail;
    }
    s[cur[i]].push_back(i);
    if (doit(poss2, restrict, cur, s)) return true;
    s[cur[i]].pop_back();
fail:;
  }
  cur[i] = -1;
  return false;
}

int main() {
  int N;
  while (cin >> N) {
    vector<string> W(N);
    vector<int> cur(26, -1), poss(26);
    vector<vector<int>> s(3);
    vector<set<int>> restrict(26);
    for (auto& w : W) cin >> w;
    for (auto const& w : W) for (auto ch : w) poss[ch-'a'] = 7;
    for (auto const& w : W) for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) if (i != j) {
      if (w[i] == w[j]) goto fail;
      restrict[w[i]-'a'].insert(w[j]-'a');
    }
    if (!doit(poss, restrict, cur, s)) goto fail;

    for (int si = 0; si < 3; si++) {
      while (s[si].size() < 6) {
        for (int i = 0; ; i++) if (cur[i] == -1) {
          cur[i] = si;
          s[si].push_back(i);
          break;
        }
      }
      for (auto i : s[si]) cout << char(i+'a');
      if (si < 2) cout << ' '; else cout << endl;
    }
    continue;
fail:
    cout << 0 << endl;
  }
}
