#include <bits/stdc++.h>
using namespace std;
const int maxn = 3010;
string a[maxn], b[maxn];
int mini[maxn], maxi[maxn];
string s;
string curkmp;
int pf[2 * maxn];
bool toch[maxn];
signed main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    mini[i] = -1;
    for (int j = 0; j < a[i].length(); j++) {
      if (a[i][j] != b[i][j]) {
        if (mini[i] == -1) mini[i] = j;
        maxi[i] = j;
      }
    }
    toch[i] = (mini[i] != -1);
  }
  if (!toch[0]) {
    for (int i = 1;; i++) {
      if (toch[i]) {
        swap(a[0], a[i]);
        swap(b[0], b[i]);
        swap(mini[0], mini[i]);
        swap(maxi[0], maxi[i]);
        swap(toch[0], toch[i]);
        break;
      }
    }
  }
  for (int i = 1; i < n; i++) {
    if (!toch[i]) continue;
    if (maxi[i] - mini[i] != maxi[0] - mini[0]) {
      cout << "NO";
      return 0;
    }
    for (int j = 0; j <= maxi[i] - mini[i]; j++) {
      if (a[i][mini[i] + j] != a[0][mini[0] + j] ||
          b[i][mini[i] + j] != b[0][mini[0] + j]) {
        cout << "NO";
        return 0;
      }
    }
  }
  while (true) {
    for (int i = 0; i < n; i++) {
      if (!toch[i]) continue;
      if (mini[i] == 0) goto endd;
      if (a[i][mini[i] - 1] != a[0][mini[0] - 1]) goto endd;
    }
    for (int i = 0; i < n; i++) {
      mini[i]--;
    }
  }
endd:;
  while (true) {
    for (int i = 0; i < n; i++) {
      if (!toch[i]) continue;
      if (maxi[i] == a[i].length() - 1) goto endd2;
      if (a[i][maxi[i] + 1] != a[0][maxi[0] + 1]) goto endd2;
    }
    for (int i = 0; i < n; i++) {
      maxi[i]++;
    }
  }
endd2:;
  s = a[0].substr(mini[0], maxi[0] - mini[0] + 1);
  for (int snum = 0; snum < n; snum++) {
    curkmp = s + "*" + a[snum];
    fill(pf, pf + curkmp.length(), 0);
    for (int i = 1; i < curkmp.length(); i++) {
      int j = pf[i - 1];
      while (j > 0 && curkmp[i] != curkmp[j]) j = pf[j - 1];
      if (curkmp[i] == curkmp[j]) j++;
      pf[i] = j;
      if (pf[i] == s.length()) {
        if (!toch[snum] || i != maxi[snum] + s.length() + 1) {
          cout << "NO";
          return 0;
        }
        break;
      }
    }
  }
  cout << "YES\n";
  cout << s << "\n";
  cout << b[0].substr(mini[0], maxi[0] - mini[0] + 1);
  return 0;
}
