#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
void dist(string a, string b, string &x, string &y, string &padl,
          string &padr) {
  if (a == b) return;
  int l = 0, r = ((int)((a).size())) - 1;
  while (l <= r and a[l] == b[l]) ++l;
  while (r >= l and a[r] == b[r]) --r;
  x = a.substr(l, r - l + 1);
  y = b.substr(l, r - l + 1);
  padl = a.substr(0, l);
  padr = a.substr(r + 1);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(17);
  int n;
  cin >> n;
  vector<string> a(n), b(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  for (int i = 0; i < (n); i++) cin >> b[i];
  string x, y, l, r;
  int same = 1;
  for (int i = 0; i < (n); i++) {
    if (a[i] != b[i]) same = 0;
    string tx, ty, tl, tr;
    dist(a[i], b[i], tx, ty, tl, tr);
    ;
    if (x.empty()) {
      x = tx, y = ty;
      l = tl;
      r = tr;
    } else if (!tx.empty() and (x != tx or y != ty)) {
      cout << "NO\n";
      return 0;
    } else if (!tx.empty()) {
      string l2, r2;
      reverse(l.begin(), l.end());
      reverse(tl.begin(), tl.end());
      for (int ii = 0; ii < (min(((int)((tl).size())), ((int)((l).size()))));
           ii++) {
        if (tl[ii] == l[ii]) {
          l2 += tl[ii];
        } else {
          break;
        }
      }
      for (int ii = 0; ii < (min(((int)((tr).size())), ((int)((r).size()))));
           ii++) {
        if (tr[ii] == r[ii]) {
          r2 += tr[ii];
        } else {
          break;
        }
      }
      reverse(l2.begin(), l2.end());
      l = l2;
      r = r2;
    }
  }
  if (same) {
    cout << "YES\na\na\n";
    return 0;
  }
  x = l + x + r;
  y = l + y + r;
  for (int i = 0; i < (n); i++) {
    auto index = a[i].find(x);
    if (index != string::npos) {
      a[i].replace(index, ((int)((x).size())), y);
    }
  }
  int ok = 1;
  for (int i = 0; i < (n); i++) {
    if (a[i] != b[i]) ok = 0;
  }
  if (ok) {
    cout << "YES\n" << x + "\n" + y << endl;
  } else {
    cout << "NO\n";
  };
  return 0;
}
