#include <iostream>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;

    int a[n], b[m];

    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    for (int i = 0; i < m; i++){
        cin >> b[i];
    }

    int help = 0;
    for (int i = 0; i < n; i++){
        if(a[i] == b[help]){
            help++;
        }

        if(help == m)
            break;
    }

    if(help == m){
        cout << "Yes";
    } else {
        cout << "No";
    }


    return 0;
}