#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 15;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int n;
string s[maxn], t[maxn];
char tmp[maxn];
int z[maxn << 1];
void getZ(const string &s) {
  for (int i = 1, l = 0, r = -1; i < ((int)(s).size()); ++i) {
    if (i + z[i - l] < r) {
      z[i] = z[i - l];
    } else {
      l = i;
      r = max(r, i);
      while (r < ((int)(s).size()) && s[r] == s[r - l]) r++;
      z[i] = r - l;
    }
  }
}
int getPos(const string &s, const string &t) {
  getZ(t + '#' + s);
  for (int i = 0; i < ((int)(s).size()); ++i) {
    if (z[((int)(t).size()) + 1 + i] >= ((int)(t).size())) return i;
  }
  return -1;
}
int ls[maxn], rs[maxn];
void solve() {
  string from, to;
  for (int i = 0; i < n; i++) {
    if (s[i] == t[i]) {
      ls[i] = -1;
      rs[i] = -1;
      continue;
    }
    auto &l = ls[i], &r = rs[i];
    l = 0;
    r = ((int)(s[i]).size());
    while (s[i][l] == t[i][l]) l++;
    while (s[i][r - 1] == t[i][r - 1]) --r;
    string curs = s[i].substr(l, r - l), curt = t[i].substr(l, r - l);
    if (from.empty()) {
      from = curs;
      to = curt;
    }
    if (from != curs || to != curt) {
      printf("NO\n");
      return;
    }
  }
  while (1) {
    char c = 0;
    bool bad = 0;
    for (int i = 0; i < n; ++i) {
      if (ls[i] == -1) continue;
      if (ls[i] == 0) {
        bad = 1;
        break;
      }
      if (!c) {
        c = s[i][ls[i] - 1];
      }
      if (c != s[i][ls[i] - 1]) {
        bad = 1;
        break;
      }
    }
    if (bad) break;
    from.insert(from.begin(), c);
    to.insert(to.begin(), c);
    for (int i = 0; i < n; ++i) {
      if (ls[i] == -1) continue;
      ls[i]--;
    }
  }
  while (1) {
    char c = 0;
    bool bad = 0;
    for (int i = 0; i < n; ++i) {
      if (ls[i] == -1) continue;
      if (rs[i] >= ((int)(s[i]).size())) {
        bad = 1;
        break;
      }
      if (!c) {
        c = s[i][rs[i]];
      }
      if (c != s[i][rs[i]]) {
        bad = 1;
        break;
      }
    }
    if (bad) break;
    from += c;
    to += c;
    for (int i = 0; i < n; ++i) {
      if (ls[i] == -1) continue;
      rs[i]++;
    }
  }
  for (int i = 0; i < n; i++) {
    int pos = getPos(s[i], from);
    if (ls[i] == -1) {
      if (pos != -1) {
        printf("NO\n");
        return;
      }
    } else {
      if (pos != ls[i]) {
        printf("NO\n");
        return;
      }
    }
  }
  printf("YES\n");
  printf("%s\n%s\n", from.c_str(), to.c_str());
}
int main() {
  {};
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", tmp);
    s[i] = tmp;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%s", tmp);
    t[i] = tmp;
  }
  solve();
  return 0;
}
