#include <bits/stdc++.h>
using namespace std;
vector<int> prefix_function(string s) {
  int n = (int)s.length();
  vector<int> pi(n);
  for (int i = 1; i < n; ++i) {
    int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) ++j;
    pi[i] = j;
  }
  return pi;
}
int subfind(string s, string t) {
  vector<int> pi = prefix_function(s + "#" + t);
  int n = (int)s.size();
  int m = (int)t.size();
  for (int i = n; i < n + m + 1; ++i)
    if (pi[i] == n) return i - 2 * n;
  return -1;
}
const int MAX = 3000;
const int N = 3000;
string w[N][2];
int posL[N], posR[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> w[i][0];
  for (int i = 0; i < n; ++i) cin >> w[i][1];
  for (int i = 0; i < n; ++i) {
    if (w[i][0] != w[i][1]) {
      swap(w[i][0], w[0][0]);
      swap(w[i][1], w[0][1]);
      break;
    }
  }
  set<string> S, T;
  for (int i = 0; i < n; ++i) {
    if (w[i][0] == w[i][1]) continue;
    posL[i] = 0;
    while (w[i][0][posL[i]] == w[i][1][posL[i]]) ++posL[i];
    posR[i] = (int)w[i][0].size() - 1;
    while (w[i][0][posR[i]] == w[i][1][posR[i]]) --posR[i];
    string s = w[i][0].substr(posL[i], posR[i] - posL[i] + 1);
    string t = w[i][1].substr(posL[i], posR[i] - posL[i] + 1);
    S.insert(s);
    T.insert(t);
  }
  if ((int)S.size() > 1 || (int)T.size() > 1) {
    cout << "NO";
    return 0;
  }
  int a = MAX, b = MAX;
  for (int i = 0; i < n; ++i) {
    if (w[i][0] == w[i][1]) continue;
    int ji = posL[i], j0 = posL[0];
    for (; ji >= 0 && j0 >= 0; --ji, --j0)
      if (w[i][0][ji] != w[0][0][j0]) break;
    a = min(a, posL[i] - ji - 1);
    ji = posR[i], j0 = posR[0];
    for (; ji < (int)w[i][0].size() && j0 < (int)w[0][0].size(); ++ji, ++j0)
      if (w[i][0][ji] != w[0][0][j0]) break;
    b = min(b, ji - posR[i] - 1);
  }
  string s = w[0][0].substr(posL[0] - a, posR[0] - posL[0] + 1 + a + b);
  string t = w[0][1].substr(posL[0] - a, posR[0] - posL[0] + 1 + a + b);
  for (int i = 0; i < n; ++i) {
    int pos = subfind(s, w[i][0]);
    if (w[i][0] == w[i][1]) {
      if (pos != -1) {
        cout << "NO";
        return 0;
      }
    } else {
      if (pos != posL[i] - a) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES\n";
  cout << s << '\n' << t;
}
