#include <bits/stdc++.h>
using namespace std;
char a[3005][3005], b[3005][3005];
int l[3005], r[3005], len[3005];
char s1[3005], s2[3005];
int next2[3005];
void kmp(int n) {
  next2[0] = next2[1] = 0;
  for (int i = 1, j = 0; i < n; i++) {
    while (j && s1[i] != s1[j]) j = next2[j];
    if (s1[i] == s1[j]) j++;
    next2[i + 1] = j;
  }
}
int match(int n, int m, char *s) {
  for (int i = 0, j = 0; i < n; i++) {
    while (j && s[i] != s1[j]) j = next2[j];
    if (s[i] == s1[j]) j++;
    if (j == m) return i;
  }
  return -1;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", a[i]);
  for (int i = 1; i <= n; i++) scanf("%s", b[i]);
  int id = -1;
  for (int i = 1; i <= n; i++) {
    len[i] = strlen(a[i]);
    l[i] = r[i] = -1;
    for (int j = 0; j < len[i]; j++)
      if (a[i][j] != b[i][j]) {
        r[i] = j;
        if (l[i] == -1) l[i] = j;
      }
    if (l[i] == -1) continue;
    if (id == -1)
      id = i;
    else {
      if (r[i] - l[i] != r[id] - l[id]) {
        puts("NO");
        return 0;
      }
      for (int j = 0; j <= r[i] - l[i]; j++)
        if (a[id][l[id] + j] != a[i][l[i] + j] ||
            b[id][l[id] + j] != b[i][l[i] + j]) {
          puts("NO");
          return 0;
        }
    }
  }
  for (;;) {
    bool ok = 1;
    for (int i = 1; i <= n; i++)
      if (l[i] == 0 || (l[i] != -1 && (a[id][l[id] - 1] != a[i][l[i] - 1] ||
                                       b[id][l[id] - 1] != b[i][l[i] - 1]))) {
        ok = 0;
        break;
      }
    if (!ok) break;
    for (int i = 1; i <= n; i++)
      if (l[i] != -1) l[i]--;
  }
  for (;;) {
    bool ok = 1;
    for (int i = 1; i <= n; i++)
      if (r[i] == len[i] - 1 ||
          (r[i] != -1 && (a[id][r[id] + 1] != a[i][r[i] + 1] ||
                          b[id][r[id] + 1] != b[i][r[i] + 1]))) {
        ok = 0;
        break;
      }
    if (!ok) break;
    for (int i = 1; i <= n; i++)
      if (r[i] != -1) r[i]++;
  }
  int m = r[id] - l[id] + 1;
  for (int i = 0; i <= r[id] - l[id]; i++) {
    s1[i] = a[id][l[id] + i];
    s2[i] = b[id][l[id] + i];
  }
  kmp(m);
  for (int i = 1; i <= n; i++)
    if (match(len[i], m, a[i]) != r[i]) {
      puts("NO");
      return 0;
    }
  puts("YES");
  puts(s1);
  puts(s2);
  return 0;
}
