#include <bits/stdc++.h>
using namespace std;
const long long md = (long long)1e9 + 7, inf = (long long)1e18;
long long gcd(long long a, long long b) { return (!a ? b : gcd(b % a, a)); }
int main() {
  iostream::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<string> s(n), t(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) cin >> t[i];
  string fr, to;
  bool was = false;
  vector<bool> ch(n, 0);
  vector<pair<int, int>> add;
  vector<pair<int, int>> nadd;
  for (int i = 0; i < n; i++) {
    if (s[i] == t[i]) continue;
    ch[i] = true;
    int p1 = 0, p2 = s[i].length() - 1;
    while (s[i][p1] == t[i][p1]) p1++;
    while (s[i][p2] == t[i][p2]) p2--;
    assert(p1 <= p2);
    string nfr = s[i].substr(p1, p2 - p1 + 1),
           nto = t[i].substr(p1, p2 - p1 + 1);
    if (was && nfr != fr) {
      cout << "NO\n";
      return 0;
    }
    if (!was) {
      was = true;
      fr = nfr;
      to = nto;
    }
    add.push_back({i, p2 + 1});
    nadd.push_back({i, p1 - 1});
  }
  while (true) {
    bool fin = false;
    vector<char> nx, mx;
    for (auto &tr : add) {
      int i = tr.first, pos = tr.second;
      if (s[i].size() == pos)
        fin = true;
      else {
        nx.push_back(s[i][tr.second]);
        mx.push_back(t[i][tr.second++]);
      }
    }
    if (fin) break;
    bool ok = true;
    for (char c : nx) ok &= c == nx[0];
    for (char c : mx) ok &= c == mx[0];
    if (ok) {
      fr += nx[0];
      to += mx[0];
    } else {
      break;
    }
  }
  reverse(fr.begin(), fr.end());
  reverse(to.begin(), to.end());
  while (true) {
    bool fin = false;
    vector<char> nx, mx;
    for (auto &tr : nadd) {
      int i = tr.first, pos = tr.second;
      if (-1 == pos)
        fin = true;
      else {
        nx.push_back(s[i][tr.second]);
        mx.push_back(t[i][tr.second--]);
      }
    }
    if (fin) break;
    bool ok = true;
    for (char c : nx) ok &= c == nx[0];
    for (char c : mx) ok &= c == mx[0];
    if (ok) {
      fr += nx[0];
      to += mx[0];
    } else {
      break;
    }
  }
  reverse(fr.begin(), fr.end());
  reverse(to.begin(), to.end());
  assert(was);
  long long hs = 0, pw = 1;
  int len = fr.size();
  const long long p = 239;
  for (char c : fr) {
    hs = ((hs * p) + c) % md;
    pw = (pw * p) % md;
  }
  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (s[i].size() < len) continue;
    long long curhs = 0;
    for (int j = 0; j < len; j++) curhs = ((curhs * p) + s[i][j]) % md;
    if (curhs == hs && fr == s[i].substr(0, len)) {
      if (!ch[i]) {
        cout << "NO\n";
        return 0;
      } else {
        if (t[i].substr(0, len) != to) {
          cout << "NO\n";
          return 0;
        }
        for (int k = len; k < s[i].size(); k++) {
          if (s[i][k] != t[i][k]) {
            cout << "NO\n";
            return 0;
          }
        }
        continue;
      }
    }
    bool cont = false;
    for (int j = len; j < s[i].size(); j++) {
      curhs = ((curhs * p) + s[i][j]) % md;
      curhs -= pw * s[i][j - len];
      curhs %= md;
      if (curhs < 0) curhs += md;
      if (curhs == hs && fr == s[i].substr(j - len + 1, len)) {
        if (!ch[i]) {
          cout << "NO\n";
          return 0;
        } else {
          if (t[i].substr(j - len + 1, len) != to) {
            cout << "NO\n";
            return 0;
          }
          for (int k = j + 1; k < s[i].size(); k++) {
            if (s[i][k] != t[i][k]) {
              cout << "NO\n";
              return 0;
            }
          }
          cont = true;
          break;
        }
      }
    }
    if (cont) continue;
  }
  cout << "YES\n";
  cout << fr << '\n' << to << '\n';
  return 0;
}
