#include <bits/stdc++.h>
using namespace std;
const long long N = 3005;
string A[N], B[N];
long long solve() {
  long long n;
  cin >> n;
  for (__typeof((n)) i = (1); i <= (n); i++) cin >> A[i];
  for (__typeof((n)) i = (1); i <= (n); i++) cin >> B[i];
  string st, rt, core_s, core_r;
  long long stt, ett;
  for (__typeof((n)) j = (1); j <= (n); j++) {
    long long l = A[j].size();
    long long l1 = -1;
    long long r1 = -1;
    for (__typeof((l - 1)) i = (0); i <= (l - 1); i++) {
      if (A[j][i] != B[j][i]) {
        l1 = i;
        break;
      }
    }
    for (__typeof((l - 1)) i = (l - 1); i >= (0); i--) {
      if (A[j][i] != B[j][i]) {
        r1 = i;
        break;
      }
    }
    if (l1 != -1) {
      if (st.empty()) {
        core_s = A[j].substr(l1, r1 - l1 + 1);
        core_r = B[j].substr(l1, r1 - l1 + 1);
        st = A[j];
        rt = B[j];
        stt = l1;
      } else {
        if (A[j].substr(l1, r1 - l1 + 1) != core_s or
            B[j].substr(l1, r1 - l1 + 1) != core_r) {
          cout << "NO" << endl;
          return 0;
        } else {
          ett = stt + core_s.size() - 1;
          for (long long u = ett + 1; u < (long long)st.size(); u++) {
            r1++;
            if (r1 == B[j].size() or st[u] != A[j][r1]) {
              st = st.substr(0, u);
              rt = rt.substr(0, u);
              break;
            }
          }
          for (long long u = stt - 1; u >= 0; u--) {
            l1--;
            if (l1 < 0 or st[u] != A[j][l1]) {
              st = st.substr(u + 1);
              rt = rt.substr(u + 1);
              stt = stt - (u + 1);
              break;
            }
          }
        }
      }
    }
  }
  for (__typeof((n)) j = (1); j <= (n); j++) {
    string s = st + '$' + A[j];
    long long m = s.size();
    vector<long long> z(m);
    for (long long i = 1, l = 0, r = 0; i < m; ++i) {
      if (i <= r) z[i] = min(r - i + 1, z[i - l]);
      while (i + z[i] < m && s[z[i]] == s[i + z[i]]) ++z[i];
      if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
      if (z[i] >= st.size()) {
        long long id = i - (st.size() + 1);
        for (char c : rt) {
          A[j][id] = c;
          id++;
        }
        break;
      }
    }
    if (A[j] != B[j]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  cout << st << "\n" << rt << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  long long t;
  t = 1;
  while (t--) solve();
  return 0;
}
