#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-O3")
using ld = long double;
const long long int mod = 1000000007;
const long long int inf = 1000000000000000000;
const long long int rk = 256;
const ld PI = 3.141592653589793;
ostream& operator<<(ostream& os, pair<long long int, long long int> const& x) {
  os << x.first << "," << x.second;
  return os;
}
template <class T>
ostream& operator<<(ostream& os, vector<T> const& x) {
  os << "{ ";
  for (auto& y : x) os << y << " ";
  return os << "}";
}
template <class T>
ostream& operator<<(ostream& os, set<T> const& x) {
  os << "{ ";
  for (auto& y : x) os << y << " ";
  return os << "}";
}
template <class Ch, class Tr, class Container>
basic_ostream<Ch, Tr>& operator<<(basic_ostream<Ch, Tr>& os,
                                  Container const& x) {
  os << "{ ";
  for (auto& y : x) os << y << " ";
  return os << "}";
}
template <class X, class Y>
ostream& operator<<(ostream& os, pair<X, Y> const& p) {
  return os << "[ " << p.first << ", " << p.second << "]";
}
long long int max_possible_till_here(vector<long long int> prices,
                                     long long int len, long long int x,
                                     long long int a, long long int y,
                                     long long int b) {
  long long int s1 = 0, s2 = 0;
  long long int counta = 0, countb = 0, countboth = 0;
  for (int i = 1; i <= len; i++) {
    if (i % a == 0 && i % b == 0)
      countboth++;
    else if (i % a == 0)
      counta++;
    else if (i % b == 0)
      countb++;
  }
  long long int countr = 0;
  while (countr < countboth) {
    s1 += prices[countr] * (x + y);
    s2 += prices[countr] * (x + y);
    countr++;
  }
  while (countr < counta) {
    s1 += prices[countr] * (x);
    s2 += prices[countr] * (y);
    countr++;
  }
  while (countr < countb) {
    s1 += prices[countr] * (y);
    s2 += prices[countr] * (x);
    countr++;
  }
  return max(s1, s2);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    if (s == t) {
      cout << "YES\n";
      continue;
    }
    if (s.size() == 1)
      cout << "NO\n";
    else {
      bool found = false;
      for (int i = 0; i < s.size(); i++) {
        if (!found) {
          for (int j = 0; j < t.size(); j++) {
            if (t[j] == s[i]) {
              found = true;
              break;
            }
          }
        }
      }
      if (found)
        cout << "YES\n";
      else
        cout << "NO\n";
    }
  }
  return 0;
}
