#include <bits/stdc++.h>
const int N = 3e3 + 10;
const int mod = 998244353;
using namespace std;
char a[N][N], b[N][N];
char s[N], t[N];
int ne[N], len[N], lb;
bool vis[N];
int lx[N], rx[N];
char ss[N], tt[N];
int st;
int pd(int x) {
  int f = 0, i, j;
  for (i = 0, j = 0; i <= len[x]; i++, j++) {
    if (j == lb) {
      f = 1;
      break;
    }
    while (j != -1 && a[x][i] != ss[j]) j = ne[j];
  }
  if (f)
    for (j = i - lb; j < i; j++) a[x][j] = tt[j - i + lb];
  for (int ii = 0; ii < len[x]; ii++)
    if (a[x][ii] != b[x][ii]) return 1;
  return 0;
}
int pp(int x) {
  for (int i = 0; i < len[x]; i++)
    if (a[x][i] != b[x][i]) return 1;
  return 0;
}
int ppp(int x) {
  for (int i = 0, j = 0; i <= len[x]; i++, j++) {
    if (j == lb) return 1;
    while (j != -1 && a[x][i] != ss[j]) j = ne[j];
  }
  return 0;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", a[i]), len[i] = strlen(a[i]);
  for (int i = 1; i <= n; i++) scanf("%s", b[i]);
  int lq = 0, rq, g = 0;
  for (int i = 1; i <= n; i++) {
    if (pp(i) == 0)
      g++, vis[i] = 1;
    else {
      lq = 0, rq = len[i] - 1;
      while (lq < len[i] && a[i][lq] == b[i][lq]) lq++;
      lx[i] = lq;
      while (rq >= 0 && a[i][rq] == b[i][rq]) rq--;
      rx[i] = rq;
      lb = 0;
      for (int ii = lq; ii <= rq; ii++)
        s[lb] = a[i][ii], t[lb] = b[i][ii], lb++;
    }
  }
  if (g == n) {
    puts("YES");
    puts("a");
    puts("a");
    return 0;
  }
  for (int j = 1; j <= n; j++)
    if (vis[j] == 0) {
      if (rx[j] - lx[j] + 1 != lb) return puts("NO"), 0;
      for (int k = 0, i = lx[j]; i <= rx[j]; i++, k++)
        if (s[k] != a[j][i] || t[k] != b[j][i]) return puts("NO"), 0;
    }
  while (1) {
    int ff = 0;
    char c = '*', cc = '&';
    for (int i = 1; i <= n; i++)
      if (vis[i] == 0) {
        if (rx[i] + 1 >= len[i]) {
          ff = 1;
          break;
        }
        if (c == '*') c = a[i][rx[i] + 1], cc = b[i][rx[i] + 1];
        if (a[i][rx[i] + 1] != c || b[i][rx[i] + 1] != cc) {
          ff = 1;
          break;
        }
        rx[i]++;
      }
    if (c == '*') break;
    if (!ff)
      s[lb] = c, t[lb] = cc, lb++;
    else
      break;
  }
  while (1) {
    int ff = 0;
    char c = '*', cc = '&';
    for (int i = 1; i <= n; i++)
      if (vis[i] == 0) {
        if (lx[i] - 1 < 0) {
          ff = 1;
          break;
        }
        if (c == '*') c = a[i][lx[i] - 1], cc = b[i][lx[i] - 1];
        if (a[i][lx[i] - 1] != c || b[i][lx[i] - 1] != cc) {
          ff = 1;
          break;
        }
        lx[i]--;
      }
    if (c == '*') break;
    if (!ff)
      ss[st] = c, tt[st] = cc, st++;
    else
      break;
  }
  reverse(ss, ss + st);
  reverse(tt, tt + st);
  for (int i = 0; i < lb; i++) ss[i + st] = s[i], tt[i + st] = t[i];
  lb += st;
  for (int i = 0, j = -1; i <= lb; i++, j++) {
    ne[i] = j;
    while (j != -1 && ss[i] != ss[j]) j = ne[j];
  }
  for (int i = 1; i <= n; i++)
    if (vis[i] && ppp(i)) return puts("NO"), 0;
  for (int i = 1; i <= n; i++)
    if (vis[i] == 0 && pd(i)) return puts("NO"), 0;
  puts("YES");
  puts(ss);
  puts(tt);
  return 0;
}
