#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int flag = 0, f1[26] = {0}, f2[26] = {0};
    string s1;
    cin >> s1;
    string s2;
    cin >> s2;
    for (int i = 0; i < s1.length(); i++) {
      f1[s1[i] - 'a'] = 1;
    }
    for (int i = 0; i < s2.length(); i++) {
      f2[s2[i] - 'a'] = 1;
    }
    for (int i = 0; i < 26; i++) {
      if (f1[i] && f2[i]) {
        flag = 1;
        break;
      }
    }
    if (flag)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
