#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    string s, t;
    cin >> s >> t;
    int len, i, j, flag = 0;
    len = t.size();
    for (i = 0; i < len; i++) {
      for (j = 0; j < len; j++) {
        if (t[i] == s[j]) {
          flag = 1;
          cout << "YES" << endl;
          goto x;
        }
      }
    }
  x:
    if (flag == 0) cout << "NO" << endl;
  }
}
