#include<iostream>
using namespace std;
const int N = 100010;
int n, m;
int a[N], b[N];
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i ++ ) cin >> a[i];
for (int j = 0; j < m; j ++ ) cin >> b[j];
int i = 0, j = 0, count = 0;
for (i = 0; i < n; i ++ ) {
while(j < m && a[i] != b[j]) j ++ ;
if (a[i] == b[j] && j < m) {
j ++ ;
count ++ ;
}
}
if (count == n) cout << "Yes" << endl;
else cout << "No" << endl;
}