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