#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
  putchar(' ');
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
using namespace std;
const long long mod = 1e9 + 7;
string S, T, X;
int n, m, Qtion, dem[340];
long long sum, ans;
int getbit(int bit, int ii) { return (bit >> ii) & 1; }
void dowork() {
  for (int i = (0); i <= (33); ++i) dem[i] = 0;
  cin >> S >> T;
  n = S.length();
  S = "+" + S + "+";
  T = "+" + T + "+";
  bool kt = 0;
  for (int i = (1); i <= (n); ++i) ++dem[S[i] - 'a'];
  for (int i = (1); i <= (n); ++i)
    if (dem[T[i] - 'a']) kt = 1;
  if (kt) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}
void openmain() {
  ios_base::sync_with_stdio(0);
  freopen(
      "1223B"
      ".inp",
      "r", stdin);
  freopen(
      "1223B"
      ".out",
      "w", stdout);
  cout.tie();
}
int main() {
  cin >> Qtion;
  while (Qtion--) dowork();
  return 0;
}
