1
2 2
1 1
1 2
 1
1 3
3
1 2 3
 1
1 1
1000
1000
 1
2 2
2 2
2 2
 5
4 5
10 8 6 4
1 2 3 4 5
1 1
3
3
1 1
3
2
5 3
1000 2 2 2 3
3 1 5
5 5
1 2 3 4 5
1 2 3 4 5
 1
4 4
1 1 1 1
1 2 3 4
 1
2 3
1 1
1 2 3

YES
1 1
 YES
1 3
 YES
1 1000
 YES
1 2
 YES
1 4
YES
1 3
NO
YES
1 3
YES
1 1
 YES
1 1
 YES
1 1

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Gaurav
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            HashSet<Integer> set = new HashSet<Integer>();
            HashSet<Integer> set2 = new HashSet<Integer>();
            for (int i = 0; i < n; i++) {
                set.add(in.nextInt());
            }
            for (int i = 0; i < m; i++) {
                set2.add(in.nextInt());
            }
            int flag = 0;
            int ans = 0;
            Iterator it = set2.iterator();
            while (it.hasNext()) {
                int tm = (Integer) it.next();
                if (!set.add(tm)) {
                    ans = tm;
                    flag = 1;
                    break;
                }
            }
            if (flag == 0)
                out.println("NO");
            else
                out.println("YES" + "\n" + 1 + " " + ans);
        }

    }
}

