#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string arr[n], arr_[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++) cin >> arr_[i];
  int left[n], right[n];
  for (int i = 0; i < n; i++) {
    left[i] = -1;
    right[i] = 10000;
  }
  int a = -1, b, c, d;
  for (int i = 0; i < n; i++) {
    a = arr[i].size();
    b = -1;
    for (int j = 0; j < a; j++) {
      if (arr[i][j] != arr_[i][j]) {
        left[i] = j;
        if (b != -1 && j != b) {
          cout << "NO";
          exit(0);
        } else
          b = j;
        break;
      }
    }
  }
  string x, y;
  for (int i = 0; i < n; i++) {
    a = arr[i].size();
    b = -1;
    for (int j = a - 1; j >= 0; j--) {
      if (arr[i][j] != arr_[i][j]) {
        right[i] = j;
        if (b != -1 && j != b) {
          cout << "NO";
          exit(0);
        } else
          b = j;
        x = arr[i].substr(left[i], right[i] - left[i] + 1);
        y = arr_[i].substr(left[i], right[i] - left[i] + 1);
        break;
      }
    }
  }
  for (;;) {
    bool flag = 0;
    string l = "1", r = "1";
    for (int i = 0; i < n; i++) {
      if (left[i] > -1) {
        if (left[i] == 0) {
          flag = 1;
          break;
        }
        if (l == "1") {
          l.pop_back();
          r.pop_back();
          l += arr[i][left[i] - 1];
          r += arr_[i][left[i] - 1];
        } else {
          if (l[0] != arr[i][left[i] - 1] || r[0] != arr_[i][left[i] - 1]) {
            flag = 1;
            break;
          }
        }
      }
    }
    if (flag)
      break;
    else {
      x = l + x;
      y = r + y;
    }
    for (int i = 0; i < n; i++) left[i]--;
  }
  for (;;) {
    bool flag = 0;
    string l = "1", r = "1";
    for (int i = 0; i < n; i++) {
      if (right[i] < 10000) {
        if (right[i] == arr[i].size() - 1) {
          flag = 1;
          break;
        }
        if (l == "1") {
          l.pop_back();
          r.pop_back();
          l += arr[i][right[i] + 1];
          r += arr_[i][right[i] + 1];
        } else {
          if (l[0] != arr[i][right[i] + 1] || r[0] != arr_[i][right[i] + 1]) {
            flag = 1;
            break;
          }
        }
      }
    }
    if (flag)
      break;
    else {
      x = x + l;
      y = y + r;
    }
    for (int i = 0; i < n; i++) right[i]++;
    ;
  }
  int first = 0, second;
  for (int i = 0; i < n; i++) {
    if (arr[i].find(x) != string::npos) {
      first = arr[i].find(x);
      int size_ = x.size();
      int size__ = arr[i].size();
      bool flag1 = 0;
      if (first != 0 && arr[i].substr(0, first) != arr_[i].substr(0, first))
        flag1 = 1;
      if (arr_[i].substr(first, size_) != y) flag1 = 1;
      if (first + size_ < size__ &&
          arr[i].substr(first + size_, size__ - first - size_) !=
              arr_[i].substr(first + size_, size__ - first - size_))
        flag1 = 1;
      if (flag1 == 1) {
        cout << "NO";
        exit(0);
      }
    } else {
      if (arr[i] != arr_[i]) {
        cout << "NO";
        exit(0);
      }
    }
  }
  cout << "YES\n";
  cout << x << "\n";
  cout << y << "\n";
}
