//p259下 1051 Pop Sequence #include <cstdio>
#include <stack>
using namespace std;
const int maxn = 1010;
int arr[maxn];
stack<int> st;
int main(){
int m,n,T;
scanf("%d%d%d",&m,&n,&T);
while(T--){
while(!st.empty()) st.pop();//清空栈
for(int i=1;i<=n;++i) scanf("%d",&arr[i]);
int current = 1;
bool flag = true;
for(int i=1;i<=n;++i){
st.push(i);
if(st.size() > m) {
flag = false;
break;
}
while(!st.empty() && st.top() == arr[current]){
st.pop();
current++;
}
}
if(st.empty() == true && flag == true){
printf("YES\n");
}else{
printf("NO\n");
}
}
return 0;
}
//添加版本
//A1051 天勤 todo
#include <iostream>
#define maxSize 10000
using namespace std;
int main(){
int M,N,K;
int st[maxSize],top = -1;
cin>>M>>N>>K;
//cout<<M<<N<<K;
for(int i=0;i<K;++i){
cout<<"liu"<<endl;
top = -1;
int a[N],t = 0;
bool flag = true;
for(int j=0;i<N;++j) cin>>a[j];
for(int j=1;j<=N;j++){
// for(int j=1;j<N;j++){
st[++top] = j;
if(top+1 > M) {
flag = false;// top+1 为元素个数
break; //视频没有Break
}
while(top > -1 && st[top] == a[t]){
t++;
--top;
}
if(top > -1 && st[top] != a[t] && j==N){
flag = false;
break;//视频没有Break
}
}
if(flag == true) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}