import java.util.*;
/*
* public class ListNode {
* int val;
* ListNode next = null;
* public ListNode(int val) {
* this.val = val;
* }
* }
*/
public class Solution {
public ListNode Merge (ListNode pHead1, ListNode pHead2) {
ListNode list=new ListNode(-1);
ListNode node=list;
while(pHead1!=null&&pHead2!=null){
if(pHead1.val>pHead2.val){
node.next=pHead2;
pHead2=pHead2.next;
}else{
node.next=pHead1;
pHead1=pHead1.next;
}
node=node.next;
}
if(pHead1!=null){
node.next=pHead1;
}
if(pHead2!=null){
node.next=pHead2;
}
return list.next;
}
}