#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    string s1, s2;
    cin >> s1 >> s2;
    int count1[26] = {0}, count2[26] = {0};
    for (int i = 0; i < (int)s1.size(); i++) {
      count1[s1[i] - 'a']++;
      count2[s2[i] - 'a']++;
    }
    bool yes = 0;
    for (int i = 0; i < 26; i++) {
      if ((count1[i] && count2[i])) {
        cout << "YES" << endl;
        yes = 1;
        break;
      }
    }
    if (!yes) cout << "NO" << endl;
  }
}
