t = int(input())
for _ in range(t):
    input()
    x = set(map(int, input().split()))
    y = set(map(int, input().split()))
    z = x.intersection(y)
    if z:
        print("YES")
        print(1, z.pop())
    else:
        print("NO")

