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