#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 17;
string s[maxn];
string t[maxn];
string a, b;
int mn[maxn], mx[maxn], f[maxn];
int n;
int mat(string &s, string &p) {
  int k = 0;
  for (int i = 1; i < p.size(); i++) {
    while (k && p[k] != p[i]) k = f[k];
    if (p[k] == p[i]) k++;
    f[i + 1] = k;
  }
  k = 0;
  for (int i = 0; i < s.size(); i++) {
    while (k && p[k] != s[i]) k = f[k];
    if (p[k] == s[i]) k++;
    if (k == p.size()) return i - p.size() + 1;
  }
  return maxn;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  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++) {
    mn[i] = maxn;
    for (int j = 0; j < s[i].size(); j++)
      if (s[i][j] != t[i][j]) mn[i] = min(mn[i], j), mx[i] = max(mx[i], j);
    if (mn[i] == maxn) continue;
    string t1, t2;
    t1 = s[i].substr(mn[i], mx[i] - mn[i] + 1);
    t2 = t[i].substr(mn[i], mx[i] - mn[i] + 1);
    if (a == "")
      a = t1, b = t2;
    else if (a != t1 || b != t2)
      return cout << "NO" << '\n', 0;
    swap(s[0], s[i]);
    swap(t[0], t[i]);
    swap(mn[0], mn[i]);
    swap(mx[0], mx[i]);
  }
  int l = 0;
  while (true) {
    bool ok = 1;
    for (int i = 0; ok && i < n; i++)
      if (mn[i] != maxn)
        ok &= mn[i] - 1 - l >= 0 && s[i][mn[i] - l - 1] == s[0][mn[0] - l - 1];
    if (ok)
      l++;
    else
      break;
  }
  int r = 0;
  while (true) {
    bool ok = 1;
    for (int i = 0; ok && i < n; i++)
      if (mn[i] != maxn)
        ok &= mx[i] + 1 + r < s[i].size() &&
              s[i][mx[i] + r + 1] == s[0][mx[0] + r + 1];
    if (ok)
      r++;
    else
      break;
  }
  a = s[0].substr(mn[0] - l, l + mx[0] - mn[0] + 1 + r);
  b = t[0].substr(mn[0] - l, l + mx[0] - mn[0] + 1 + r);
  bool ok = 1;
  for (int i = 0; i < n; i++)
    if (mn[i] != maxn)
      ok &= mat(s[i], a) == mn[i] - l;
    else
      ok &= mat(s[i], a) == maxn;
  if (ok)
    cout << "YES" << '\n' << a << '\n' << b << '\n';
  else
    cout << "NO" << '\n';
}
