#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    bool tg = false;
    string s, t;
    cin >> s >> t;
    set<char> ss, st;
    for (int i = 0; i < s.size(); i++) {
      ss.insert(s[i]);
      st.insert(t[i]);
    }
    for (auto x : ss) {
      auto pos = st.find(x);
      if (pos != st.end()) {
        tg = true;
        break;
      }
    }
    if (tg == true)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
