```
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param {ListNode} l1
# @param {ListNode} l2
# @return {ListNode}
def mergeTwoLists(self, l1, l2):
p1 = l1
p2 = l2
guard = ListNode(0)
q = guard
while p1 is not None and p2 is not None:
if p1.val <= p2.val:
q.next = p1
p1 = p1.next
q = q.next
else:
q.next = p2
p2 = p2.next
q = q.next
if p1 is not None:
q.next = p1
if p2 is not None:
q.next = p2
return guard.next
```