#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  for (int k = 0; k < q; k++) {
    string s1, s2;
    cin >> s1 >> s2;
    for (int i = 0; i < s1.length(); i++) {
      for (size_t j = 0; j < s2.length(); j++) {
        if (s1[i] == s2[j]) {
          cout << "YES\n";
          goto next;
        }
      }
    }
    cout << "NO\n";
  next:
    int t;
  }
}
