#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s1, s2;
  cin >> s1 >> s2;
  long long int len1 = s1.length(), len2 = s2.length();
  long long int n, i, j, count = 0, flag = 0;
  if (len1 != len2) {
    cout << "NO" << endl;
    return;
  }
  if (len1 == 1 && (s1 != s2)) {
    cout << "NO" << endl;
    return;
  }
  for (i = 0; i < len1; i++) {
    for (j = 0; j < len2; j++) {
      if (s1[i] == s2[j]) {
        cout << "YES" << endl;
        return;
      }
    }
  }
  cout << "NO" << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long int t;
  cin >> t;
  long long int c = 1;
  while (t--) {
    solve();
    c++;
  }
  return 0;
}
