#include <bits/stdc++.h>
using namespace std;
void zFunction(int frst, int lst, string ch, int z[]) {
  int lft = -1, rght = -1, t, i, j, k;
  for (i = frst + 1; i <= lst; i++) z[i] = 0;
  for (i = frst + 1; i <= lst; i++) {
    if (ch[i] != ch[frst])
      z[i] = 0;
    else if (i > rght) {
      lft = rght = i;
      for (j = i, k = frst; j <= lst && ch[j] == ch[k]; j++, k++) rght = j;
      z[i] = rght - lft + 1;
    } else {
      t = i - lft + frst;
      if (z[t] < rght - i + 1)
        z[i] = z[t];
      else {
        lft = i;
        for (j = rght, k = rght - lft + frst; j <= lst && ch[j] == ch[k];
             j++, k++)
          rght = j;
        z[i] = rght - lft + 1;
      }
    }
  }
}
const int N = 5010;
int n, b, e, sz, z[2 * N];
string s, t, ch, w[N], w2[N], tmp, tmp2;
vector<pair<pair<int, int>, string>> v;
bool fnd, vld;
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> w[i];
  }
  fnd = 0;
  for (int i = 1; i <= n; i++) {
    cin >> w2[i];
    fnd = 0;
    sz = w2[i].size();
    for (int j = 0; j < sz; j++) {
      if (w[i][j] != w2[i][j]) {
        if (!fnd) b = j;
        e = j;
        fnd = 1;
      }
    }
    if (fnd) {
      s = "";
      t = "";
      for (int j = b; j <= e; j++) {
        s += w[i][j];
        t += w2[i][j];
      }
      v.push_back(make_pair(make_pair(i, b), s));
    }
  }
  for (int i = 1, j, k; i < v.size(); i++) {
    if (v[i].second != v[i - 1].second) {
      cout << "NO\n";
      return;
    }
  }
  tmp = "";
  for (int x = 1;; x++) {
    if (v[0].first.second >= x) {
      vld = 1;
      for (int i = 1, j, k; i < v.size(); i++) {
        j = v[i].first.first;
        k = v[i].first.second;
        if (k < x ||
            w[j][k - x] != w[v[i - 1].first.first][v[i - 1].first.second - x]) {
          vld = 0;
          break;
        }
      }
      if (vld) {
        tmp += w[v[0].first.first][v[0].first.second - x];
      } else
        break;
    } else
      break;
  }
  reverse(tmp.begin(), tmp.end());
  tmp2 = "";
  for (int x = 1;; x++) {
    if (v[0].first.second + s.size() - 1 + x < w[v[0].first.first].size()) {
      vld = 1;
      for (int i = 1, j, k; i < v.size(); i++) {
        j = v[i].first.first;
        k = v[i].first.second + s.size() - 1;
        if (k + x >= w[j].size() ||
            w[j][k + x] != w[v[i - 1].first.first]
                            [v[i - 1].first.second + s.size() - 1 + x]) {
          vld = 0;
          break;
        }
      }
      if (vld) {
        tmp2 += w[v[0].first.first][v[0].first.second + s.size() - 1 + x];
      } else
        break;
    } else
      break;
  }
  s = tmp + s + tmp2;
  t = tmp + t + tmp2;
  for (int i = 1; i <= n; i++) {
    ch = s + w[i];
    sz = ch.size();
    zFunction(0, sz - 1, ch, z);
    sz = s.size();
    for (int j = sz; j < ch.size(); j++) {
      if (z[j] >= sz) {
        b = j - sz;
        e = b + sz - 1;
        for (int k = b; k <= e; k++) w[i][k] = t[k - b];
        break;
      }
    }
    if (w[i] != w2[i]) {
      cout << "NO\n";
      return;
    }
  }
  cout << "YES\n" << s << "\n" << t << "\n";
}
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
