#include
using namespace std;
class node{
public:
int data;
nodenext;
node(int d){
data=d;
next=NULL;
}
};
int len(nodehead){
int length=0;
while(head!=NULL){
head=head->next;
length++;
}
return length;
}
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;
}
void insertathead(node*&head,int data){
noden=new node(data);
n->next=head;
head=n;
}
void print(nodehead){
while(head!=NULL){
cout<<head->data<<"<-";
head=head->next;
}
}
void insertatmiddle(node*&head,int data,int p){
if(head==NULL||p==0){
insertathead(head,data);
}
else if(p>len(head)){
insertattail(head,data);
}
else{
int jump=1;
nodetemp=head;
while(jump<=p-1){
temp=temp->next;
jump+=1;
}
noden=new node(data);
n->next=temp->next;
temp->next=n;
}
}
void deleteathead(node*&head){
if(head==NULL){
return;
}
nodetemp=head;
head=head->next;
delete temp;
return;
}
void deleteattail(node&head){
nodepre=NULL;
nodetemp=head;
while(temp->next!=NULL){
pre=temp;
temp=temp->next;
}
delete temp;
pre->next=NULL;
return;
}
bool searchrecusive(nodehead,int key){
if(head==NULL){
return false;
}
if(head->data==key){
return true;
}
else{
return searchrecusive(head->next,key);
}
}
void builtlist(node&head){
int data;
cin>>data;
while(data!=-1){
insertathead(head,data);
cin>>data;
}
}
istream& operator>>(istream&is,node*&head){
builtlist(head);
return is;
}
ostream& operator<<(ostream&os,node*&head){
print(head);
return os;
}
/void reverse(node&head){
nodec=head;
nodep=NULL;
noden;
while(c!=NULL){
n=c->next;
c->next=p;
p=c;
c=n;
}
head=p;
}/
nodemiddlepoint(node&head){
if(head==NULL||head->next==NULL){
return head;
}
nodeslow=head;
nodefast=head->next;
while(fast!=NULL && fast->next!=NULL){
fast=fast->next->next;
slow=slow->next;
}
return slow;
}
nodemerge(nodea,nodeb){
if(a==NULL){
return b;
}
else if(b==NULL){
return a;
}
node c;
if(a->data < b->data){
c=a;
c->next=merge(a->next,b);
}
else{
c=b;
c->next=merge(a,b->next);
}
return c;
}
int main() {
nodehead=NULL;
nodehead2=NULL;
cin>>head>>head2;
head=merge(head,head2);
cout<<head<<endl;
print(head);
}