def main():
    for _ in range(int(input())):
        n = input()
        arr1 = set((map(int, input().split())))
        arr2 = set((map(int, input().split())))
        ans = arr1.intersection(arr2)
        if len(ans)==0:
            print("NO")
        else:
            print("YES")
            print(1,ans.pop())
main()