# -*- coding:utf-8 -*-
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None
class Solution:
    # 返回ListNode
    def ReverseList(self, pHead):
        # write code here
        if pHead == None:
            return None
        cur_pointer = pHead
        pre_pointer = None
        next_pointer = None
        while (cur_pointer != None):
            next_pointer = cur_pointer.next
            cur_pointer.next = pre_pointer
            pre_pointer = cur_pointer
            cur_pointer = next_pointer
        return pre_pointer