#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  string t;
  string r;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    cin >> t;
    r = "NO";
    for (int j = 0; j < s.length(); j++) {
      for (int k = 0; k < t.length(); k++) {
        if (s[j] == t[k]) {
          r = "YES";
          break;
        }
      }
    }
    cout << r << endl;
  }
  return 0;
}
