/*
public class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}*/
public class Solution {
    public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
         ListNode L1 = pHead1;
         ListNode L2 = pHead2;

        while(L1 != L2){
            L1 = (L1 == null) ? pHead2 : L1.next;
            L2 = (L2 == null) ? pHead1 : L2.next;
        }

        return L1;
    }
}