#include <bits/stdc++.h>
long long mod = 1000000007;
using namespace std;
int n;
string s, t;
int mxlength;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
string a[3001];
string b[3001];
int sh[3001];
int kh[3001];
int lad, rad;
void expa() {
  int offset = 1, i;
  lad = rad = 0;
  while (1) {
    char x = '*';
    int poss = 1;
    for (i = 0; i < n; i++) {
      if (sh[i] == -1) continue;
      int l = a[i].length();
      if (kh[i] + offset < l) {
        if (a[i][kh[i] + offset] == x || x == '*') {
          x = a[i][kh[i] + offset];
        } else {
          poss = 0;
          break;
        }
      } else
        break;
    }
    if (i != n || !poss) break;
    rad = offset;
    s.push_back(x);
    t.push_back(x);
    offset++;
  }
  offset = 1;
  while (1) {
    char x = '*';
    int poss = 1;
    for (i = 0; i < n; i++) {
      if (sh[i] == -1) continue;
      int l = a[i].length();
      if (sh[i] - offset >= 0) {
        if (a[i][sh[i] - offset] == x || x == '*') {
          x = a[i][sh[i] - offset];
        } else {
          poss = 0;
          break;
        }
      } else
        break;
    }
    if (i != n || !poss) break;
    lad = offset;
    s = x + s;
    t = x + t;
    offset++;
  }
}
int main() {
  int i, j, fl, test;
  scanf("%d", &n);
  char tmp[3001];
  for (i = 0; i < n; i++) {
    scanf("%s", tmp);
    a[i] = string(tmp);
  }
  for (i = 0; i < n; i++) {
    scanf("%s", tmp);
    b[i] = string(tmp);
  }
  mxlength = 0;
  s = "", t = "";
  for (i = 0; i < n; i++) {
    int l = a[i].length();
    int st = 0, beg = -1, end = -1;
    for (j = 0; j < l; j++) {
      if (a[i][j] != b[i][j]) {
        if (st == 0)
          st = 1, beg = j, end = j;
        else
          end = j;
      }
    }
    sh[i] = beg;
    kh[i] = end;
    if (beg == -1) continue;
    for (j = 0; j + beg <= end; j++) {
      if (mxlength < j + 1) {
        s = s + a[i][j + beg];
        t = t + b[i][j + beg];
        mxlength++;
      } else {
        if (s[j] != a[i][j + beg] || t[j] != b[i][j + beg]) {
          printf("NO\n");
          return 0;
        }
      }
    }
  }
  for (i = 0; i < n; i++) {
    int l = a[i].length();
    int st = 0, beg = -1, end = -1;
    beg = sh[i];
    if (beg == -1) continue;
    for (j = 0;; j++) {
      if (j == mxlength) break;
      if (j + beg == l) {
        printf("NO\n");
        return 0;
      }
      if (s[j] != a[i][j + beg] || t[j] != b[i][j + beg]) {
        printf("NO\n");
        return 0;
      }
    }
  }
  expa();
  for (i = 0; i < n; i++) {
    if (sh[i] == -1 && a[i].find(s) != std::string::npos) {
      printf("NO\n");
      return 0;
    }
    if (sh[i] != -1 && a[i].find(s) != sh[i] - lad) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  printf("%s\n", s.c_str());
  printf("%s\n", t.c_str());
  return 0;
}
