#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000009;
const int MAXN = 3000;
int n;
string w[MAXN + 3], v[MAXN + 3];
vector<pair<int, pair<int, int>>> L;
bool Check1() {
  for (int i = 1; i < L.size(); i++) {
    int ind = L[i].first;
    int a = L[i].second.first;
    int b = L[i].second.second;
    int ind2 = L[i - 1].first;
    int c = L[i - 1].second.first;
    int d = L[i - 1].second.second;
    if (w[ind].substr(a, b - a + 1) != w[ind2].substr(c, d - c + 1) ||
        v[ind].substr(a, b - a + 1) != v[ind2].substr(c, d - c + 1))
      return false;
  }
  return true;
}
bool Check2(int A, int B) {
  for (int i = 0; i < L.size(); i++) {
    int ind = L[i].first;
    int a = L[i].second.first - A;
    int b = L[i].second.second + B;
    if (a < 0 || b >= w[ind].size()) return false;
    if (i > 0) {
      int ind2 = L[i - 1].first;
      int c = L[i - 1].second.first - A;
      int d = L[i - 1].second.second + B;
      if (c < 0 || d >= w[ind2].size()) return false;
      if (w[ind][a] != w[ind2][c] || v[ind][a] != v[ind2][c] ||
          w[ind][b] != w[ind2][d] || v[ind][b] != v[ind2][d])
        return false;
    }
  }
  return true;
}
int tps[2 * MAXN + 3];
int kmpFind(string &text, string &pattern) {
  string glued = pattern + "#" + text;
  tps[0] = 0;
  for (int i = 1; i < glued.size(); i++) {
    int d = tps[i - 1];
    while (glued[d] != glued[i] && d > 0) d = tps[d - 1];
    if (glued[d] == glued[i]) d++;
    tps[i] = d;
  }
  for (int i = pattern.size() + 1; i < glued.size(); i++) {
    if (tps[i] == (int)pattern.size()) return i - 2 * (int)pattern.size();
  }
  return INF;
}
bool KMP(string &pattern, string &reppattern) {
  for (int i = 0; i < n; i++) {
    int pos = kmpFind(w[i], pattern);
    if (pos < w[i].size()) w[i].replace(pos, reppattern.size(), reppattern);
    if (w[i] != v[i]) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> w[i];
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) {
    if (w[i] == v[i]) continue;
    int a = 0;
    while (w[i][a] == v[i][a]) a++;
    int b = w[i].size() - 1;
    while (w[i][b] == v[i][b]) b--;
    L.push_back(make_pair(i, make_pair(a, b)));
  }
  if (!Check1())
    cout << "NO\n";
  else {
    int i = 0;
    while (Check2(i + 1, 0)) i++;
    int j = 0;
    while (Check2(i, j + 1)) j++;
    string res1 = w[L[0].first].substr(
        L[0].second.first - i,
        (L[0].second.second + j) - (L[0].second.first - i) + 1);
    string res2 = v[L[0].first].substr(
        L[0].second.first - i,
        (L[0].second.second + j) - (L[0].second.first - i) + 1);
    if (KMP(res1, res2))
      cout << "YES\n" << res1 << "\n" << res2 << "\n";
    else
      cout << "NO\n";
  }
  return 0;
}
