Farmer John has a large farm with N barns (1≤N≤10^5), some of which are already painted and some n
ot yet painted. Farmer John wants to paint these remaining barns so that all the barns are painted,
but he only has three paint colors available. Moreover, his prize cow Bessie becomes confused if two
barns that are directly reachable from one another are the same color, so he wants to make sure thi
s situation does not happen.It is guaranteed that the connections between the N barns do not form an
y 'cycles'. That is, between any two barns, there is at most one sequence of connections that will l
ead from one to the other.How many ways can Farmer John paint the remaining yet-uncolored barns?