#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10;
string a[N], b[N];
int l[N], r[N];
string ans = "";
const int MAXN = N;
int patMatch(string &str, string &pat) {
  int fail[MAXN] = {-1}, i = 0, j;
  int lp = pat.length();
  int ls = str.length();
  for (j = 1; j < lp; j++) {
    for (i = fail[j - 1]; i >= 0 && !(pat[i + 1] == pat[j]); i = fail[i])
      ;
    fail[j] = ((pat[i + 1] == pat[j]) ? i + 1 : -1);
  }
  for (i = j = 0; i < ls && j < lp; i++) {
    if (str[i] == pat[j]) {
      j++;
    } else if (j) {
      j = fail[j - 1] + 1;
      i--;
    }
  }
  return j == lp ? (i - lp) : -1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) {
    l[i] = N;
    r[i] = 0;
    for (int j = 0; j < a[i].length(); j++)
      if (a[i][j] != b[i][j]) {
        l[i] = min(l[i], j);
        r[i] = max(r[i], j);
      }
  }
  for (int i = 1; i <= n; i++)
    if (l[i] != N) {
      string t = a[i].substr(l[i], r[i] - l[i] + 1);
      if (ans.length() == 0) {
        ans = t;
      } else {
        if (ans != t) {
          cout << "NO\n";
          return 0;
        }
      }
    }
  while (true) {
    bool flag = true;
    char c = '\0';
    for (int i = 1; i <= n; i++)
      if (l[i] != N) {
        if (r[i] < (int)a[i].length() - 1) {
          if (c == '\0')
            c = a[i][r[i] + 1];
          else if (c != a[i][r[i] + 1]) {
            flag = false;
            break;
          }
        } else {
          flag = false;
          break;
        }
      }
    if (flag) {
      for (int i = 1; i <= n; i++)
        if (l[i] != N) r[i]++;
    } else
      break;
  }
  while (true) {
    bool flag = true;
    char c = '\0';
    for (int i = 1; i <= n; i++)
      if (l[i] != N) {
        if (l[i] > 0) {
          if (c == '\0')
            c = a[i][l[i] - 1];
          else if (c != a[i][l[i] - 1]) {
            flag = false;
            break;
          }
        } else {
          flag = false;
          break;
        }
      }
    if (flag) {
      for (int i = 1; i <= n; i++)
        if (l[i] != N) l[i]--;
    } else
      break;
  }
  for (int i = 1; i <= n; i++)
    if (l[i] != N) {
      ans = a[i].substr(l[i], r[i] - l[i] + 1);
      break;
    }
  bool flag = true;
  for (int i = 1; i <= n; i++) {
    int p = patMatch(a[i], ans);
    if (l[i] != N) {
      if (l[i] != p) {
        flag = false;
        break;
      }
    } else {
      if (p != -1) {
        flag = false;
        break;
      }
    }
  }
  if (!flag) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES" << '\n';
  cout << ans << '\n';
  for (int i = 1; i <= n; i++)
    if (l[i] != N) {
      cout << b[i].substr(l[i], r[i] - l[i] + 1) << '\n';
      break;
    }
  return 0;
}
