#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long q;
  cin >> q;
  while (q) {
    q--;
    string s, t;
    cin >> s >> t;
    set<char> s1, t1;
    for (long long i = 0; i < s.size(); i++) {
      s1.insert(s[i]);
      t1.insert(t[i]);
    }
    bool poc = 0;
    for (set<char>::iterator i = s1.begin(); i != s1.end(); i++)
      if (t1.count((*i))) poc = 1;
    if (poc)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
