#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[200] = {0}, b[200] = {0};
  string s1, s2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t = 0;
    cin >> s1 >> s2;
    int l1 = s1.length(), l2 = s2.length();
    for (int j = 0; j < l1; j++) {
      a[s1[j] - '0']++;
    }
    for (int c = 0; c < l2; c++) {
      b[s2[c] - '0']++;
    }
    for (int r = 49; r <= 49 + 26; r++) {
      if (b[r] > 0 && a[r] > 0) {
        cout << "YES" << endl;
        t = 1;
        break;
      }
    }
    if (t == 0) {
      cout << "NO" << endl;
    }
    for (int g = 49; g <= 49 + 26; g++) {
      b[g] = 0;
      a[g] = 0;
    }
  }
  return 0;
}
