#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];
}
int b = 0;
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)
{
b = 1;
}
}
if (b == 1)
{
cout << "Yes";
}
else
{
cout << "No";
}
return 0;
}