#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  string s, t;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> s >> t;
    if (s.length() != t.length()) {
      cout << "NO" << endl;
    } else {
      unordered_set<char> setOfS;
      for (char k : s) {
        setOfS.insert(k);
      }
      int j;
      for (j = 0; j < t.length(); j++) {
        if (setOfS.find(t[j]) != setOfS.end()) {
          cout << "YES" << endl;
          break;
        }
      }
      if (j == t.length()) {
        cout << "NO" << endl;
      }
    }
  }
  return 0;
}
