#include <bits/stdc++.h>
using namespace std;
bool al1[26];
bool al2[26];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 0;
  cin >> t;
  for (int I = 0; I < t; I++) {
    memset(al1, 0, sizeof(al1));
    memset(al2, 0, sizeof(al2));
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
      al1[s[i] - 'a'] = 1;
      al2[t[i] - 'a'] = 1;
    }
    bool x = 0;
    for (int i = 0; i < 26; i++) {
      if (al1[i] == 1 && al2[i] == 1) {
        cout << "YES" << endl;
        x = 1;
        break;
      }
    }
    if (x) {
      continue;
    }
    cout << "NO" << endl;
  }
}
