#include <bits/stdc++.h>
using namespace std;
int n, al, ar, nl, nr, o;
int ne[3003];
char w[3003][3003];
char w1[3003][3003];
char s[5003];
char t[5003];
bool check(int i, int l, int r) {
  if (r - l != ar - al) return 0;
  for (int j = l; j <= r; ++j) {
    if (w[i][j] != s[j - l + al]) return 0;
    if (w1[i][j] != t[j - l + al]) return 0;
  }
  return 1;
}
void fix(int i, int l, int r) {
  int j = al - 1;
  while (j >= nl && l > 0 && w[i][l - 1] == s[j]) {
    --j;
    --l;
  }
  nl = j + 1;
  j = ar + 1;
  while (j <= nr && w[i][r + 1] && w[i][r + 1] == s[j]) {
    ++j;
    ++r;
  }
  nr = j - 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", w[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%s", w1[i]);
  }
  for (int i = 0; i < n; ++i) {
    int l = 0, r = strlen(w1[i]) - 1;
    while (l <= r && w[i][l] == w1[i][l]) {
      ++l;
    }
    while (l <= r && w[i][r] == w1[i][r]) {
      --r;
    }
    if (l > r) continue;
    if (!o) {
      o = 1;
      al = l;
      ar = r;
      nl = 0;
      nr = strlen(w1[i]) - 1;
      for (int j = 0; j <= nr; ++j) {
        s[j] = w[i][j];
        t[j] = w1[i][j];
      }
    } else {
      if (!check(i, l, r)) return 0 * puts("NO");
      fix(i, l, r);
    }
  }
  if (!o) {
    for (int i = 0; i < 4000; ++i) {
      s[i] = 'a';
      t[i] = 'b';
    }
    nl = 0;
    nr = 4000 - 1;
  }
  ne[nl] = nl - 1;
  for (int i = nl + 1, j = nl - 1; i <= nr; ++i) {
    while (j != nl - 1 && s[j + 1] != s[i]) j = ne[j];
    if (s[j + 1] == s[i]) ++j;
    ne[i] = j;
  }
  for (int i = 0; i < n; ++i) {
    int l = 0, j = nl - 1;
    while (w[i][l]) {
      while (j != nl - 1 && s[j + 1] != w[i][l]) j = ne[j];
      if (s[j + 1] == w[i][l]) ++j;
      if (j == nr) {
        if (!check(i, l - nr + al, l - nr + ar)) return 0 * puts("NO");
        break;
      }
      ++l;
    }
  }
  puts("YES");
  for (int i = nl; i <= nr; ++i) putchar(s[i]);
  puts("");
  for (int i = nl; i <= nr; ++i) putchar(t[i]);
  puts("");
  return 0;
}
