#include <iostream>
using namespace std;
int main()
{
    int n , m;    cin >> n >> m;
    int Arr[n];
    for ( int i = 0 ; i < n ; i ++ )
    {
        cin >> Arr[i];
    }

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

    int f = 0;
    int counter = 0;
    for ( int i = f ; i < n ; i ++ )
    {
        for ( int j = 0 ; j < m ; j ++ )
        {
            if ( arr[j] == Arr[i] )
            {
                i ++;
                counter ++;
            }

            else if ( arr[j] != Arr[i] )
            {
                j = j - 1;
                if ( i < n - 1 )
                {
                    i ++;
                }

                else 
                {
                    break;
                }
            }

            if ( j == m - 1 && counter == m )
            {
                cout << "Yes";
                f = n;
            }
        }

        if ( i == n - 1 && f != n )
        {
            f = n - 1;
        }

        else if ( f != n && i < n - 1 )
        {
            f ++;
            counter = 0;
        }
    }

    if ( counter != m )
    {
        cout << "No";
    }



    return 0;
}