//pair of roses array challenge
#include<bits/stdc++.h>
#include
#include
using namespace std;
int main() {
int t,n,amount;
int diff=0;
int min_diff=INT_MAX;
int wi,wj;
cin>>t;
while(t!=0){
cin>>n;
int price[n];
for(int i=0;i<n;i++){
cin>>price[i];
}
cin>>amount;
sort(price,price+n);
int i=0;
int j=n-1;
while(i<j){
if(price[i]+price[j]==amount){
diff=abs(price[j]-price[i]);
if(diff<min_diff){
min_diff=diff;
wi=i;
wj=j;
}
i++;
j--;}
if(price[i]+price[j]>amount){
j--;
}
if(price[i]+price[j]<amount){
i++;
}
}
cout<<"Deepak should buy roses whose prices are "<<price[wi]<<" and "<<price[wj]<<"."<<endl;
t--;
}
return 0;
}