#include <bits/stdc++.h>
using namespace std;
int q;
string s, t;
bool a[30];
bool b[30];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> q;
  while (q--) {
    cin >> s >> t;
    for (int i = 0; i < int(26); i++) a[i] = b[i] = 0;
    for (int i = 0; i < int(s.size()); i++) a[s[i] - 'a'] = 1;
    for (int i = 0; i < int(t.size()); i++) b[t[i] - 'a'] = 1;
    bool ok = 0;
    for (int i = 0; i < int(26); i++)
      if (a[i] && b[i]) ok = 1;
    if (ok)
      cout << "YES";
    else
      cout << "NO";
    cout << '\n';
  }
}
