#include <bits/stdc++.h>
using namespace std;
const int N = 107;
int q;
int cnt1[200], cnt2[200];
char a[N], b[N];
int main() {
  cin >> q;
  while (q--) {
    for (int i = 'a'; i <= 'z'; i++) cnt1[i] = 0, cnt2[i] = 0;
    cin >> a >> b;
    int len = strlen(a), f = 0;
    for (int i = 0; i < len; i++) cnt1[a[i]]++, cnt2[b[i]]++;
    for (int i = 'a'; i <= 'z'; i++)
      if (cnt1[i] && cnt2[i]) f = 1;
    if (f)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
