#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    string s;
    string n;
    bool b = false;
    cin >> s >> n;
    for (int j = 0; j < s.size(); j++) {
      for (int k = 0; k < n.size(); k++) {
        if (s[j] == n[k]) {
          b = true;
        }
      }
      if (b) {
        cout << "YES" << endl;
        break;
      }
    }
    if (b == false) {
      cout << "NO" << endl;
    }
  }
}
