def main():
    _ = input()
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    for a_el in a:
        for b_el in b:
            if a_el == b_el:
                print('YES')
                print(f'1 {a_el}')
                return

    print('NO')

if __name__ == '__main__':
    t = int(input())

    for _ in range(t):
        main()
