#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  int q, c;
  cin >> q;
  for (int i = 0; i < q; i++) {
    c = 0;
    cin >> s >> t;
    for (int h = 0; h < s.length(); h++) {
      for (int h1 = 0; h1 < s.length(); h1++) {
        if (s[h] == t[h1] & c == 0) {
          cout << "YES" << endl;
          c++;
        }
      }
    }
    if (c == 0) cout << "NO" << endl;
  }
  return 0;
}
