#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long q;
  cin >> q;
  while (q--) {
    string s, t;
    cin >> s >> t;
    long long a[26];
    for (int i = 0; i < 26; ++i) {
      a[i] = 0;
    }
    for (int i = 0; i < s.size(); ++i) {
      a[s[i] - 'a']++;
    }
    bool b = true;
    for (int i = 0; i < t.size(); ++i) {
      if (a[t[i] - 'a']) {
        cout << "YES\n";
        b = false;
        break;
      }
    }
    if (b) cout << "NO\n";
  }
  return 0;
}
