My answer for test case looking correct but all test case wrong answer

#include
using namespace std;
class node{

public:
	int data;
	node *next;
	
node(int value){
	data=value;
	next=NULL;
}

};

void insertAt_tail(node*&head,int value){
if(head==NULL){
head= new node(value);
return;
}
node n=new node(value);
node
temp=head;
while(temp->next!=NULL){
temp=temp->next;
}
temp->next=n;
}

void print(node *head){
while(head!=NULL){
cout<data<<" ";
head=head->next;
}
}
node * merge(node * head1,node * head2){
if(head1==NULL) return head2;
if(head2==NULL) return head1;
node * c;
if(head1->data data){
c=head1;
c->next=merge(head1->next,head2);
}
else{
c=head2;
c->next=merge(head1,head2->next);
}
return c;
}

int main(){
int t;
cin>>t;
while(t–){
node *head1=NULL;
node *head2=NULL;
int n1,n2,ele;
cin>>n1;
for(int i=0;i<n1;i++){
cin>>ele;
insertAt_tail(head1,ele);
}
cin>>n2;
for(int i=0;i<n2;i++){
cin>>ele;
insertAt_tail(head2,ele);
}
node * head=merge(head1,head2);
print(head);
}
return 0;
}

hi @kumawatnitesh093 print newline after each test case

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.