#include using namespace std; typedef long long ll; const int INF=0x3f3f3f3f; const ll LLINF=0x3f3f3f3f3f3f3f3fLL; const int MAX=1e5+10; char s[MAX][35],t[MAX][35]; int main() { int n,k,i,tmp,ok; scanf("%d%d",&n,&k); for(i=1;i<=n;i++) scanf("%s",s[i]); for(i=1;i<=n;i++) scanf("%s",t[i]); ok=1; for(i=1;i<=n;i++) { if(i-k<1&&i+k>n) { if(strcmp(s[i],t[i])!=0) ok=0; } } if(ok) puts("Yes"); else puts("No"); return 0; }