#include <bits/stdc++.h>
int main() {
  int q, i, f, j, k;
  char a[101], b[101];
  scanf("%d\n", &q);
  for (i = 1; i <= q; i++) {
    f = 0;
    scanf("%s%s", a, b);
    for (j = 0; j < strlen(a); j++) {
      for (k = 0; k < strlen(b); k++) {
        if (a[j] == b[k]) {
          f = 1;
          break;
        }
      }
      if (f == 1) break;
    }
    if (f == 1)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
