#include <bits/stdc++.h>
using namespace std;
map<char, long long int> mp, mk;
set<long long int> s1, s2;
vector<long long int> v, w;
string s = "", p = "", q = "";
char ch;
long long int m, n, c, i, j, k, l, r, x, t, y, u, e, f, g, h, mn, mx, d, z;
int main() {
  cin >> t;
  while (t--) {
    cin >> s >> p;
    for (i = 0; i < s.size(); i++) mp[s[i]]++;
    for (i = 0; i < p.size(); i++) {
      if (mp[p[i]]) c = 1;
    }
    if (c)
      cout << "YES\n";
    else
      cout << "NO\n";
    c = 0;
    mp.clear();
  }
}
