package pat树;
//ac
//参考博客
//javascript:void(0)
import java.util.Scanner;
public class Main2是否同一棵二叉搜索树 {
static int n;
static int m;
static int[]arr;
public static boolean charge(node i,node j) {
if(i!=null&&j!=null) {
if(i.v==j.v)return charge(i.le,j.le)&&charge(i.ri,j.ri);
else return false;
}
else if(i==null&&j==null)return true;
else return false;
}
public static node insert(node root,int i) {
if(root==null) {
root=new node();
root.v=arr[i];
return root;
}
else {
if(arr[i]>root.v) {
root.ri=insert(root.ri,i);
}
else {
root.le=insert(root.le,i);
}
return root;
}
}
public static node build() {
node root=null;
for(int i=0;i<n;i++)root=insert(root,i);
return root;
}
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
while(in.hasNext()) {
n=in.nextInt();
if(n==0)break;
m=in.nextInt();
arr=new int[n];
for(int i=0;i<n;i++)arr[i]=in.nextInt();
node root=build();
for(int i=0;i<m;i++) {
for(int j=0;j<n;j++) {
arr[j]=in.nextInt();
}
node rootsecond=build();
if(charge(root,rootsecond))System.out.println("Yes");
else System.out.println("No");
}
}
}
}
class node{
int v;
node le;
node ri;
}