#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int strlen(char *);
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    char a[100001], b[100001];
    int s[26];
    int i, l;
    int f = 0;
    scanf("%s", a);
    scanf("%s", b);
    for (i = 0; i < 26; i++) {
      s[i] = 0;
    }
    l = strlen(a);
    for (i = 0; i < l; i++) {
      s[a[i] - 'a']++;
    }
    l = strlen(b);
    for (i = 0; i < l; i++) {
      if (s[b[i] - 'a']) {
        printf("YES\n");
        f = 1;
        break;
      }
    }
    if (!f) {
      printf("NO\n");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30de0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     12e2 <main+0x1b2>
movl   $0x0,-0x30ddc(%rbp)
lea    -0x186b0(%rbp),%rsi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x30d60(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x30dd4(%rbp)
cmpl   $0x1a,-0x30dd4(%rbp)
jge    11d9 <main+0xa9>
movslq -0x30dd4(%rbp),%rax
movl   $0x0,-0x30dd0(%rbp,%rax,4)
mov    -0x30dd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30dd4(%rbp)
jmp    11a6 <main+0x76>
lea    -0x186b0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30dd8(%rbp)
movl   $0x0,-0x30dd4(%rbp)
mov    -0x30dd4(%rbp),%eax
cmp    -0x30dd8(%rbp),%eax
jge    1240 <main+0x110>
movslq -0x30dd4(%rbp),%rax
movsbl -0x186b0(%rbp,%rax,1),%eax
ff
sub    $0x61,%eax
cltq
mov    -0x30dd0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30dd0(%rbp,%rax,4)
mov    -0x30dd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30dd4(%rbp)
jmp    11f5 <main+0xc5>
lea    -0x30d60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30dd8(%rbp)
movl   $0x0,-0x30dd4(%rbp)
mov    -0x30dd4(%rbp),%eax
cmp    -0x30dd8(%rbp),%eax
jge    12c4 <main+0x194>
movslq -0x30dd4(%rbp),%rax
movsbl -0x30d60(%rbp,%rax,1),%eax
ff
sub    $0x61,%eax
cltq
cmpl   $0x0,-0x30dd0(%rbp,%rax,4)
je     12ab <main+0x17b>
lea    0xd6f(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x30ddc(%rbp)
jmp    12c4 <main+0x194>
jmp    12b0 <main+0x180>
mov    -0x30dd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30dd4(%rbp)
jmp    125c <main+0x12c>
cmpl   $0x0,-0x30ddc(%rbp)
jne    12dd <main+0x1ad>
lea    0xd33(%rip),%rdi
call   1040 <printf@plt>
jmp    1154 <main+0x24>
mov    -0x4(%rbp),%eax
add    $0x30de0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30de0,%rsp
lea    0xeb9(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    116d <main+0x3d>
xor    %eax,%eax
add    $0x30de0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe8f(%rip),%r14
lea    0x80(%rsp),%r15
lea    0x18730(%rsp),%rbx
lea    0xe7b(%rip),%r12
lea    0xe77(%rip),%r13
jmp    11af <main+0x7f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
call   1030 <puts@plt>
subl   $0x1,0xc(%rsp)
jb     115a <main+0x2a>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movq   $0x0,0x70(%rsp)
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1261 <main+0x131>
mov    %eax,%ecx
cmp    $0x1,%eax
jne    1210 <main+0xe0>
xor    %eax,%eax
jmp    124b <main+0x11b>
nopw   0x0(%rax,%rax,1)
mov    %ecx,%edx
and    $0xfffffffe,%edx
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movsbq 0x80(%rsp,%rax,1),%rsi
addl   $0x1,-0x174(%rsp,%rsi,4)
01
movsbq 0x81(%rsp,%rax,1),%rsi
addl   $0x1,-0x174(%rsp,%rsi,4)
01
add    $0x2,%rax
cmp    %rax,%rdx
jne    1220 <main+0xf0>
test   $0x1,%cl
je     1261 <main+0x131>
movsbq 0x80(%rsp,%rax,1),%rax
addl   $0x1,-0x174(%rsp,%rax,4)
01
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
test   %eax,%eax
jle    11a3 <main+0x73>
mov    %eax,%eax
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
movsbq 0x18730(%rsp,%rcx,1),%rdx
cmpl   $0x0,-0x174(%rsp,%rdx,4)
jne    11a0 <main+0x70>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1280 <main+0x150>
mov    %r12,%rdi
jmp    11a3 <main+0x73>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"YES\0A\00"
@.str.3 = [4 x i8] c"NO\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100001 x i8]
%4 = alloca [100001 x i8]
%5 = alloca [26 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %10
10: ; preds = %79, %0
%11 = load i32, i32* %2
%12 = add nsw i32 %11, -1
store i32 %12, i32* %2
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %80
14: ; preds = %10
store i32 0, i32* %8
%15 = getelementptr inbounds [100001 x i8], [100001 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [100001 x i8], [100001 x i8]* %4, i64 0, i64 0
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 0, i32* %6
br label %19
19: ; preds = %26, %14
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 26
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 %24
store i32 0, i32* %25
br label %26
26: ; preds = %22
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %19
29: ; preds = %19
%30 = getelementptr inbounds [100001 x i8], [100001 x i8]* %3, i64 0, i64 0
%31 = call i32 @strlen(i8* %30)
store i32 %31, i32* %7
store i32 0, i32* %6
br label %32
32: ; preds = %47, %29
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %50
36: ; preds = %32
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [100001 x i8], [100001 x i8]* %3, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = sub nsw i32 %41, 97
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = add nsw i32 %45, 1
store i32 %46, i32* %44
br label %47
47: ; preds = %36
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %32
50: ; preds = %32
%51 = getelementptr inbounds [100001 x i8], [100001 x i8]* %4, i64 0, i64 0
%52 = call i32 @strlen(i8* %51)
store i32 %52, i32* %7
store i32 0, i32* %6
br label %53
53: ; preds = %71, %50
%54 = load i32, i32* %6
%55 = load i32, i32* %7
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %74
57: ; preds = %53
%58 = load i32, i32* %6
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [100001 x i8], [100001 x i8]* %4, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = sub nsw i32 %62, 97
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %57
%69 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %8
br label %74
70: ; preds = %57
br label %71
71: ; preds = %70
%72 = load i32, i32* %6
%73 = add nsw i32 %72, 1
store i32 %73, i32* %6
br label %53
74: ; preds = %68, %53
%75 = load i32, i32* %8
%76 = icmp ne i32 %75, 0
br i1 %76, label %79, label %77
77: ; preds = %74
%78 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %79
79: ; preds = %77, %74
br label %10
80: ; preds = %10
%81 = load i32, i32* %1
ret i32 %81
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@str = [3 x i8] c"NO\00"
@str.4 = [4 x i8] c"YES\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100001 x i8]
%3 = alloca [100001 x i8]
%4 = alloca [26 x i32]
%5 = bitcast [26 x i32]* %4 to i8*
%6 = bitcast i32* %1 to i8*
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, -1
store i32 %9, i32* %1
%10 = icmp eq i32 %8, 0
br i1 %10, label %80, label %11
11: ; preds = %0
%12 = getelementptr inbounds [100001 x i8], [100001 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [100001 x i8], [100001 x i8]* %3, i64 0, i64 0
br label %14
14: ; preds = %11, %74
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%17 = call i32 @strlen(i8* %12)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %57
19: ; preds = %14
%20 = zext i32 %17 to i64
%21 = and i64 %20, 1
%22 = icmp eq i32 %17, 1
br i1 %22, label %46, label %23
23: ; preds = %19
%24 = and i64 %20, 4294967294
br label %25
25: ; preds = %25, %23
%26 = phi i64 [ 0, %23 ], [ %43, %25 ]
%27 = phi i64 [ 0, %23 ], [ %44, %25 ]
%28 = getelementptr inbounds [100001 x i8], [100001 x i8]* %2, i64 0, i64 %26
%29 = load i8, i8* %28
%30 = sext i8 %29 to i64
%31 = add nsw i64 %30, -97
%32 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
store i32 %34, i32* %32
%35 = or i64 %26, 1
%36 = getelementptr inbounds [100001 x i8], [100001 x i8]* %2, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i64
%39 = add nsw i64 %38, -97
%40 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = add nsw i32 %41, 1
store i32 %42, i32* %40
%43 = add nuw nsw i64 %26, 2
%44 = add i64 %27, 2
%45 = icmp eq i64 %44, %24
br i1 %45, label %46, label %25
46: ; preds = %25, %19
%47 = phi i64 [ 0, %19 ], [ %43, %25 ]
%48 = icmp eq i64 %21, 0
br i1 %48, label %57, label %49
49: ; preds = %46
%50 = getelementptr inbounds [100001 x i8], [100001 x i8]* %2, i64 0, i64 %47
%51 = load i8, i8* %50
%52 = sext i8 %51 to i64
%53 = add nsw i64 %52, -97
%54 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = add nsw i32 %55, 1
store i32 %56, i32* %54
br label %57
57: ; preds = %49, %46, %14
%58 = call i32 @strlen(i8* %13)
%59 = icmp sgt i32 %58, 0
br i1 %59, label %60, label %74
60: ; preds = %57
%61 = zext i32 %58 to i64
br label %64
62: ; preds = %64
%63 = icmp eq i64 %73, %61
br i1 %63, label %74, label %64
64: ; preds = %60, %62
%65 = phi i64 [ 0, %60 ], [ %73, %62 ]
%66 = getelementptr inbounds [100001 x i8], [100001 x i8]* %3, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i64
%69 = add nsw i64 %68, -97
%70 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %69
%71 = load i32, i32* %70
%72 = icmp eq i32 %71, 0
%73 = add nuw nsw i64 %65, 1
br i1 %72, label %62, label %74
74: ; preds = %62, %64, %57
%75 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0), %57 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.4, i64 0, i64 0), %64 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0), %62 ]
%76 = call i32 @puts(i8* dereferenceable(1) %75)
%77 = load i32, i32* %1
%78 = add nsw i32 %77, -1
store i32 %78, i32* %1
%79 = icmp eq i32 %77, 0
br i1 %79, label %80, label %14
80: ; preds = %74, %0
ret i32 0
}