#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s1, s2;
    cin >> s1 >> s2;
    long long i, j, p = 0;
    for (auto i : s1) {
      for (auto j : s2) {
        if (i == j) {
          p = 1;
        }
      }
    }
    if (p == 0) {
      cout << "NO" << endl;
    } else if (p == 1) {
      cout << "YES" << endl;
    }
  }
  return 0;
}
