from structures import build_list, list_values

def reorder_list(head):
    if head is None or head.next is None:
        return head
    slow, fast = head, head.next
    while fast is not None and fast.next is not None:
        slow = slow.next
        fast = fast.next.next
    current = slow.next
    slow.next = None
    second = None
    while current is not None:
        following = current.next
        current.next = second
        second, current = current, following
    first = head
    while second is not None:
        next_first, next_second = first.next, second.next
        first.next = second
        second.next = next_first
        first, second = next_first, next_second
    return head
