#include<bits/stdc++.h>
using namespace std;
class node{public:
int data;
nodeleft;
noderight;
node(int d)
{
data=d;
left=NULL;
right=NULL;
}
};
node* insert(node*root,int d)
{
if(root==NULL)
return new node(d);
if(d<=root->data)
{
root->left=insert(root->left,d);
}
else
root->right=insert(root->right,d);
}
node* build()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
int d;
node*root=NULL;
for(int i=0;i<n;i++)
{
d=arr[i];
root=insert(root,d);
}
return root;
}
void sumrange(node*root,int k1,int k2)
{
if(root==NULL)
return ;
if(root->data>k1)
sumrange(root->left, k1, k2);
if(k1<=root->data && k2>=root->data)
cout<data<<" ";
if(root->data<k2)
sumrange(root->right,k1, k2);
}
int main() {
int t;
cin>>t;
while(t–)
{
node*root=build();
int k1,k2;
cin>>k1>>k2;
sumrange(root,k1,k2);
}
return 0;
}