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