#include <bits/stdc++.h>
using namespace std;
const long long inf = 10000000;
int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    vector<int> a(28);
    vector<int> b(28);
    for (int i = 0; i < n; i++) {
      a[s[i] - 'a']++;
      b[t[i] - 'a']++;
    }
    int count = 0;
    for (int i = 0; i < 28; i++) {
      if (a[i] > 0 && b[i] > 0) {
        count++;
      }
    }
    if (count >= 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
