A DAG is represented in a list of pairs, the first element of the pair has a directed link to the second element. All elements in each pair are uniquely represented by a positive number.
For example, [1,2], [3,4], [1,3], [5,4] is the following graph:
1 ---> 2
|
V
3 ---> 4 <--- 5
Given 2 nodes in the graph, write a function that returns true if the graph contains at least one common ancestor for these 2 nodes.