#include <bits/stdc++.h>
using namespace std;
pair<int, int> result[5000];
vector<int> z_function(string s) {
  int n = (int)s.length();
  vector<int> z(n);
  for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  return z;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<string> src(n);
  for (auto& s : src) {
    cin >> s;
  }
  vector<string> dst(n);
  for (auto& s : dst) {
    cin >> s;
  }
  for (int i = 0; i < n; ++i) {
    const auto& curSrc = src[i];
    const auto& curDst = dst[i];
    int i1 = 0, i2 = curSrc.size() - 1;
    while (i1 < curSrc.size() && curSrc[i1] == curDst[i1]) {
      ++i1;
    }
    while (i2 >= 0 && curSrc[i2] == curDst[i2]) {
      --i2;
    }
    if (i1 <= i2) {
      result[i] = {i1, i2};
    } else {
      result[i] = {-1, -1};
    }
  }
  pair<string, string> curReplace = {"", ""};
  for (int i = 0; i < n; ++i) {
    if (result[i].first == -1) {
      continue;
    }
    pair<string, string> r = {
        src[i].substr(result[i].first, result[i].second - result[i].first + 1),
        dst[i].substr(result[i].first, result[i].second - result[i].first + 1)};
    if (curReplace.first.empty()) {
      curReplace = std::move(r);
      continue;
    }
    if (curReplace != r) {
      cout << "NO" << endl;
      return 0;
    }
  }
  while (true) {
    char prev = 0;
    for (int i = 0; i < n; ++i) {
      if (result[i].first == -1) {
        continue;
      }
      if (result[i].first == 0) {
        prev = 0;
        break;
      }
      if (prev == 0) {
        prev = src[i][result[i].first - 1];
        continue;
      }
      if (prev != src[i][result[i].first - 1]) {
        prev = 0;
        break;
      }
    }
    char nxt = 0;
    for (int i = 0; i < n; ++i) {
      if (result[i].second == -1) {
        continue;
      }
      if (result[i].second + 1 == src[i].size()) {
        nxt = 0;
        break;
      }
      if (nxt == 0) {
        nxt = src[i][result[i].second + 1];
      }
      if (nxt != src[i][result[i].second + 1]) {
        nxt = 0;
        break;
      }
    }
    if (prev == 0 && nxt == 0) {
      break;
    }
    for (int i = 0; i < n; ++i) {
      if (result[i].first != -1 && prev != 0) {
        --result[i].first;
      }
      if (result[i].second != -1 && nxt != 0) {
        ++result[i].second;
      }
    }
    if (prev) {
      curReplace.first.insert(curReplace.first.begin(), prev);
      curReplace.second.insert(curReplace.second.begin(), prev);
    }
    if (nxt) {
      curReplace.first.push_back(nxt);
      curReplace.second.push_back(nxt);
    }
  }
  for (int i = 0; i < n; ++i) {
    string s = curReplace.first + "#" + src[i];
    auto z = z_function(s);
    int frst = -1;
    for (int j = (int)curReplace.first.size() + 1; j < s.size(); ++j) {
      if (z[j] == curReplace.first.size()) {
        frst = j - (int)(curReplace.first.size() + 1);
        break;
      }
    }
    if (result[i].first == -1) {
      if (frst != -1) {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (result[i].first != frst) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  cout << curReplace.first << "\n" << curReplace.second << endl;
}
