#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
using namespace std;
const int maxn=1005;
int m,n,k;
int seq[maxn];
int stacks[maxn];
int rear=0;
int main()
{
int val;
scanf("%d %d %d",&m,&n,&k);
for(int i=0;i<k;i++){
for(int j=0;j<n;j++){
scanf("%d",&seq[j]);
}
rear=0;//对尾
int num=0;//要压入的数
bool flag=true;
for(int j=0;j<n;j++){
while(num<seq[j] && rear<m){
stacks[rear++]=++num;
}
//如果栈内元素已满,则false
if(rear>=m && num!=seq[j]){
flag=false;
break;
}
//对尾是否是要pop的元素
if(stacks[rear-1]==seq[j])
rear--;
else{
flag=false;
break;
}
}
if(flag)
printf("YES
");
else
printf("NO
");
}
return 0;
}