#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
char s[3005][3005], t[3005][3005];
int L[3005];
void NO() {
  printf("NO\n");
  exit(0);
}
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < (N); ++i) scanf("%s", s[i]);
  for (int i = 0; i < (N); ++i) scanf("%s", t[i]);
  vector<pair<int, pair<int, int>>> changes;
  for (int i = 0; i < (N); ++i) {
    L[i] = strlen(s[i]);
    pair<int, int> r(L[i], -1);
    for (int j = 0; j < (L[i]); ++j)
      if (s[i][j] != t[i][j]) {
        r.first = min(r.first, j);
        r.second = max(r.second, j);
      }
    if (r.second == -1) continue;
    changes.push_back({i, r});
  }
  int pattern_id = changes[0].first;
  int pattern_start = changes[0].second.first;
  int pattern_end = changes[0].second.second;
  int min_length = pattern_end - pattern_start + 1;
  const char* pattern_s = s[pattern_id];
  const char* pattern_t = t[pattern_id];
  int pattern_L = L[pattern_id];
  int start = 0;
  int end = L[pattern_id] - 1;
  for (auto pp : changes) {
    const char* my_s = s[pp.first];
    const char* my_t = t[pp.first];
    int my_start = pp.second.first;
    int my_end = pp.second.second;
    if (my_end - my_start + 1 != min_length) NO();
    if (string(my_s + my_start, min_length) !=
        string(pattern_s + pattern_start, min_length))
      NO();
    if (string(my_t + my_start, min_length) !=
        string(pattern_t + pattern_start, min_length))
      NO();
    int prefix = 0;
    while (prefix < my_start && prefix < pattern_start &&
           my_s[my_start - prefix - 1] == pattern_s[pattern_start - prefix - 1])
      ++prefix;
    int suffix = 0;
    while (my_end + suffix < L[pp.first] - 1 &&
           pattern_end + suffix < pattern_L - 1 &&
           my_s[my_end + suffix + 1] == pattern_s[pattern_end + suffix + 1])
      ++suffix;
    start = max(start, pattern_start - prefix);
    end = min(end, pattern_end + suffix);
  }
  string S(pattern_s + start, end - start + 1);
  string T(pattern_t + start, end - start + 1);
  for (int i = 0; i < (N); ++i) {
    string A(s[i]);
    int pos = A.find(S);
    if (pos != string::npos) {
      A = A.replace(pos, S.size(), T);
    }
    if (A != string(t[i])) NO();
  }
  printf("YES\n%s\n%s\n", S.c_str(), T.c_str());
}
