#include <iostream>
#include <string.h>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;
int n,l;
typedef struct dataStruct{
dataStruct* left;
dataStruct* right;
int data;
}*node;
void CreatTree(node &T, int dt){
if(T == NULL){
T = new dataStruct();
T->data = dt;
T->left = NULL;
T->right = NULL;
return ;
}
if(T->data > dt){
CreatTree(T->left, dt);
}else{
CreatTree(T->right, dt);
}
}
bool isEqual(node t1,node t2){
if(t1 != NULL && t2 != NULL){
if(t1->data != t2->data){
return false;
}
return (isEqual(t1->left,t2->left)&&isEqual(t1->right,t2->right));
}else{
if(t1 == NULL && t2 ==NULL){
return true;
}else{
return false;
}
}
}
int main(){
int w;
int len1;
node t1,t2;
while(cin>>n && n != 0){
cin>>l;
t1 = NULL;
for(int i = 0 ;i < n ;i++){
cin>>w;
CreatTree(t1,w);
}
for(int i = 0 ;i < l ;i++){
t2 = NULL;
for(int j = 0 ;j < n ;j++){
cin>>w;
CreatTree(t2, w);
}
if(isEqual(t1,t2)){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
}
return 0;
}
#include <string.h>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;
int n,l;
typedef struct dataStruct{
dataStruct* left;
dataStruct* right;
int data;
}*node;
void CreatTree(node &T, int dt){
if(T == NULL){
T = new dataStruct();
T->data = dt;
T->left = NULL;
T->right = NULL;
return ;
}
if(T->data > dt){
CreatTree(T->left, dt);
}else{
CreatTree(T->right, dt);
}
}
bool isEqual(node t1,node t2){
if(t1 != NULL && t2 != NULL){
if(t1->data != t2->data){
return false;
}
return (isEqual(t1->left,t2->left)&&isEqual(t1->right,t2->right));
}else{
if(t1 == NULL && t2 ==NULL){
return true;
}else{
return false;
}
}
}
int main(){
int w;
int len1;
node t1,t2;
while(cin>>n && n != 0){
cin>>l;
t1 = NULL;
for(int i = 0 ;i < n ;i++){
cin>>w;
CreatTree(t1,w);
}
for(int i = 0 ;i < l ;i++){
t2 = NULL;
for(int j = 0 ;j < n ;j++){
cin>>w;
CreatTree(t2, w);
}
if(isEqual(t1,t2)){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
}
return 0;
}