#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void computeLPSArray(string &pat, int M, int *lps) {
  int len = 0;
  lps[0] = 0;
  int i = 1;
  while (i < M) {
    if (pat[i] == pat[len]) {
      len++;
      lps[i] = len;
      i++;
    } else {
      if (len != 0) {
        len = lps[len - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
}
int KMPSearch(string &pat, string &txt) {
  int M = pat.size();
  int N = txt.size();
  int lps[M];
  computeLPSArray(pat, M, lps);
  int i = 0;
  int j = 0;
  while (i < N) {
    if (pat[j] == txt[i]) {
      j++;
      i++;
    }
    if (j == M) {
      return i - j;
    } else if (i < N && pat[j] != txt[i]) {
      if (j != 0)
        j = lps[j - 1];
      else
        i = i + 1;
    }
  }
  return -1;
}
string repl(string A, string &s, string &t) {
  int i = KMPSearch(s, A);
  if (i < 0) return A;
  A.replace(i, t.size(), t);
  return A;
}
void print(vector<int> tab) {
  for (auto x : tab) cout << x << ' ';
  cout << endl;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> ini(n), tar(n);
  for (int i = 0; i < n; ++i) cin >> ini[i];
  for (int i = 0; i < n; ++i) cin >> tar[i];
  vector<int> frst(n, -1);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < ini[i].size(); ++j)
      if (ini[i][j] != tar[i][j]) {
        frst[i] = j;
        break;
      }
  }
  while (true) {
    bool b = false;
    for (int x : frst)
      if (x == 0) b = true;
    if (b) break;
    set<pair<char, char>> se;
    for (int i = 0; i < n; ++i)
      if (frst[i] != -1)
        se.insert(make_pair(ini[i][frst[i] - 1], tar[i][frst[i] - 1]));
    if (se.size() == 1) {
      for (int i = 0; i < n; ++i)
        if (frst[i] != -1) frst[i]--;
    } else
      break;
  }
  vector<int> last = frst;
  while (true) {
    bool b = false;
    for (int i = 0; i < n; ++i)
      if (last[i] == ini[i].size()) b = true;
    if (b) break;
    set<pair<char, char>> se;
    for (int i = 0; i < n; ++i)
      if (last[i] != -1) se.insert(make_pair(ini[i][last[i]], tar[i][last[i]]));
    if (se.size() == 1) {
      for (int i = 0; i < n; ++i)
        if (last[i] != -1) last[i]++;
    } else
      break;
  }
  int ex = -1;
  for (int i = 0; i < n; ++i)
    if (frst[i] >= 0) ex = i;
  string s = ini[ex].substr(frst[ex], last[ex] - frst[ex]);
  string t = tar[ex].substr(frst[ex], last[ex] - frst[ex]);
  bool b = true;
  for (int i = 0; i < n && b; ++i)
    if (repl(ini[i], s, t) != tar[i]) b = false;
  if (b)
    cout << "YES\n" << s << '\n' << t << '\n';
  else
    cout << "NO";
}
