#include <bits/stdc++.h>
using namespace std;
long long q, n;
string s, t, kol;
long long a, b;
long long perevod(char a) {
  int num;
  if (((long long)a >= 48) && ((long long)a <= 57)) {
    num = atoi(&a);
  } else {
    num = (long long)a - 55;
  }
  return num;
}
int main() {
  cin >> q;
  bool fl = 0;
  for (long long i = 0; i < q; i++) {
    cin >> s >> t;
    for (long long i = 0; i < s.length(); i++) {
      if (fl == true) {
        break;
      }
      a = s[i] - '0';
      for (long long j = 0; j < s.length(); j++) {
        b = t[j] - '0';
        if (a == b) {
          fl = true;
          break;
        }
      }
    }
    if (fl == true) {
      cout << "YES" << endl;
      fl = false;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
