https://codeforces.com/contest/1241/problem/B
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 107;
int n;
char s[MAXN], t[MAXN];
void init ();
void input ();
void work ();
int main ()
{
init ();
int T;
scanf ( "%d", &T );
while ( T-- ) {
input ();
work ();
}
}
void init ()
{
// Init Everything Here
ios::sync_with_stdio ( false );
}
void input ()
{
// input method
scanf ( "%s%s", s, t );
}
void work ()
{
// main work
n = strlen ( s );
set < char > ss;
lp ( i, 0, n ) ss.insert ( s[i] );
lp ( i, 0, n ) {
if ( ss.find ( t[i] ) != ss.end () ) {
cout << "YES" << endl;
return;
}
}
cout << "NO" << endl;
}