#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3010;
string s1[MAXN], s2[MAXN];
string cs1, cs2;
string gl, gr, tmp;
int st[MAXN], nex[MAXN * 3];
void no() {
  puts("NO");
  exit(0);
}
void kmp_pre(string x) {
  int i, j, m = x.size();
  j = nex[0] = -1;
  i = 0;
  while (i < m) {
    while (-1 != j && x[i] != x[j]) j = nex[j];
    nex[++i] = ++j;
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s1[i];
  for (int i = 0; i < n; i++) cin >> s2[i];
  for (int i = 0; i < n; i++) {
    if (s1[i] == s2[i]) {
      st[i] = s1[i].size();
      continue;
    }
    int l = 0, r = s1[i].size() - 1;
    while (s1[i][l] == s2[i][l]) l++;
    while (s1[i][r] == s2[i][r]) r--;
    st[i] = l;
    if (cs1.empty()) {
      cs1 = s1[i].substr(l, r - l + 1);
      cs2 = s2[i].substr(l, r - l + 1);
      tmp = s1[i].substr(0, l);
      reverse(tmp.begin(), tmp.end());
      gl = tmp;
      tmp = s1[i].substr(r + 1);
      gr = tmp;
    } else {
      if (cs1 != s1[i].substr(l, r - l + 1)) no();
      if (cs2 != s2[i].substr(l, r - l + 1)) no();
      tmp = s1[i].substr(0, l);
      reverse(tmp.begin(), tmp.end());
      int now = 0;
      while (now < min(tmp.size(), gl.size()) && tmp[now] == gl[now]) now++;
      gl.resize(now);
      tmp = s1[i].substr(r + 1);
      now = 0;
      while (now < min(tmp.size(), gr.size()) && tmp[now] == gr[now]) now++;
      gr.resize(now);
    }
  }
  reverse(gl.begin(), gl.end());
  cs1 = gl + cs1 + gr;
  cs2 = gl + cs2 + gr;
  int sh = gl.size();
  for (int i = 0; i < n; i++) {
    tmp = cs1 + '#' + s1[i];
    memset(nex, 0, sizeof(nex));
    kmp_pre(tmp);
    int t = s1[i] == s2[i] ? s1[i].size() : st[i] - sh;
    for (int j = 0; j < t; j++) {
      if (nex[2 * cs1.size() + 1 + j] >= cs1.size()) no();
    }
  }
  cout << "YES\n";
  cout << cs1 << endl << cs2 << endl;
  return 0;
}
