#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  int q, k, l;
  cin >> q;
  for (int p = 0; p < q; p++) {
    cin >> s1;
    cin >> s2;
    k = 0;
    l = s1.length();
    for (int i = 0; i < l; i++) {
      for (int j = 0; j < l; j++) {
        if (s1[i] == s2[j]) {
          k = 1;
        }
      }
    }
    if (k == 0) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
    }
  }
  return 0;
}
