#include<vector>#include<iostream>#include<algorithm>#include<unordered_map>#include<set>#include<map>#include<cstring>#include<string>#include<queue>#include<array>#include<stack>usingnamespace std;int arr[1001];
stack<int>st;intmain(){int m, n, T;
cin >> m >> n >> T;while(T--){while(!st.empty()){
st.pop();}for(int i =0; i < n; i++){
cin >> arr[i];}int index =0;bool flag =true;for(int i =0; i < n; i++){
st.push(i +1);if(st.size()> m){
flag =false;break;}while(!st.empty()&& st.top()== arr[index]){
st.pop();
index++;}}if(st.empty()){
cout <<"YES"<< endl;}else{
cout <<"NO"<< endl;}}}