#include <bits/stdc++.h>
using namespace std;
string s, t;
bool us[222];
long long n, sh;
int main() {
  cin >> n;
  while (n > 0) {
    cin >> s >> t;
    sh = 0;
    for (auto to : s) {
      us[to] = 1;
    }
    for (auto to : t) {
      if (us[to] > 0) {
        cout << "YES" << endl;
        sh = 1;
        break;
      }
    }
    memset(us, 0, sizeof us);
    if (sh == 0) cout << "NO" << endl;
    n--;
  }
  return false;
}
