class Solution:
def swapPairs(self, head: Optional[ListNode]) -> Optional[ListNode]:
dummy = ListNode(0, head)
cur = dummy
while cur.next and cur.next.next:
first = cur.next
second = cur.next.next
next_p = second.next
cur.next = second
second.next = first
first.next = next_p
cur = first
return dummy.next