# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param head ListNode类 
# @return ListNode类
#  

class Solution:
    def head_List(self, head: ListNode) -> list:
        if head is None:
            return None
        Phead = head
        list1 = []
        while Phead:
            list1.append(int(Phead.val))
            Phead = Phead.next
        list2 = []
        for i in range(0, len(list1), 2):
            list2.append(list1[i])
        for i in range(1, len(list1), 2):
            list2.append(list1[i])
        return list2                

    def oddEvenList(self, head: ListNode) -> ListNode:
        list1 = self.head_List(head)
        if head is None:
            return None
        Pheadres = head
        for i in list1:
            Pheadres.val = i
            Pheadres = Pheadres.next
        return head