#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read_to_vector(size_t N, std::vector<T> &v) {
  for (size_t i = 0; i < N; i++) {
    T tmp;
    std::cin >> tmp;
    v.push_back(tmp);
  }
}
template <typename T>
void print_vector(const std::vector<T> &v) {
  for (auto it = v.begin(); it < v.end(); it++) {
    if (it != v.begin()) std::cout << " ";
    std::cout << (*it);
  }
}
string getpre(string s0, string s1) {
  string res;
  for (int i = 0; i < s0.size() && i < s1.size(); i++) {
    if (s0[i] == s1[i]) {
      res += s0[i];
    } else {
      break;
    }
  }
  return res;
}
string getpre(vector<string> &ss) {
  if (ss.size() == 0) {
    return "";
  }
  string smin = ss[0];
  string smax = ss[0];
  for (int i = 0; i < ss.size(); i++) {
    smin = min(ss[i], smin);
    smax = max(ss[i], smax);
  }
  return getpre(smin, smax);
}
void solve() {
  long long n;
  cin >> n;
  vector<string> w0, w1;
  read_to_vector(n, w0);
  read_to_vector(n, w1);
  vector<int> ch0(n, -1), ch1(n, -1);
  string chans0;
  string chans1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < w0[i].size(); j++) {
      if (w0[i][j] != w1[i][j]) {
        if (ch0[i] == -1) {
          ch0[i] = j;
        }
        ch1[i] = j;
      }
    }
    ch1[i]++;
    if (ch0[i] != -1) {
      chans0 = w0[i].substr(ch0[i], ch1[i] - ch0[i]);
      chans1 = w1[i].substr(ch0[i], ch1[i] - ch0[i]);
    }
  }
  vector<string> prefs;
  vector<string> posts;
  for (int i = 0; i < n; i++) {
    if (ch0[i] == -1) {
      continue;
    }
    string pre = w0[i].substr(0, ch0[i]);
    reverse(pre.begin(), pre.end());
    string post = w0[i].substr(ch1[i], w0[i].size() - ch1[i]);
    prefs.push_back(pre);
    posts.push_back(post);
  }
  string pre = getpre(prefs);
  reverse(pre.begin(), pre.end());
  string post = getpre(posts);
  string rep0 = pre + chans0 + post;
  string rep1 = pre + chans1 + post;
  bool test = true;
  for (int i = 0; i < n; i++) {
    string w = w0[i];
    string wend = w;
    int ind = w.find(rep0);
    if (ind != string::npos) {
      wend = w.substr(0, ind) + rep1 +
             w.substr(ind + rep1.size(), w.size() - (ind + rep1.size()));
    }
    test &= (wend == w1[i]);
  }
  if (test) {
    cout << "YES\n" << rep0 << "\n" << rep1 << "\n";
  } else {
    cout << "NO\n";
  }
}
void pre_compute() {}
int main() {
  std::cout << std::setprecision(15);
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  pre_compute();
  solve();
  return 0;
}
