#include <bits/stdc++.h>
using namespace std;
const int Z = (int)1e5 + 13;
const int M = (int)1e9 + 13;
int n, q;
string s1, s2;
int main() {
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> s1 >> s2;
    map<char, int> mp;
    for (auto i : s1) mp[i] = 1;
    bool b = false;
    for (auto i : s2)
      if (mp[i] != 0) {
        cout << "YES" << endl;
        b = true;
        break;
      }
    if (b == false) cout << "NO" << endl;
  }
  return 0;
}
