#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int MAXN = 5000;
string s[MAXN], t[MAXN];
int ldiff[MAXN], rdiff[MAXN];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) cin >> t[i];
  for (int i = 0; i < n; i++) {
    ldiff[i] = s[i].size();
    rdiff[i] = -1;
    for (int j = 0; j < s[i].size(); j++)
      if (s[i][j] != t[i][j]) {
        ldiff[i] = min(ldiff[i], j);
        rdiff[i] = max(rdiff[i], j);
      }
  }
  int first = -1;
  for (int i = 0; i < n; i++)
    if (ldiff[i] <= rdiff[i]) {
      first = i;
      break;
    }
  assert(first >= 0);
  bool ok = true;
  int len = rdiff[first] - ldiff[first] + 1;
  vector<int> diffs;
  for (int i = 0; i < n; i++)
    if (ldiff[i] <= rdiff[i]) {
      diffs.push_back(i);
      if (rdiff[i] - ldiff[i] + 1 != len) {
        ok = false;
        break;
      }
      for (int j = 0; j < len; j++)
        if (s[first][ldiff[first] + j] != s[i][ldiff[i] + j] ||
            t[first][ldiff[first] + j] != t[i][ldiff[i] + j]) {
          ok = false;
          break;
        }
      if (!ok) break;
    }
  if (ok) {
    bool can = true;
    while (can && ldiff[first] > 0) {
      for (int i : diffs) {
        if (ldiff[i] == 0 || s[i][ldiff[i] - 1] != s[first][ldiff[first] - 1] ||
            t[i][ldiff[i] - 1] != t[first][ldiff[first] - 1])
          can = false;
      }
      if (can)
        for (int i : diffs) ldiff[i]--;
    }
    can = true;
    while (can && rdiff[first] + 1 < s[first].size()) {
      for (int i : diffs) {
        if (rdiff[i] + 1 == s[i].size() ||
            s[i][rdiff[i] + 1] != s[first][rdiff[first] + 1] ||
            t[i][rdiff[i] + 1] != t[first][rdiff[first] + 1])
          can = false;
      }
      if (can)
        for (int i : diffs) rdiff[i]++;
    }
    string pat = string(s[first].begin() + ldiff[first],
                        s[first].begin() + rdiff[first] + 1);
    string q;
    vector<int> p;
    for (int i = 0; i < n; i++) {
      q = pat;
      q += "#";
      q += s[i];
      p.resize(q.size());
      int start = -1;
      for (int j = 1; j < q.size(); j++) {
        int k = p[j - 1];
        while (k > 0 && q[j] != q[k]) k = p[k - 1];
        if (q[j] == q[k]) k++;
        p[j] = k;
        if (p[j] == pat.size()) {
          start = j;
          break;
        }
      }
      if (ldiff[i] > rdiff[i])
        ok &= start == -1;
      else {
        start -= pat.size() - 1;
        ok &= ldiff[i] == start - pat.size() - 1;
      }
    }
  }
  if (!ok)
    puts("NO");
  else {
    printf("YES\n");
    printf("%s\n", string(s[first].begin() + ldiff[first],
                          s[first].begin() + rdiff[first] + 1)
                       .c_str());
    printf("%s\n", string(t[first].begin() + ldiff[first],
                          t[first].begin() + rdiff[first] + 1)
                       .c_str());
  }
  return 0;
}
