#include
using namespace std;
struct node
{
int data;
node *next;
};
node *head;
node *tail;
int count;
void push(int b,int n)
{
node *x=new node;
x->data=b;
x->next=NULL;
if(count==0)
{
head=x;
tail=x;
}
else if(count>=n)
{
tail->next=x;
tail=tail->next;
head=head->next;
}
else
{
tail->next=x;
tail=tail->next;
}
}
bool search(int b)
{
node *x;
x=head;
bool flag= false;
if(x==NULL)
{
return flag;
}
while(x!=NULL)
{
if((x->data)==b)
{
flag=true;
return flag;
}
x=x->next;
}
return flag;
}
void print()
{
node *x;
x=head;
while(x!=NULL)
{
cout<<x->data<<" ";
x=x->next;
}
cout<<"\n";
}
//main function
int main()
{
int t,m,n,a,b;
cin>>t;
while(t--)
{
head=NULL;
tail=NULL;
cin>>n>>m;
count=0;
while(m--)
{
cin>>a>>b;
if(a==1)
{
push(b,n);
++count;
}
if(a==2)
{
if(search(b))
{
cout<<"YES\n";
}
else
{
cout<<"NO\n";
}
}
}
}
return 0;
}