#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 998244353;
const int MAXN = (int)1e5 + 5;
int kmp(const string &T, const string &P) {
  if (P.empty()) return 0;
  vector<int> pi(P.size(), 0);
  for (int i = 1, k = 0; i < P.size(); ++i) {
    while (k && P[k] != P[i]) k = pi[k - 1];
    if (P[k] == P[i]) ++k;
    pi[i] = k;
  }
  for (int i = 0, k = 0; i < T.size(); ++i) {
    while (k && P[k] != T[i]) k = pi[k - 1];
    if (P[k] == T[i]) ++k;
    if (k == P.size()) return i - k + 1;
  }
  return -1;
}
int n;
string s, t;
string st[3005], en[3005];
char sind[3005];
bool same[3005];
int foundpos[3005];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%s", sind);
    st[i] = sind;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%s", sind);
    en[i] = sind;
  }
  int lb = -1, rb = 0, mlb, mrb, stidx = -1;
  int i = 0;
  while (i < n) {
    if (st[i].compare(en[i]) != 0) {
      stidx = i;
      same[i] = 0;
      int j = 0;
      while (j < st[i].size()) {
        if (st[i][j] != en[i][j]) {
          if (lb == -1) {
            lb = j;
            foundpos[i] = j;
          }
          rb = max(rb, j);
        }
        ++j;
      }
      mlb = 0, mrb = st[i].size() - 1;
      break;
    } else
      same[i] = 1;
    ++i;
  }
  ++i;
  while (i < n) {
    if (st[i].compare(en[i]) != 0) {
      same[i] = 0;
      int j = 0;
      while (j < st[i].size()) {
        if (st[i][j] != en[i][j]) {
          int kj = j, ki = lb;
          foundpos[i] = j;
          while (ki <= rb && kj < st[i].size()) {
            if (st[stidx][ki] != st[i][kj] || en[stidx][ki] != en[i][kj]) {
              cout << "NO";
              return 0;
            }
            ki++;
            kj++;
          }
          if (kj == st[i].size() && ki != rb + 1) {
            cout << "NO";
            return 0;
          }
          ki = lb - 1;
          int k = j - 1;
          while (k >= 0 && ki >= mlb && st[i][k] == st[stidx][ki]) {
            --k;
            --ki;
          }
          ++ki;
          mlb = ki;
          ki = rb + 1;
          int kjj = kj;
          while (kj < st[i].size())
            if (st[i][kj] != en[i][kj]) {
              cout << "NO";
              return 0;
            } else
              ++kj;
          while (ki <= mrb && kjj < st[i].size() &&
                 st[stidx][ki] == st[i][kjj]) {
            kjj++;
            ki++;
          }
          --ki;
          mrb = ki;
          break;
        }
        ++j;
      }
    } else
      same[i] = 1;
    ++i;
  }
  string needle;
  string t;
  for (int k = mlb; k <= mrb; ++k) {
    needle.push_back(st[stidx][k]);
    t.push_back(en[stidx][k]);
  }
  for (int i = 0; i < n; ++i) {
    if (same[i] && kmp(st[i], needle) > -1) {
      cout << "NO";
      return 0;
    }
    if (!same[i]) {
      int pos = kmp(st[i], needle);
      for (int j = 0; j < needle.size(); ++j)
        if (t[j] != en[i][j + pos]) {
          cout << "NO";
          return 0;
        }
    }
  }
  cout << "YES" << endl << needle << endl << t;
  return 0;
}
