#include <bits/stdc++.h>
using namespace std;
int q;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> q;
  string s, t;
  set<char> fd;
  for (int i = 0; i < q; i++) {
    fd.clear();
    cin >> s >> t;
    for (char c : s) fd.insert(c);
    for (char c : t) {
      if (fd.find(c) != fd.end()) {
        cout << "YES" << endl;
        goto END;
      }
    }
    cout << "NO" << endl;
  END:;
  }
}
