public ListNode mergeLists(ListNode A, ListNode B)
    {
    	if(A == null) return B; 
    	if(B == null) return A;
    	
    	ListNode dummy = new ListNode(0);
    	ListNode currA = A, currB = B, curr = dummy;
    	
    	while(currA!=null || currB!=null)
    	{
    		if(currA == null)
    		{
    			curr.next = currB; 
    			currB = currB.next;
    		}else if(currB == null)
    		{
    			curr.next = currA; 
    			currA = currA.next;
    		}else if(currA.val < currB.val)
    		{
    			curr.next = currA; 
    			currA = currA.next;
    		}else
    		{
    			curr.next = currB; 
    			currB = currB.next;
    		}
    		curr = curr.next;
    	}
    	
    	return dummy.next;
    }