#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int MAX = 5005;
int n;
string strs[MAX];
string strp[MAX];
int anspos = 0;
int strlens[MAX];
int vis[MAX];
int change[MAX][2];
string ansa, ansb;
bool cal(int pos) {
  int len = strs[pos].size();
  strlens[pos] = len;
  int l = -1, r = len;
  while (l < len && strs[pos][++l] == strp[pos][l])
    ;
  while (r > 0 && strs[pos][--r] == strp[pos][r])
    ;
  if (l > r) return 1;
  string cnt = strs[pos].substr(l, r - l + 1);
  string cnt2 = strp[pos].substr(l, r - l + 1);
  if (ansa.size() == 0 && ansb.size() == 0) {
    anspos = pos;
    ansa = cnt;
    ansb = cnt2;
  }
  if (cnt != ansa || cnt2 != ansb) {
    return 0;
  }
  vis[pos] = 1;
  change[pos][0] = l, change[pos][1] = r;
  return 1;
}
bool myfinds(string &ps) {
  int nowcntlen = ps.size();
  for (int i = 0; i < n; i++) {
    auto pos = strs[i].find(ps);
    if (pos != string::npos) {
      string rester =
          strs[i].substr(0, pos) + ansb + strs[i].substr(pos + ansb.size());
      if (rester != strp[i]) {
        return 1;
      }
    }
  }
  return 0;
}
int addl, addr;
string pre;
bool check(int len) {
  addl = 0, addr = 0;
  while (change[anspos][0] > 0) {
    int flag = 1;
    for (int i = 0; i < n; i++) {
      if (i == anspos) continue;
      if (!vis[i]) continue;
      if (change[i][0] > 0 &&
          strs[anspos][change[anspos][0] - 1] == strs[i][change[i][0] - 1]) {
        change[i][0]--;
      } else {
        flag = 0;
        break;
      }
    }
    if (flag) {
      change[anspos][0]--;
      addl++;
    } else {
      break;
    }
  }
  while (change[anspos][1] < len - 1) {
    int flag = 1;
    for (int i = 0; i < n; i++) {
      if (i == anspos) continue;
      if (!vis[i]) continue;
      if (change[i][1] < strlens[i] - 1 &&
          strs[anspos][change[anspos][1] + 1] == strs[i][change[i][1] + 1]) {
        change[i][1]++;
      } else {
        flag = 0;
        break;
      }
    }
    if (flag) {
      change[anspos][1]++;
      addr++;
    } else {
      break;
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  ansa.clear(), ansb.clear();
  for (int i = 0; i < n; i++) {
    cin >> strs[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> strp[i];
  }
  for (int i = 0; i < n; i++) {
    if (!cal(i)) {
      cout << "NO\n";
      return 0;
    }
  }
  int nowl = change[anspos][0], nowr = change[anspos][1];
  check(strs[anspos].size());
  if (addl) {
    ansa = strs[anspos].substr(nowl - addl, addl) + ansa;
    ansb = strs[anspos].substr(nowl - addl, addl) + ansb;
  }
  if (addr) {
    ansa += strs[anspos].substr(nowr + 1, addr);
    ansb += strs[anspos].substr(nowr + 1, addr);
  }
  if (myfinds(ansa)) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
    cout << ansa << "\n" << ansb << endl;
  }
  return 0;
}
