#include <bits/stdc++.h>
using namespace std;
void input(vector<int>& v, int n) {
  int i, io;
  for (i = 0; i < n; i++) {
    cin >> io;
    v.push_back(io);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    string a, b;
    cin >> a >> b;
    bool f = true;
    int i, j, n = a.length();
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (a[i] == b[j]) {
          i = n;
          cout << "YES" << endl;
          f = false;
          break;
        }
      }
    }
    if (f) cout << "NO" << endl;
  }
}
