#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  int t, i, l;
  cin >> t;
  while (t--) {
    int j, cnt = 0;
    cin >> s1 >> s2;
    l = s1.size();
    for (i = 0; i < l; i++) {
      for (j = 0; j < l; j++) {
        if (s1[i] == s2[j]) {
          cnt++;
        }
      }
    }
    if (cnt > 0) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
