what is error in my code 2test case not pass
#include
#include
using namespace std;
void next(int *a,int n){
stack<int>s;
stack<int>v;
s.push(0);
int i=1;
for( ;i<n;i++){
while(!s.empty() && a[s.top()]<a[i]){
// cout<<a[s.top()]<<","<<a[i]<<endl;
v.push(s.top());
s.pop();
}
while(!v.empty()){
cout<<a[v.top()]<<","<<a[i]<<endl;
v.pop();
}
if(!s.empty() && a[s.top()]>a[i]){
}
s.push(i);
}
if(i==n){
while(!s.empty()){
v.push(s.top());
s.pop();
}
}
while(!v.empty()){
cout<<a[v.top()]<<","<<"-1"<<endl;
v.pop();
}
}
int main(){
int t;
cin>>t;
while(t–){
long long int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
next(a,n);
}
return 0;
}