#include <bits/stdc++.h>
using namespace std;
const int N = 3000;
string s[N], t[N];
int p[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) cin >> t[i];
  string ss, tt;
  int ii = -1, ln;
  for (int i = 0; i < n; i++) {
    if (s[i].compare(t[i]) == 0) {
      p[i] = -1;
      continue;
    }
    int l = 0, r = s[i].length() - 1;
    for (; l < r && s[i][l] == t[i][l]; l++)
      ;
    for (; l < r && s[i][r] == t[i][r]; r--)
      ;
    if (ii == -1) {
      ss = s[i].substr(l, r - l + 1);
      tt = t[i].substr(l, r - l + 1);
      ii = i;
      ln = r - l + 1;
    }
    p[i] = l;
  }
  while (1) {
    int possible = 1;
    for (int i = ii; i < n; i++) {
      if (p[i] == -1) continue;
      if (p[i] + ln < s[i].length() && s[ii][p[ii] + ln] == s[i][p[i] + ln] &&
          t[ii][p[ii] + ln] == t[i][p[i] + ln])
        continue;
      possible = 0;
    }
    if (possible)
      ln++;
    else
      break;
  }
  int add = 0;
  while (1) {
    int possible = 1;
    for (int i = ii; i < n; i++) {
      if (p[i] == -1) continue;
      if (p[i] - add > 0 && s[ii][p[ii] - add - 1] == s[i][p[i] - add - 1] &&
          t[ii][p[ii] - add - 1] == t[i][p[i] - add - 1])
        continue;
      possible = 0;
    }
    if (possible)
      add++;
    else
      break;
  }
  ss = s[ii].substr(p[ii] - add, add + ln);
  tt = t[ii].substr(p[ii] - add, add + ln);
  int ok = 1;
  for (int i = 0; i < n && ok; i++) {
    int pos = s[i].find(ss);
    string r;
    if (pos == string::npos) {
      r = s[i];
    } else {
      r = s[i].replace(s[i].begin() + pos, s[i].begin() + pos + tt.length(),
                       tt);
    }
    if (r.compare(t[i]) != 0) ok = 0;
  }
  if (ok) {
    cout << "YES" << endl;
    cout << ss << endl;
    cout << tt << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
