Problems
Farmer John is worried for the health of his cows (conveniently numbered
Recently, Farmer John tested all of his cows and found some of them to be positive for the disease. Using video footage from inside his barn, he is able to review recent interactions between pairs of cows --- it turns out that when cows greet each-other, they shake hooves, a gesture that can unfortunately spread the infection from one cow to another. Farmer John assembles a time-stamped list of interacting pairs of cows, with entries of the form
(i) Exactly one cow on his farm could have started out carrying the disease (we'll call this cow "patient zero").
(ii) Once a cow is infected, she passes the infection along with her next
(iii) Once a cow is infected, she stays infected.
Unfortunately, Farmer John doesn't know which of his
Input
The first line of the input file contains
Output
Print a single line with three integers
Example
4 3
1100
7 1 2
5 2 3
6 2 4
1 1 Infinity
The only candidate for patient zero is cow 1. For all