#include <iostream>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
int arr_1[n];
int arr_2[m];
for (int i = 0; i < n; i++)
cin >> arr_1[i];
for (int i = 0; i < m; i++)
cin >> arr_2[i];
bool res = false;
for (int i = 0; i < n; i++)
{
if (arr_1[i] == arr_2[0])
if (arr_1[i + 1] == arr_2[1])
if (arr_1[i + 2] == arr_2[2])
{
res = true;
break;
}
}
if (res)
cout << "YES";
else
cout << "NO";
return 0;
}