for i in range(int(input())):
    X, Y = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))
    z = x + y
    counter = 0
    for i in z:
        if x.count(i) >= 1 and y.count(i) >= 1:
            print("YES")
            print(1, i, sep=" ")
            counter = 1
            break
    if counter == 0:
        print("NO")