# Definition for singly-linked list.# class ListNode:# def __init__(self, val=0, next=None):# self.val = val# self.next = nextclassSolution:defswapPairs(self, head: ListNode)-> ListNode:
dummy = ListNode()
dummy.next= head
head = dummy
while(head.nextand head.next.next):
first = head.next
second = first.next
first.next= second.next
second.next= first
head.next= second
head = first
return dummy.next