#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, i, j, k;
  cin >> r;
  string s, s1;
  while (r) {
    k = 0;
    cin >> s >> s1;
    sort(s.begin(), s.end());
    sort(s1.begin(), s1.end());
    j = s.size();
    for (int i = 0; i < j; i++) {
      if (binary_search(s1.begin(), s1.end(), s[i])) {
        k++;
        break;
      }
    }
    if (k == 1)
      cout << "YES"
           << "\n";
    else
      cout << "NO"
           << "\n";
    r--;
  }
  return 0;
}
