class Solution:
def swapPairs(self, head: Optional[ListNode]) -> Optional[ListNode]:
if head is None or head.next is None:
return head
node1=head
node2=head.next
node3=node2.next
node1.next=self.swapPairs(node3)
node2.next=node1
return node2