#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7fffffff;
const double eps = 1e-10;
const double pi = acos(-1.0);
inline int read() {
  int x = 0, f = 1;
  char ch;
  ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch & 15);
    ch = getchar();
  }
  if (f)
    return x;
  else
    return -x;
}
const int N = 3030;
int n;
int Len[N], L[N], R[N];
string s[N], t[N], S, T;
int maxlen = N, minlen, id;
bool vis[N];
int l, r;
void solve(int len) {
  while (L[id] > 0) {
    int flag = 1;
    for (int i = 0; i < n; i++) {
      if (i == id || !vis[i]) continue;
      if (L[i] > 0 && s[id][L[id] - 1] == s[i][L[i] - 1])
        --L[i];
      else {
        flag = 0;
        break;
      }
    }
    if (flag)
      --L[id], l++;
    else
      break;
  }
  while (R[id] < len - 1) {
    int flag = 1;
    for (int i = 0; i < n; i++) {
      if (i == id || !vis[i]) continue;
      if (R[i] < Len[i] - 1 && s[id][R[id] + 1] == s[i][R[i] + 1])
        ++R[i];
      else {
        flag = 0;
        break;
      }
    }
    if (flag)
      ++R[id], r++;
    else
      break;
  }
}
bool cheak(string &c) {
  int len = c.size();
  for (int i = 0; i < n; i++) {
    auto id = s[i].find(c);
    if (id != string::npos) {
      string ls = s[i].substr(0, id) + T + s[i].substr(id + T.size());
      if (ls != t[i]) return 1;
    }
  }
  return 0;
}
int main() {
  n = read();
  char ss[N];
  for (int i = 0; i < n; i++) scanf("%s", ss), s[i] = ss;
  for (int i = 0; i < n; i++) scanf("%s", ss), t[i] = ss;
  for (int i = 0; i < n; i++) {
    Len[i] = s[i].size();
    L[i] = -1, R[i] = Len[i];
    while (L[i] < Len[i] && s[i][++L[i]] == t[i][L[i]])
      ;
    while (R[i] > 0 && s[i][--R[i]] == t[i][R[i]])
      ;
    if (L[i] > R[i]) continue;
    string c1 = s[i].substr(L[i], R[i] - L[i] + 1);
    string c2 = t[i].substr(L[i], R[i] - L[i] + 1);
    if (S.size() == 0 && T.size() == 0) {
      id = i;
      S = c1;
      T = c2;
    }
    if (c1 != S || c2 != T) {
      printf("NO\n");
      return 0;
    }
    vis[i] = 1;
  }
  int LL = L[id], RR = R[id];
  solve(Len[id]);
  if (l) S = s[id].substr(LL - l, l) + S, T = t[id].substr(LL - l, l) + T;
  if (r) S = S + s[id].substr(RR + 1, r), T = T + t[id].substr(RR + 1, r);
  if (cheak(S))
    printf("NO\n");
  else
    printf("YES\n%s\n%s\n", S.c_str(), T.c_str());
  return 0;
}
