#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
int n;
char s[N][N], t[N][N];
char ss[N], tt[N];
int l[N], r[N], pi[N], length[N];
void prefix_function() {
  int n = strlen(ss);
  int now;
  pi[0] = now = -1;
  for (int i = 1; i < n; i++) {
    while (now != -1 && ss[now + 1] != ss[i]) now = pi[now];
    if (ss[now + 1] == ss[i])
      pi[i] = ++now;
    else
      pi[i] = now = -1;
  }
}
int kmp(int id) {
  int n = strlen(s[id]), m = strlen(ss);
  int now = -1;
  for (int i = 0; i < n; i++) {
    while (now != -1 && ss[now + 1] != s[id][i]) now = pi[now];
    if (ss[now + 1] == s[id][i])
      ++now;
    else
      now = -1;
    if (now == m - 1) return i - m + 1;
  }
  return -1;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf(" %s", s[i]);
    length[i] = strlen(s[i]);
  }
  for (int i = 0; i < n; i++) scanf(" %s", t[i]);
  for (int i = 0; i < n; i++) {
    int sz = length[i];
    int &p = l[i] = 0;
    while (p < sz && s[i][p] == t[i][p]) p++;
    int &q = r[i] = sz - 1;
    while (q >= 0 && s[i][q] == t[i][q]) q--;
  }
  int p = -1;
  for (int i = 0; i < n; i++) {
    if (l[i] > r[i]) continue;
    if (p == -1) {
      p = i;
      continue;
    }
    if (r[i] - l[i] != r[p] - l[p]) {
      puts("NO");
      return 0;
    }
    int len = r[i] - l[i] + 1;
    for (int j = 0; j < len; j++) {
      if (s[p][l[p] + j] != s[i][l[i] + j]) {
        puts("NO");
        return 0;
      }
      if (t[p][l[p] + j] != t[i][l[i] + j]) {
        puts("NO");
        return 0;
      }
    }
  }
  int lim = length[p], L = 0, R = 0;
  for (R = 1; r[p] + R < lim; R++) {
    char c = s[p][r[p] + R];
    bool flag = true;
    for (int i = 0; i < n; i++) {
      if (l[i] > r[i]) continue;
      if (r[i] + R >= length[i]) {
        flag = false;
        break;
      }
      if (s[i][r[i] + R] != c) {
        flag = false;
        break;
      }
    }
    if (!flag) break;
  }
  R--;
  for (L = 1; l[p] - L >= 0; L++) {
    char c = s[p][l[p] - L];
    bool flag = true;
    for (int i = 0; i < n; i++) {
      if (l[i] > r[i]) continue;
      if (l[i] - L < 0) {
        flag = false;
        break;
      }
      if (s[i][l[i] - L] != c) {
        flag = false;
        break;
      }
    }
    if (!flag) break;
  }
  L--;
  for (int i = 0; i < n; i++)
    if (l[i] <= r[i]) l[i] -= L, r[i] += R;
  int sz = r[p] - l[p] + 1;
  for (int i = 0; i < sz; i++) ss[i] = s[p][l[p] + i], tt[i] = t[p][l[p] + i];
  prefix_function();
  for (int i = 0; i < n; i++) {
    int idx = kmp(i);
    if (idx == -1) continue;
    for (int j = 0; j < sz; j++) s[i][idx + j] = t[p][l[p] + j];
  }
  for (int i = 0; i < n; i++) {
    sz = length[i];
    for (int j = 0; j < sz; j++)
      if (s[i][j] != t[i][j]) {
        puts("NO");
        return 0;
      }
  }
  puts("YES");
  puts(ss);
  puts(tt);
  return 0;
}
