#include <iostream>
using namespace std;
int main()
{
long long n , m;
cin >> n >> m;
long long arr[n];
int arr1[m];
for (int i = 0; i < n; ++i)
{
cin >> arr[i];
}
for (int i = 0; i < m; ++i)
{
cin >> arr1[i];
}
for (int i = 0; i + m <= n; ++i)
{
int x = i + m;
int a = 0;
int z = 0;
for (int j = i; j < x; ++j)
{
if (arr[j] == arr1[a])
{
z = z + 1;
}
a++;
}
if ( z == m)
{
cout << "Yes";
return 0;
}
}
cout << "No";
return 0;
}