#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<string, string>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i].second;
  }
  pair<string, string> res;
  auto solve = [&]() {
    set<pair<string, string>> cands;
    vector<pair<int, int>> pos;
    for (auto pr : a) {
      auto &w = pr.first;
      auto &w1 = pr.second;
      int start = -1, fin;
      for (int i = 0; i < w.length(); i++) {
        if (w[i] != w1[i]) {
          if (start = -1) {
            start = i;
          }
          fin = i;
        }
      }
      if (start == -1) {
        pos.emplace_back(-1, -1);
        continue;
      }
      int len = fin - start + 1;
      cands.insert({w.substr(start, len), w1.substr(start, len)});
      pos.emplace_back(start, fin);
    }
    if (cands.size() > 1) {
      return false;
    }
    auto expand = [&](bool left) {
      for (int d = 1;; d++) {
        char from = 0, to = 0;
        bool ok = true;
        for (int i = 0; i < n; i++) {
          if (pos[i].first == -1) {
            continue;
          }
          auto &w = a[i].first;
          auto &w1 = a[i].second;
          int j = left ? pos[i].first - d : pos[i].second + d;
          if (j < 0 || j == w.length()) {
            ok = false;
            break;
          }
          if (from == 0) {
            from = w[j];
            to = w1[j];
          } else if (from != w[j] || to != w1[j]) {
            ok = false;
            break;
          }
        }
        if (!ok) {
          return d - 1;
        }
      }
    };
    pair<int, int> blk = {expand(true), expand(false)};
    for (int i = 0; i < n; i++) {
      if (pos[i].first != -1) {
        auto &w = a[i].first;
        auto &w1 = a[i].second;
        int start = pos[i].first - blk.first, fin = pos[i].second + blk.second;
        int len = fin - start + 1;
        string from = w.substr(start, len);
        string to = w1.substr(start, len);
        res = {from, to};
        if (w.find(from) != start) {
          return false;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      if (pos[i].first == -1) {
        auto &w = a[i].first;
        if (w.find(res.first) != string::npos) {
          return false;
        }
      }
    }
    return true;
  };
  bool ans = solve();
  cout << (ans ? "YES" : "NO") << "\n";
  if (ans) {
    cout << res.first << endl << res.second << endl;
  }
}
