def solve():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    union = set(a) & set(b)
    if not union:
        print("NO")
    else:
        print("YES")
        print(1, union.pop())


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