#include <bits/stdc++.h>
using namespace std;
int a[100001], b[100001];
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  ;
  long long int t, i, j, c = 0;
  string s, p;
  set<char> q, r;
  cin >> t;
  while (t--) {
    cin >> s >> p;
    for (i = 0; i < s.length(); i++) {
      for (j = 0; j < p.length(); j++) {
        if (s[i] == p[j]) {
          c = 1;
          break;
        }
      }
    }
    if (c)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    c = 0;
  }
  return 0;
}
