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