#include<bits/stdc++.h>
using namespace std;
class node{
public:
int data;
nodenext;
node(int d){
data = d;
next = NULL;
}
};
void insertAttail(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 *take_input(node head ,int size){
while(size–){
int d;
cin>>d;
insertAttail(head ,d);
}
return head;
}
void print(node head){
while(head!=NULL){
cout<<head;
head = head->next;
}
}
int main() {
node *l1 = NULL;
node *l2 = NULL;
int t;
cout<<“Enter the no of testcases”<<endl;
cin>>t;
while(t–){
int n1;
cout<<“Enter the size of list 1----”;
cin>>n1;
cout<<“Enter the elements of list 1----”;
take_input(l1,n1);
print(l1);
cout<<"Enter the size of list 1----";
int n2;cin>>n2;
cout<<"Enter the elements of list 2----";
take_input(l2,n2);
print(l2);
while(l1->next!=NULL){
l1 = l1->next;
}
l1 = l2;
print(l1);
}
return 0;
}