我们令$fa[i]$为$i$直接连向的点

那么显然,$fa[i] \in {a_{i, 1}, a_{i, 2}}​$

假设$a_{i, 1}$为$fa[i]$,那么$a_{2, i} \in { a_{fa[i], 1}, a_{fa[i], 2} }$

否则肯定有$a_{2, i} \not\in { a_{fa[i], 1}, a_{fa[i], 2} }$

所以,如果有$a_{2, i} \in { a_{fa[i], 1}, a_{fa[i], 2} }$,那么$fa[i] = a_{i, 1}$,否则$fa[i] = a_{i, 2}$