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