#include <bits/stdc++.h>
using namespace std;
void primeFacTillN(long n) {
  bool p[1000000] = {0};
  p[0] = 1;
  p[1] = 1;
  int i = 0;
  for (int i = 2; i <= n; i++) {
    if (!p[i]) {
      for (int j = 2 * i; j <= n; j += i) p[j] = 1;
    }
  }
  for (i = 1; i < n; i++) cout << p[i] << "\n";
}
long long baseN(long long a, long long n) {
  if (a < n)
    return a;
  else {
    return (a % n + 10 * baseN((a / n), n));
  }
}
long long binarySearch(long long a[], long long l, long long h, long long k) {
  while (l <= h) {
    long long mid = (l + h) >> 1;
    if (a[k] > mid)
      l = mid + 1;
    else if (a[k] < mid)
      h = mid - 1;
    else
      return mid;
  }
  return -1;
}
long long GCD(long long A, long long B) {
  if (B == 0)
    return A;
  else
    return GCD(B, A % B);
}
int main() {
  long t;
  cin >> t;
  while (t--) {
    string x, y;
    cin >> x >> y;
    bool hai = false;
    for (int i = 0; i < x.length(); i++) {
      for (int j = 0; j < y.length(); j++) {
        if (x[i] == y[j]) {
          hai = true;
          break;
        }
      }
    }
    if (hai)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
