struct ListNode
{
	int val;
	struct ListNode *next;
};
struct ListNode *addTwoNumbers(struct ListNode *l1, struct ListNode *l2)
{
	struct ListNode *pp = NULL, *p = l1;
	struct ListNode *qp = NULL, *q = l2;
	int carry = 0;
	while (p != NULL && q != NULL)
	{
		p->val += q->val + carry;
		carry = 0;
		if (p->val >= 10)
		{
			carry = 1;
			p->val -= 10;
		}
		pp = p;
		p = p->next;
		qp = q;
		q = q->next;
	}
	if (q)
	{
		pp->next = p = q;
		qp->next = NULL;
	}
	while (carry && p)
	{
		p->val += carry;
		carry = 0;
		if (p->val >= 10)
		{
			carry = 1;
			p->val -= 10;
		}
		pp = p;
		p = p->next;
	}
	if (carry)
	{
		struct ListNode *n = (struct ListNode *)malloc(sizeof(struct ListNode));
		n->val = 1;
		n->next = NULL;
		pp->next = n;
	}
	return l1;
}