for _ in range(int(input())):
    dlug_a, dlug_b = map(int, input().split())
    a = set([int(_) for _ in input().split()])
    b = set([int(_) for _ in input().split()])
    wynik = list(a & b)
    if len(wynik) != 0:
        print("YES")
        print(1, wynik[0])
    else:
        print("NO")