#include <bits/stdc++.h>
using namespace std;
char a[100 + 10], b[100 + 10];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    bool ok = 0;
    scanf("%s", a + 1);
    scanf("%s", b + 1);
    int arr[26], brr[26];
    for (int i = 0; i < 26; i++) arr[i] = brr[i] = 0;
    for (int i = 1; i <= strlen(a + 1); i++) {
      arr[a[i] - 'a']++;
      brr[b[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
      if (arr[i] and brr[i]) {
        ok = 1;
        break;
      }
    }
    printf("%s", (ok == 1 ? "YES\n" : "NO\n"));
  }
}
