#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int n, len = -1, lo[3000], hi[3000];
vector<string> w, w2;
vector<pair<int, int> > constructDFA(string m) {
  vector<pair<int, int> > dfa(1, make_pair(-1, 0));
  for (int i = 0; i < (((int)(m).size())); i++) {
    int lps = dfa[i].second;
    dfa[i].first = m[i];
    while (lps > 0 && dfa[lps].first != m[i]) lps = dfa[lps].second;
    if (dfa[lps].first == m[i] && lps != i) lps++;
    dfa.push_back(make_pair(-1, lps));
  }
  return dfa;
}
string apply(string a, string s, string t) {
  vector<pair<int, int> > dfa = constructDFA(s);
  int curr = 0;
  for (int i = 0; i < (((int)(a).size())); i++) {
    while (curr > 0 && dfa[curr].first != a[i]) curr = dfa[curr].second;
    if (dfa[curr].first == a[i]) curr++;
    if (curr == ((int)(s).size())) {
      return a.substr(0, i + 1 - ((int)(s).size())) + t +
             a.substr(i + 1, ((int)(a).size()) - (i + 1));
    }
  }
  return a;
}
void readInput() {
  cin >> n;
  for (int i = 0; i < (n); i++) {
    string s;
    cin >> s;
    w.push_back(s);
  }
  for (int i = 0; i < (n); i++) {
    string s;
    cin >> s;
    w2.push_back(s);
  }
}
void findLoHi() {
  for (int i = 0; i < (n); i++) lo[i] = hi[i] = -1;
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (((int)(w[i]).size())); j++)
      if (w[i][j] != w2[i][j]) {
        if (lo[i] == -1) lo[i] = j;
        hi[i] = j;
      }
}
bool sameChar(int pos) {
  char c1 = -1, c2 = -1;
  for (int i = 0; i < (n); i++)
    if (lo[i] != -1) {
      if (lo[i] + pos < 0 || lo[i] + pos >= ((int)(w[i]).size())) return 0;
      if (c1 == -1) c1 = w[i][lo[i] + pos], c2 = w2[i][lo[i] + pos];
      if (c1 != w[i][lo[i] + pos] || c2 != w2[i][lo[i] + pos]) return 0;
    }
  return 1;
}
bool checkSame() {
  for (int i = 0; i < (n); i++)
    if (lo[i] != -1) {
      if (len == -1) len = hi[i] - lo[i];
      if (len != hi[i] - lo[i]) return 0;
    }
  for (int i = 0; i < (len); i++)
    if (!sameChar(i)) return 0;
  return 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  readInput();
  findLoHi();
  if (!checkSame()) {
    cout << "NO" << endl;
    return 0;
  }
  while (sameChar(-1)) {
    for (int i = 0; i < (n); i++)
      if (lo[i] != -1) lo[i]--;
    len++;
  }
  while (sameChar(len)) {
    for (int i = 0; i < (n); i++)
      if (lo[i] != -1) hi[i]++;
    len++;
  }
  string s = "", t = "";
  for (int i = 0; i < (n); i++)
    if (lo[i] != -1) {
      s = w[i].substr(lo[i], len);
      t = w2[i].substr(lo[i], len);
      break;
    }
  for (int i = 0; i < (n); i++)
    if (apply(w[i], s, t) != w2[i]) {
      cout << "NO" << endl;
      return 0;
    }
  cout << "YES" << endl;
  cout << s << endl;
  cout << t << endl;
}
