#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string str;
    string ptr;
    cin >> str >> ptr;
    int has[26] = {0};
    int gas[26] = {0};
    for (int i = 0; i < str.size(); i++) {
      has[str[i] - 97]++;
    }
    for (int i = 0; i < str.size(); i++) {
      gas[ptr[i] - 97]++;
    }
    int flag = 0;
    for (int i = 0; i < 26; i++) {
      if (has[i] > 0 && gas[i] > 0) {
        flag = 1;
        break;
      }
    }
    if (flag)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
