# -*- coding:utf-8 -*-
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None
class Solution:
    def FindFirstCommonNode(self, pHead1, pHead2):
        # write code here
        #init

        #process
        a = pHead1
        b = pHead2
        while a != b:
            if a != None:
                a = a.next 
            else:
                a = pHead2
            if b != None:
                b = b.next 
            else:
                b = pHead1

        return a