#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    string p, q;
    cin >> p >> q;
    long long int z = 1;
    long long int m = p.size();
    for (long long int i = 0; i < m; i++) {
      for (long long int j = 0; j < m; j++) {
        if (p[i] == q[j]) {
          cout << "YES" << endl;
          z = 0;
          break;
        }
      }
      if (z == 0) break;
    }
    if (z == 1) cout << "NO" << endl;
  }
}
