#include <bits/stdc++.h>
using namespace std;
const int N = int(2e5) + 5;
const int inf = (int)1e9 + 7;
int n;
int l[N], r[N];
string f[N], s[N];
vector<int> prefix_function(string s) {
  int n = (int)s.length();
  vector<int> pi(n);
  for (int i = 1; i < n; ++i) {
    int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) ++j;
    pi[i] = j;
  }
  return pi;
}
void doit(string &x, string &from, string &to) {
  vector<int> pf = prefix_function(from + '#' + x);
  int pos = -1;
  for (int i = (int)((from).size()) + 1; i < (int)((pf).size()); ++i) {
    if (pf[i] == (int)((from).size())) {
      pos = i - 2 * (int)((from).size());
      break;
    }
  }
  if (pos == -1) return;
  for (int j = pos; j < pos + (int)((from).size()); ++j) {
    x[j] = to[j - pos];
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> f[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
  }
  string F, S;
  for (int i = 1; i <= n; ++i) {
    l[i] = r[i] = -1;
    for (int j = 0; j < (int)((f[i]).size()); ++j) {
      if (f[i][j] != s[i][j]) {
        if (l[i] == -1) l[i] = j;
        r[i] = j;
      }
    }
    if (l[i] != -1) {
      F = f[i].substr(l[i], r[i] - l[i] + 1);
      S = s[i].substr(l[i], r[i] - l[i] + 1);
    }
  }
  if (F.empty()) {
    cout << "YES\n";
    cout << "a\na";
    return 0;
  }
  for (int i = 1; i <= 5000; ++i) {
    int ok = 1;
    char c = '?';
    char cc = '?';
    for (int j = 1; j <= n; ++j) {
      if (l[j] != -1) {
        if (r[j] + 1 == (int)f[j].size()) {
          ok = 0;
          break;
        }
        if (c == '?') {
          c = f[j][r[j] + 1];
          cc = s[j][r[j] + 1];
        } else {
          if (c != f[j][r[j] + 1] || cc != s[j][r[j] + 1]) {
            ok = 0;
            break;
          }
        }
      }
    }
    if (c == '?' || !ok) break;
    for (int j = 1; j <= n; ++j) {
      if (r[j] != -1) ++r[j];
    }
  }
  for (int i = 1; i <= 5000; ++i) {
    int ok = 1;
    char c = '?';
    char cc = '?';
    for (int j = 1; j <= n; ++j) {
      if (l[j] != -1) {
        if (l[j] == 0) {
          ok = 0;
          break;
        }
        if (c == '?') {
          c = f[j][l[j] - 1];
          cc = s[j][l[j] - 1];
        } else {
          if (c != f[j][l[j] - 1] || cc != s[j][l[j] - 1]) {
            ok = 0;
            break;
          }
        }
      }
    }
    if (c == '?' || !ok) break;
    for (int j = 1; j <= n; ++j) {
      if (l[j] != -1) --l[j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (r[i] != -1) {
      F = f[i].substr(l[i], r[i] - l[i] + 1);
      S = s[i].substr(l[i], r[i] - l[i] + 1);
    }
  }
  for (int i = 1; i <= n; ++i) {
    doit(f[i], F, S);
  }
  for (int i = 1; i <= n; ++i) {
    if (f[i] != s[i]) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n" << F << "\n" << S << "\n";
  return 0;
}
