#include <bits/stdc++.h>
using namespace std;
typedef struct Res {
  int len, L, R, l, r;
  int net[3005];
  char s1[3005], s2[3005];
  void Getnext() {
    int i, j;
    i = l, j = l - 1;
    net[l] = l - 1;
    while (i <= r) {
      if (j == l - 1 || s1[i] == s1[j]) {
        i++, j++;
        if (s1[i] == s1[j])
          net[i] = net[j];
        else
          net[i] = j;
      } else
        j = net[j];
    }
  }
} Res;
Res a[3005], poi;
int Jud(Res c, Res d) {
  int i, j, k, now, flag;
  char temp[3005];
  for (i = 1; i <= c.len; i++) temp[i] = c.s1[i];
  temp[c.len + 1] = flag = 0;
  i = 1, j = poi.l;
  while (i <= c.len) {
    if (temp[i] == poi.s1[j]) {
      if (j == poi.r) {
        k = i - (poi.r - poi.l);
        for (now = poi.l; now <= poi.r; now++) temp[k++] = poi.s2[now];
        flag = 1;
        break;
      }
      i++, j++;
    } else {
      j = poi.net[j];
      if (j == poi.l - 1) i++, j = poi.l;
    }
  }
  if (strcmp(temp + 1, c.s2 + 1) == 0) return 1;
  if (flag) return -1;
  return 0;
}
int main(void) {
  int n, i, now;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%s", a[i].s1 + 1);
    a[i].len = strlen(a[i].s1 + 1);
  }
  for (i = 1; i <= n; i++) scanf("%s", a[i].s2 + 1);
  for (i = 1; i <= n; i++) {
    if (strcmp(a[i].s1 + 1, a[i].s2 + 1) != 0) {
      swap(a[1], a[i]);
      break;
    }
  }
  poi = a[1];
  for (i = a[1].len; i >= 1; i--) {
    if (poi.s1[i] != poi.s2[i]) poi.L = i;
  }
  for (i = 1; i <= poi.len; i++) {
    if (poi.s1[i] != poi.s2[i]) poi.R = i;
  }
  poi.l = 1, poi.r = poi.R;
  poi.Getnext();
  for (i = 1; i <= n; i++) {
    now = Jud(a[i], poi);
    while (now != 1 && poi.l != poi.L) {
      if (now == 0) {
        poi.l++;
        poi.Getnext();
        now = Jud(a[i], poi);
      } else
        break;
    }
  }
  for (i = 1; i <= n; i++) {
    now = Jud(a[i], poi);
    while (now != 1 && poi.r != poi.len) {
      if (now == -1) {
        poi.r++;
        poi.Getnext();
        now = Jud(a[i], poi);
      } else
        break;
    }
  }
  for (i = 1; i <= n; i++) {
    if (Jud(a[i], poi) != 1) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  for (i = poi.l; i <= poi.r; i++) printf("%c", poi.s1[i]);
  puts("");
  for (i = poi.l; i <= poi.r; i++) printf("%c", poi.s2[i]);
  puts("");
  return 0;
}
