Wrong-Answer in Merge Sorted Linked Lists

I have to try to submit the solution but it always shows TESTCASE #1: wrong-answer(Time:0 s) but according to me my solution is correct as it is giving correct ouputs on other online IDE’s here is my code is ther is any flaw in it pls help:#include <bits/stdc++.h>

//LINKED LIST IMPLEMENTATION

using namespace std;

class node{
public:
long long int data;
node* next;
node(long long int d)
{
data=d;
next=NULL;
}
};

void printLinkedList(node*head)
{
while(head!=NULL)
{
cout<data<<" ";

    head=head->next;
}

}

void insertAtTail(node*&head, long long int data){ // function to insert node at the end of linked list
if(head==NULL)
{ head=new node(data);
return ;

}

node* tail=head;
 while(tail->next!=NULL)

{
tail=tail->next;

}

tail->next=new node(data);
return ;

}

node* mergeLL(node head1,node head2)
{ node*head3=NULL;

node* temp1=head1;
node* temp2=head2;
while(temp1!=NULL and temp2!=NULL)
{
if(temp1->datadata)
{
insertAtTail(head3,temp1->data);
temp1=temp1->next;
}
else
{
insertAtTail(head3,temp2->data);
temp2=temp2->next;

	}
}


	while(temp2!=NULL)
	{
		insertAtTail(head3,temp2->data);
		temp2=temp2->next;
	}


while(temp1!=NULL)
	{
		insertAtTail(head3,temp1->data);
		temp1=temp1->next;
	}


return head3;

}

int main() {
long long int x,i,n1,n2,t;
node* head1=NULL;
node* head2=NULL;
cin>>t;
while(t–){
cin>>n1;
for(i=0;i<n1;i++)
{
cin>>x;

  insertAtTail(head1,x);

}
cin>>n2;

for(i=0;i<n2;i++)
{
cin>>x;

  insertAtTail(head2,x);

}
node* temp=mergeLL(head1,head2);

printLinkedList(temp);

}

return 0;

}

Plz send your code by saving on ide as it is difficult to understand it over here.