#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t > 0) {
    string a;
    string b;
    cin >> a >> b;
    int n = a.size();
    bool p = false;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (a[i] == b[j]) p = true;
      }
    }
    if (p) {
      cout << "YES" << endl;
      ;
    } else
      cout << "NO" << endl;
    ;
    t--;
  }
}
