#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 20;
bool mp[30];
int main() {
  string s, t;
  int n;
  scanf("%d", &n);
  getchar();
  while (n--) {
    memset(mp, 0, sizeof(mp));
    getline(cin, s);
    getline(cin, t);
    int len = s.size();
    for (int i = 0; i < len; ++i) {
      int c = (int)(s[i] - 'a') + 1;
      mp[c] = 1;
    }
    bool flag = 0;
    for (int i = 0; i < len; ++i) {
      int c = (int)(t[i] - 'a') + 1;
      if (mp[c]) {
        flag = 1;
        break;
      }
    }
    if (flag)
      cout << "YES" << '\n';
    else
      cout << "NO" << '\n';
  }
  return 0;
}
