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