////TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
//// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
//void main() {
//    //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
//    // to see how IntelliJ IDEA suggests fixing it.
//    IO.println(String.format("Hello and welcome!"));
//
//    for (int i = 1; i <= 5; i++) {
//        //TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
//        // for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
//        IO.println("i = " + i);
//    }
//}


import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arrBig = new int[n];
        for (int i=0 ; i<n;i++){
            arrBig[i] = sc.nextInt();
        }
        int[] arrSmall = new int[m];
        for (int i=0 ; i<m;i++){
            arrSmall[i] = sc.nextInt();
        }
        outer:
        for (int i=0 ; i<n;i++) {
            if (arrBig[i] == arrSmall[0] && i < n - m + 1) {
                for (int j = 0; j < m; j++) {
                    if (arrBig[i + j] == arrSmall[j] && j < m - 1) {
                        continue;
                    } else if (arrBig[i + j] == arrSmall[j]) {
                        System.out.print("Yes");
                        break outer;
                    } else {
                        break;
                    }
                }
            }

            if (i == n - 1) {
                System.out.println("No");
            }

        }
    }
}