#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  int q;
  cin >> q;
  while (q--) {
    cin >> s >> t;
    int flag = 0;
    set<char> s1;
    for (int i = 0; i < s.length(); i++) {
      s1.insert(t[i]);
    }
    for (int i = 0; i < s.length(); i++) {
      if (s1.find(s[i]) != s1.end()) {
        cout << "YES"
             << "\n";
        flag = 1;
        break;
      }
    }
    if (flag == 0)
      cout << "NO"
           << "\n";
  }
  return 0;
}
