package pTA;
/*
* 5 7 5
1 2 3 4 5 6 7
3 2 1 7 5 6 4
7 6 5 4 3 2 1
5 6 4 3 7 2 1
1 7 6 5 4 3 2
YES
NO
NO
YES
NO
*/
import java.util.Scanner;
import java.util.Stack;
public class Main{
public static void main(String[] args){
Stack<Integer> sta=new Stack<Integer>();
Scanner s=new Scanner(System.in);
int M=s.nextInt();
int N=s.nextInt();
int K=s.nextInt();
while(K--!=0){
sta.clear();
boolean flag=true;
int T=1;
for(int j=0;j<N;j++){
int num=s.nextInt();
while(sta.isEmpty()||sta.lastElement()!=num){
sta.push(T++);
if(sta.size()>M){
flag=false;
break;
}
}
if(flag&&sta.size()>=1&&sta.lastElement()==num)
sta.pop();
}
if(flag)
System.out.println("YES");
else
System.out.println("NO");
}
}
}
/*
* 5 7 5
1 2 3 4 5 6 7
3 2 1 7 5 6 4
7 6 5 4 3 2 1
5 6 4 3 7 2 1
1 7 6 5 4 3 2
YES
NO
NO
YES
NO
*/
import java.util.Scanner;
import java.util.Stack;
public class Main{
public static void main(String[] args){
Stack<Integer> sta=new Stack<Integer>();
Scanner s=new Scanner(System.in);
int M=s.nextInt();
int N=s.nextInt();
int K=s.nextInt();
while(K--!=0){
sta.clear();
boolean flag=true;
int T=1;
for(int j=0;j<N;j++){
int num=s.nextInt();
while(sta.isEmpty()||sta.lastElement()!=num){
sta.push(T++);
if(sta.size()>M){
flag=false;
break;
}
}
if(flag&&sta.size()>=1&&sta.lastElement()==num)
sta.pop();
}
if(flag)
System.out.println("YES");
else
System.out.println("NO");
}
}
}