#include <bits/stdc++.h>
using namespace std;
int64_t TN = 1;
void solve() {
  string s, t;
  cin >> s >> t;
  map<char, int64_t> make_pair;
  for (int i = 0; i < s.size(); ++i) {
    make_pair[s[i]] = 1;
  }
  for (int i = 0; i < t.size(); ++i) {
    if (make_pair[t[i]]) {
      cout << "YES\n";
      return;
    }
  }
  cout << "NO\n";
}
int main() {
  cin >> TN;
  for (int i = 0; i < TN; ++i) {
    solve();
  }
  return 0;
}
