#include <bits/stdc++.h>
using namespace std;
vector<string> v1;
vector<string> v2;
vector<int> kmp_prefixes;
void generateprefixes(string pattern) {
  kmp_prefixes.assign(pattern.length(), 0);
  int i = -1;
  kmp_prefixes[0] = -1;
  for (int j = 1; j < pattern.length(); j++) {
    while (i >= 0 && pattern[i + 1] != pattern[j]) {
      i = kmp_prefixes[i];
    }
    if (pattern[i + 1] == pattern[j]) {
      i++;
    }
    kmp_prefixes[j] = i;
  }
}
int kmp(string s, string a) {
  int q = -1;
  for (int i = 0; i < s.length(); i++) {
    while (q >= 0 && a[q + 1] != s[i]) {
      q = kmp_prefixes[q];
    }
    if (a[q + 1] == s[i]) {
      q++;
    }
    if (q + 1 == a.length()) {
      return i - (int)a.length() + 1;
      q = kmp_prefixes[q];
    }
  }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int ml[n + 1];
  int mr[n + 1];
  for (int i = 0; i < n; i++) {
    ml[i] = -1;
    mr[i] = -1;
    string s;
    cin >> s;
    v1.push_back(s);
  }
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    v2.push_back(s);
  }
  int len = -1;
  for (int i = 0; i < n; i++) {
    int l = -1, r = -1;
    for (int j = 0; j < v1[i].length(); j++) {
      if (v1[i][j] != v2[i][j]) {
        if (l < 0) {
          l = j;
        }
        r = j;
      }
    }
    if (l < 0 && r < 0) {
      continue;
    }
    ml[i] = l;
    mr[i] = r;
    if (len < 0) {
      len = r - l + 1;
    } else if (len != r - l + 1) {
      std::cout << "NO" << endl;
      return 0;
    }
  }
  while (true) {
    int ch = -1, cgl = 1;
    for (int i = 0; i < n; i++) {
      if (ml[i] < 0) {
        continue;
      }
      if (ml[i] > 0) {
        if (ch < 0) {
          ch = (int)v1[i][ml[i] - 1];
        } else {
          cgl = cgl && ch == (int)v1[i][ml[i] - 1];
        }
      } else {
        cgl = 0;
      }
    }
    if (!cgl) {
      break;
    }
    for (int i = 0; i < n; i++) {
      if (ml[i] > 0) {
        ml[i]--;
      }
    }
  }
  while (true) {
    int ch = -1, cgr = 1;
    for (int i = 0; i < n; i++) {
      if (mr[i] < 0) {
        continue;
      }
      if (mr[i] + 1 < v1[i].size()) {
        if (ch < 0) {
          ch = (int)v1[i][mr[i] + 1];
        } else {
          cgr = cgr && ch == (int)v1[i][mr[i] + 1];
        }
      } else {
        cgr = 0;
      }
    }
    if (!cgr) {
      break;
    }
    for (int i = 0; i < n; i++) {
      if (mr[i] >= 0) {
        mr[i]++;
      }
    }
  }
  len = -1;
  string a, b;
  for (int i = 0; i < n; i++) {
    if (ml[i] < 0) {
      continue;
    }
    len = mr[i] - ml[i] + 1;
    a = v1[i].substr(ml[i], len);
    b = v2[i].substr(ml[i], len);
    break;
  }
  generateprefixes(a);
  bool ok = true;
  for (int i = 0; ok && i < n; i++) {
    int occ = kmp(v1[i], a);
    for (int j = 0; j < v1[i].length(); j++) {
      ok = ok &&
           (((occ < 0 || j < occ || occ + len <= j) && v1[i][j] == v2[i][j]) ||
            (occ <= j && j < occ + len) && (b[j - occ] == v2[i][j]));
    }
  }
  if (ok) {
    std::cout << "YES" << endl << a << endl << b << endl;
  } else {
    std::cout << "NO" << endl;
  }
}
