* Line 1: The integer N.
* Lines 2..N: Three integers a_i, b_i and t_i, representing the two barns that edge i connects. t_i
is 0 if the herd along that edge is Charcolais, and 1 if the herd is Angus.
Line 1: One integer, representing the number of possible paths Farmer John can choose from.
7
1 2 0
3 1 1
2 4 0
5 2 0
6 3 1
5 7 1
INPUT DETAILS:
There are 7 barns and 6 edges. The edges from 1 to 2, 2 to 4 and 2 to 5 have Charcolais herds along
them.
1
OUTPUT DETAILS:
No path of length 2 can have a suitable rest stop on it, so we can only consider paths of length 4.
The only path that has a suitable rest stop is 3-1-2-5-7, with a rest stop at 2.