#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  short requestCount;
  cin >> requestCount;
  string a, b;
  set<char> sa, sb;
  bool no;
  while (requestCount != 0) {
    cin >> a >> b;
    for (auto c : a) {
      sa.insert(c);
    }
    for (auto c : b) {
      sb.insert(c);
    }
    no = true;
    for (auto n : sa) {
      if (sb.find(n) != sb.end()) {
        cout << "YES" << endl;
        no = false;
        break;
      }
    }
    if (no) {
      cout << "NO" << endl;
    }
    sa.clear();
    sb.clear();
    requestCount--;
  }
  return 0;
}
