#include <iostream>
using namespace std;
int main()
{
int n , m , x , tedad;
cin >> n >> m;
x = 0;
tedad = 0;
int bozorg[n] , kuchik[m] , arr[n];
for ( int i = 0 ; i < n ; i ++ )
{
cin >> bozorg[i];
}
for ( int i = 0 ; i < m ; i ++ )
{
cin >> kuchik[i];
}
for ( int i = 0 ; i < n ; i ++ )
{
arr[i] = 0;
}
for ( int i = 0 ; i < m ; i ++ )
{
for ( int y = x ; y < n ; y ++ )
{
if ( kuchik[i] == bozorg[x] )
{
arr[x] = 1;
x = y;
}
}
}
for ( int i = 0 ; i < n ; i ++ )
{
if ( arr[i] == 1 )
{
tedad ++;
}
}
if ( tedad == m )
{
cout <<"Yes";
}
else
{
cout <<"No";
}
return 0;
}