#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
void solve() {
  string a, b;
  cin >> a >> b;
  set<int> A, B;
  bool ok = 1;
  for (int i = 0; i < a.size(); ++i) {
    A.insert(a[i]);
    B.insert(b[i]);
  }
  set<int> second;
  for (auto &j : A)
    if (B.count(j)) second.insert(j);
  ok &= (second.size() != 0);
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
