t = int(input())

for _ in range(t):
    n, m = map(int, input().split())
    li1 = list(map(int, input().split()))
    li2 = list(map(int, input().split()))
    ans = -5
    if n < m:
        for i in li1:
            if i in li2:
                ans = i
                break
    else:
        for i in li2:
            if i in li1:
                ans = i
                break
    if ans < 0:
        print("No")
    else:
        print("Yes")
        print(1, ans)
