#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int t;
  scanf("%d", &t);
  while (t--) {
    int f[26], s[26];
    memset(f, 0, sizeof(f));
    memset(s, 0, sizeof(s));
    string a, b;
    cin >> a >> b;
    for (int e = 0; e < a.size(); e++) f[(int)(a[e] - 'a')]++;
    for (int e = 0; e < b.size(); e++) s[(int)(b[e] - 'a')]++;
    int tmp = 0;
    for (int e = 0; e < 26; e++)
      if (f[e] && s[e]) {
        tmp++;
      }
    if (tmp)
      printf("YES\n");
    else
      printf("NO\n");
  }
}
