Time Limit in Merge Sored List

Time limit error in this code
#include <bits/stdc++.h>
using namespace std;
class node{
public:
int data;
node*next;
node(int d)
{
data=d;
next=NULL;
}
};

void insertEnd(node*&head,int data)
{
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(nodea,nodeb)
{
if(a==NULL)
{
return b;
}
if(b==NULL)
{
return a;
}

node*c;
if(a->data<b->data)
{
	c=a;
	c->next=mergeLL(a->next,b);
}
else
{
	c=b;
	c->next=mergeLL(a,b->next);
}
return c;

}
void printLL(nodehead)
{
node
temp=head;
while(temp!=NULL)
{
cout<data<<" ";
temp=temp->next;
}
}

int main()
{
nodehead1=NULL;
node
head2=NULL;
int t;
cin>>t;
while(t>0)
{
int n1;
cin>>n1;
for(int i=0;i<n1;i++)
{
int data1;
cin>>data1;
insertEnd(head1,data1);
}
int n2;
cin>>n2;
for(int j=0;j<n2;j++)
{
int data2;
cin>>data2;
insertEnd(head2,data2);
}
node*ans=mergeLL(head1,head2);
printLL(ans);
t–;
}
return 0;
}