#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string a, b;
    cin >> a >> b;
    int n;
    n = a.length();
    int fl = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (a[i] == b[j]) {
          fl = 1;
          break;
        }
      }
      if (fl) break;
    }
    if (fl)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
