#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s;
    cin.ignore();
    cin >> t;
    int i = 0, d = s.size(), fg = 0;
    if (d == 1) {
      if (s != t)
        cout << "No" << endl;
      else
        cout << "Yes" << endl;
      continue;
    }
    int ar[26], br[26];
    memset(ar, 0, sizeof(ar));
    memset(br, 0, sizeof(br));
    while (i < d) {
      ar[s[i] - 97] += 1;
      br[t[i] - 97] += 1;
      i += 1;
    }
    for (int i = 0; i < 26; i++) {
      if (ar[i] + br[i] > 1 && ar[i] >= 1 && br[i] >= 1) {
        fg = 1;
        break;
      }
    }
    if (!fg)
      cout << "NO" << endl;
    else
      cout << "Yes" << endl;
  }
  return 0;
}
