#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    string s, t;
    cin >> s >> t;
    std::map<char, bool> ms, mt;
    for (int i = 0; i < s.size(); i++) {
      ms[s[i]] = true;
      mt[t[i]] = true;
    }
    for (char x = 'a'; x <= 'z'; x++)
      if (ms[x] && mt[x]) {
        cout << "YES";
        goto flag;
      }
    cout << "NO";
  flag:
    cout << endl;
    ;
  }
}
