# Don't know what's wrong with this solution of Concussive Sequence

Tried several times, But don’t why it is not passing even subtask 1

#include<bits/stdc++.h>

using namespace std;

void print(vector<int> &ans){
int i,n= ans.size();
for(i= 0;i<n;i++)
cout<<ans[i]<<" ";
cout<<endl;
}

bool isValid(vector<int> &ans){
int i,n= ans.size();
for(i= 1;i<n-1;i++){
if(ans[i-1]>ans[i] && ans[i]<ans[i+1]) continue;
if(ans[i-1]<ans[i] && ans[i]>ans[i+1]) continue;
return false;
}
return true;
}

void solve(){
int n,i;
cin>>n;
vector<int> arr(n);
for(i= 0;i<n;i++)
cin>>arr[i];
sort(arr.begin(), arr.end());
vector<int> ans1(n), ans2(n);
int k;
k= n-1;
for(i= 0;k>=0 && i<n;i+= 2)
ans2[i]= arr[k--];
for(i= 1;k>=0 && i<n;i+= 2)
ans2[i]= arr[k--];

k= 0;
for(i= 0;k<n && i<n;i+=2)
ans1[i]= arr[k++];
for(i= 1;k<n && i<n;i+=2)
ans1[i]= arr[k++];
bool flag2= isValid(ans2), flag1= isValid(ans1);
// cout<<flag1<<" "<<flag2<<endl;
if(flag1== false && flag2== false){
cout<<-1<<endl;
return;
}
if(flag2== true){
print(ans2);
return;
}
print(ans1);
}

int main(){
int t;
cin>>t;
while(t--)
solve();
}