#include <bits/stdc++.h>
using namespace std;
void run();
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  run();
  return 0;
}
void run() {
  int q;
  cin >> q;
  while (q--) {
    string s, t;
    cin >> s >> t;
    map<char, int> a, b;
    for (auto &i : s) a[i]++;
    for (auto &i : t) b[i]++;
    bool flag = false;
    for (auto &i : a) {
      if (b.find(i.first) != b.end()) flag = true;
    }
    if (flag) {
      cout << "YES";
    } else {
      cout << "NO";
    }
    cout << endl;
  }
}
