#include <bits/stdc++.h>
using namespace std;
int n, x, fr, x0, L, R, len, l[4000], f[4000];
string s1[4000], s2[4000], ss, p, p1;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = (1); i <= (n); i++) {
    cin >> s1[i];
    l[i] = s1[i].length() - 1;
  }
  for (int i = (1); i <= (n); i++) cin >> s2[i];
  for (int i = (1); i <= (n); i++)
    if (s1[i] != s2[i]) {
      if (fr) {
        for (int j = (0); j <= (l[i]); j++)
          if (s1[i][j] != s2[i][j]) {
            x = j;
            break;
          }
        for (int j = (0); j <= (L); j++)
          if (x - j < 0 || s1[i][x - j] != s1[fr][x0 - j] ||
              s2[i][x - j] != s2[fr][x0 - j]) {
            L = j - 1;
            break;
          }
        for (int j = (0); j <= (R); j++)
          if (x + j > l[i] || s1[i][x + j] != s1[fr][x0 + j] ||
              s2[i][x + j] != s2[fr][x0 + j]) {
            R = j - 1;
            break;
          }
      } else {
        fr = i;
        for (int j = (0); j <= (l[i]); j++)
          if (s1[i][j] != s2[i][j]) {
            x0 = j;
            break;
          }
        L = x0;
        R = l[i] - x0;
      }
    }
  if (L == -1) {
    cout << "NO\n";
    return 0;
  }
  for (int i = (x0 - L); i <= (x0 + R); i++)
    p = p + s1[fr][i], p1 = p1 + s2[fr][i];
  len = p.length() - 1;
  f[0] = -1;
  for (int i = (1); i <= (len); i++) {
    for (x = f[i - 1]; ~x; x = f[x])
      if (p[i - 1] == p[x]) break;
    f[i] = x + 1;
  }
  for (int i = (1); i <= (n); i++) {
    x = 0;
    for (int j = (0); j <= (l[i]); j++) {
      while (~x && p[x] != s1[i][j]) x = f[x];
      x++;
      if (x > len) {
        ss = s1[i];
        for (int k = (0); k <= (len); k++) ss[j - len + k] = p1[k];
        if (ss != s2[i]) {
          cout << "NO\n";
          return 0;
        }
        break;
      }
    }
    if (x <= len && s1[i] != s2[i]) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n" << p << '\n' << p1 << '\n';
}
