#include <bits/stdc++.h>
#pragma optimize("O3")
using namespace std;
const int up = 3003;
int n, k;
int lena[up], lenb[up], l[up], r[up];
string a[up], b[up];
string second, t;
vector<int> need;
int fail[up];
void compute_fail(string p) {
  int j = 0, i = 1;
  while (i < p.length()) {
    if (p[i] == p[j])
      fail[i++] = ++j;
    else if (j > 0)
      j = fail[j - 1];
    else
      fail[i++] = 0;
  }
}
int searcch(string second, string p) {
  int i = 0, j = 0;
  while (i < second.length()) {
    if (second[i] == p[j]) {
      if (j == p.length() - 1) return i;
      i++, j++;
    } else if (j > 0)
      j = fail[j - 1];
    else
      i++;
  }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    lena[i] = a[i].length();
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    lenb[i] = b[i].length();
  }
  for (int i = 1; i <= n; i++) {
    l[i] = r[i] = -1;
    for (int j = 0; j < lena[i]; j++) {
      if (a[i][j] != b[i][j]) {
        if (l[i] == -1) {
          l[i] = j;
        }
        r[i] = j;
      }
    }
    if (l[i] != -1) {
      need.push_back(i);
    }
  }
  bool ok = true;
  char ch;
  while (ok) {
    if (r[need[0]] + 1 < lena[need[0]]) ch = a[need[0]][r[need[0]] + 1];
    for (auto i : need) {
      if (r[i] + 1 == lena[i] || a[i][r[i] + 1] != ch) {
        ok = false;
        break;
      }
    }
    if (ok) {
      for (auto i : need) {
        r[i]++;
      }
    }
  }
  ok = true;
  while (ok) {
    if (l[need[0]] > 0) ch = a[need[0]][l[need[0]] - 1];
    for (auto i : need) {
      if (l[i] == 0 || a[i][l[i] - 1] != ch) {
        ok = false;
        break;
      }
    }
    if (ok) {
      for (auto i : need) {
        l[i]--;
      }
    }
  }
  for (int i = l[need[0]]; i <= r[need[0]]; i++) {
    second += a[need[0]][i];
    t += b[need[0]][i];
  }
  for (auto i : need) {
    for (int j = l[i]; j <= r[i]; j++) {
      if (second[j - l[i]] != a[i][j] || t[j - l[i]] != b[i][j]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  compute_fail(second);
  for (int i = 1; i <= n; i++) {
    if (l[i] == -1) {
      if (searcch(a[i], second) != -1) {
        cout << "NO" << endl;
        return 0;
      }
    } else {
      if (searcch(a[i], second) != r[i]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  cout << second << endl;
  cout << t << endl;
  return 0;
}
