#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  string s, t;
  bool flag = false;
  for (long long i = 0; i < n; ++i) {
    cin >> s >> t;
    for (long long i = 0; i < s.size(); ++i) {
      for (long long j = 0; j < t.size(); ++j) {
        if (s[i] == t[j]) {
          flag = true;
          cout << "YES\n";
          break;
        }
      }
      if (flag) break;
    }
    if (!flag) cout << "NO\n";
    flag = false;
  }
  return 0;
}
