#include<iostream>
#include<stack>
#include<vector>
using namespace std;
int main(){
int M,N,K;
cin>>M>>N>>K;//M是栈空间,N是数列长度,K是数列个数
int check=K;
while(K--)
{
vector<int> list(N,0);
for(int i=0;i<N;i++)
{
cin>>list[i];
}
stack<int> container;
int p=0;
int num=1;
bool flag=true;
while(p<N)
{
if(container.empty())
{
container.push(num);
num++;
}
else if(container.top()==list[p])
{
container.pop();
p++;
}
else if(container.top()<list[p])
{
if(container.size()==M)
{
flag=false;
break;
}
else
{
container.push(num++);
}
}
else
{
flag=false;
break;
}
}
if(K>0)
{
if(flag)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
else{
if(flag)
cout<<"YES";
else
cout<<"NO";
}
}
}
PAT的系统还是很不错的,遇到过一部分oj,没法一行一行检测输出,必须把答案整理在一起才能输出,而且最后多输出了一个换行符,后来才发现,但oj也过了,我邮的必须控制前面输出换行符,最后一个不输出,有点坑