#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <class T>
T Gcd(T x, T y) {
  return y ? Gcd(y, x % y) : x;
}
template <class T>
T Lcm(T x, T y) {
  return x / Gcd(x, y) * y;
}
template <class T>
void Adj(T &x, T y) {
  if (x >= y) x %= y;
  while (x < 0) x += y;
}
const long long MOD = 1000000007LL;
const int M = 5000005;
const int N = 5005;
int n, l[N], L[N], R[N], bz, op, ed, f[N], to[N], t;
string sa, sb;
char a[N][N], b[N][N], s[N];
set<string> sea, seb;
int kmp(char *a, char *b) {
  int i = 0, j = -1, la = strlen(a), lb = strlen(b);
  to[0] = -1;
  while (i < lb)
    if (j < 0 || b[i] == b[j])
      to[++i] = ++j;
    else
      j = to[j];
  i = j = 0;
  while (i < la) {
    if (j < 0 || a[i] == b[j])
      j++, i++;
    else
      j = to[j];
    if (j == lb) return i - lb;
  }
  return -1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    while (scanf("%s", (a[i])), !strlen((a[i])))
      ;
  for (int i = 1; i <= n; i++)
    while (scanf("%s", (b[i])), !strlen((b[i])))
      ;
  for (int i = 1; i <= n; i++) {
    l[i] = strlen(a[i]);
    L[i] = R[i] = -1;
    for (int j = 0; j < l[i]; j++)
      if (a[i][j] != b[i][j]) {
        L[i] = j;
        break;
      }
    for (int j = l[i] - 1; j >= 0; j--)
      if (a[i][j] != b[i][j]) {
        R[i] = j;
        break;
      }
    if (L[i] >= 0 && R[i] >= 0) {
      sa = a[i];
      sb = b[i];
      sea.insert(sa.substr(L[i], R[i] - L[i] + 1));
      seb.insert(sb.substr(L[i], R[i] - L[i] + 1));
      f[i] = 1;
      bz = i;
    }
  }
  if ((int)(sea).size() == 1 && (int)(seb).size() == 1) {
    ed = l[bz];
    op = 0;
    for (int i = 1; i <= n; i++)
      if (f[i]) {
        t = min(l[i] - 1 - R[i], l[bz] - 1 - R[bz]);
        ed = min(ed, R[bz] + t);
        for (int j = 1; j <= t; j++)
          if (a[i][R[i] + j] != a[bz][R[bz] + j]) {
            ed = min(ed, R[bz] + j - 1);
            break;
          }
        t = min(L[i], L[bz]);
        op = max(op, L[bz] - t);
        for (int j = 1; j <= t; j++)
          if (a[i][L[i] - j] != a[bz][L[bz] - j]) {
            op = max(op, L[bz] - j + 1);
            break;
          }
      }
    sa = a[bz];
    strcpy(s, (sa.substr(op, ed - op + 1)).c_str());
    for (int i = 1; i <= n; i++)
      if (!f[i]) {
        if (kmp(a[i], s) >= 0) {
          puts("NO");
          exit(0);
        }
      } else if (kmp(a[i], s) != L[i] - (L[bz] - op)) {
        puts("NO");
        exit(0);
      }
    puts("YES");
    for (int i = op; i <= ed; i++) printf("%c", a[bz][i]);
    puts("");
    for (int i = op; i <= ed; i++) printf("%c", b[bz][i]);
  } else {
    puts("NO");
  }
  return 0;
}
