#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    bool flag = true;
    set<char> a, b, c;
    for (auto &val : s) {
      a.insert(val);
      c.insert(val);
    }
    for (auto &val : t) {
      b.insert(val);
      c.insert(val);
    }
    if (c.size() == a.size() + b.size()) {
      flag = false;
    }
    if (flag) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
