class Solution:
    def isPail(self , head ):
        # write code here
        slow, fast = head, head
        rev = ListNode(None)

        while fast and fast.next:
            fast = fast.next.next
            slow_next = slow.next
            slow.next = rev
            rev = slow
            slow = slow_next

        if fast:
            slow = slow.next

        while slow:
            if slow.val != rev.val:
                return False
            slow = slow.next
            rev = rev.next
        return True