#include <bits/stdc++.h>
using namespace std;
void solve() {
  string ss, tt;
  cin >> ss >> tt;
  int l = ss.size();
  vector<int> s(30);
  vector<int> t(30);
  for (int i = 0; i < l; i++) {
    s[ss[i] - 'a']++;
    t[tt[i] - 'a']++;
  }
  bool ok = false;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] && t[i]) {
      ok = true;
    }
  }
  cout << (ok ? "YES\n" : "NO\n");
  return;
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    solve();
  }
}
