#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[1000];
  char t[1000];
  int n, test;
  cin >> n;
  for (int h = 0; h < n; h++) {
    test = 0;
    cin >> s;
    cin >> t;
    for (int i = 0; i < strlen(s); i++) {
      for (int j = 0; j < strlen(t); j++) {
        if (s[i] == t[j]) {
          test = 1;
          cout << "YES" << endl;
          break;
        }
      }
      if (test == 1) break;
    }
    if (test != 1) cout << "NO" << endl;
  }
  return 0;
}
