T = int(input())
for i in range(T):
    n, m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    count, m, j = 0, [], 0
    while j < len(a):
        for k in range(len(b)):
            if a[j] == b[k]:
                count += 1
                m.append(b[k])
        j += 1
    if count == 0:
        print("No")
    else:
        print("Yes")
        for h in m:
            pass
        print(1,h)

