#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s, a;
    cin >> s >> a;
    int c = 0;
    for (int i = 0; i < s.size(); i++) {
      for (int j = 0; j < a.size(); j++) {
        if (s[i] == a[j]) c++;
      }
    }
    if (c > 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
