#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const long long INF64 = (long long)1e18;
const long double eps = 1e-9;
const long double pi = 3.14159265358979323846;
bool check(string s1, string s2) {
  vector<int> v1(27), v2(27);
  v1.assign(v1.size(), 0);
  v2.assign(v2.size(), 0);
  for (int i = 0; i < s1.size(); i++) v1[s1[i] - 'a']++, v2[s2[i] - 'a']++;
  for (int i = 0; i < 26; i++)
    if ((v1[i] != 0 && v2[i] != 0)) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(), cout.tie();
  int q;
  cin >> q;
  for (int qq = 0; qq < q; qq++) {
    string s1, s2;
    cin >> s1 >> s2;
    if (check(s1, s2))
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
