#include <bits/stdc++.h>
using namespace std;
int book[27];
int main() {
  int T;
  string s, t;
  cin >> T;
  while (T--) {
    cin >> s >> t;
    bool flag = false;
    memset(book, 0, sizeof(book));
    for (int i = 0; i < s.size(); i++) {
      if (book[s[i] - 'a'] == 0) {
        book[s[i] - 'a'] = 1;
      }
    }
    for (int i = 0; i < t.size(); i++) {
      if (book[t[i] - 'a'] == 1) {
        flag = true;
        break;
      }
    }
    if (flag)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
