#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i, flag;
  cin >> t;
  while (t--) {
    string s1, s2;
    cin >> s1 >> s2;
    flag = 0;
    for (i = 0; i < s1.length(); i++) {
      if (find(s2.begin(), s2.end(), s1[i]) == s2.end()) flag++;
    }
    if (flag == s1.length())
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
