#include<iostream>
using namespace std;
class Node{
public:
Node(){
left = right = -1;
}
int left;
int right;
};
void Creat(Node *s,int n){
int root = -1;
while(n--){
int t;
cin>>t;
if(root == -1)root = t;
else{
int temp = root;
while(true){
if(temp > t){
if(s[temp].left == -1){
s[temp].left = t;
break;
}
else temp = s[temp].left;
}
else{
if(s[temp].right == -1){
s[temp].right = t;
break;
}
else temp = s[temp].right;
}
}
}
}
}
bool Compare(Node *s,Node *p,int n){
for(int i = 1;i <= n;i++){
if(s[i].left == p[i].left && s[i].right == p[i].right)continue;
else return false;
}return true;
}
int main(){
int n,m;
while(cin>>n && n != 0){
cin>>m;
Node *s = new Node[n + 2];
Creat(s,n);
for(int i = 0;i < m;i++){
Node *p = new Node[n + 2];
Creat(p,n);
if(Compare(s,p,n))cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
}