#include <bits/stdc++.h>
using namespace std;
bool checkThree(char cc, char lc, char nc) { return (cc != lc && cc != nc); }
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++) {
      int x = t.find(s[i]);
      if (x < t.length()) {
        cout << "YES" << endl;
        goto label;
      }
    }
    cout << "NO" << endl;
  label:;
  }
  return 0;
}
