#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  for (int k = 0; k < q; ++k) {
    string s, t;
    cin >> s >> t;
    vector<bool> a(26), b(26);
    for (int i = 0; i < s.size(); ++i) {
      a[s[i] - 'a'] = true;
      b[t[i] - 'a'] = true;
    }
    bool flag = false;
    for (int i = 0; i < 26; ++i) {
      if (a[i] && b[i]) {
        flag = true;
        break;
      }
    }
    if (flag)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
