Skip to content

1796

B_Asterisk_Minor_Template

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
def solve():
    a = input()
    b = input()

    if a[0] == b[0]:
        print("YES")
        print(f"{a[0]}*")
    elif a[-1] == b[-1]:
        print("YES")
        print(f"*{a[-1]}")
    else:
        for i in range(len(a) - 1):
            if a[i : i + 2] in b:
                print("YES")
                print(f"*{a[i:i+2]}*")
                return
        print("NO")


for _ in range(int(input())):
    solve()