eolymp
bolt
Try our new interface for solving problems
Problems

Pink Floyd

Pink Floyd

The band \textit{Pink Floyd} is going to go on a new concert tour around the world. From previous experience, the group knows that lead singer Roger Waters is constantly nervous when flying. On some routes he loses weight from excitement, while on others he eats a lot and gains weight. It is known that the more Roger weighs, the better the band performs, so it is necessary to plan flights so that Roger’s weight at each concert is as high as possible. The group must visit cities in the same order in which it gives concerts, and the group may visit intermediate cities between concerts. \InputFile The first line of the input file contains three natural numbers $n$, $m$ and $k$ - the number of cities in the world, the number of flights and the number of concerts that the group should give, respectively $(n ≤ 100, m ≤ 10000, 2 ≤ k ≤ 10000)$. Cities are numbered from $1$ to $n$. The next $m$ lines contain descriptions of flights, one per line. Flight number $i$ is described by three numbers $b_i$, $e_i$ and $w_i$ - the number of the initial and final city of the flight and the expected change in Roger's weight in milligrams $(1 ≤ b_i, e_i ≤ n, -100000 ≤ w_i ≤ 100000) $. The last line contains the numbers $a_1, a_2, ..., a_k$ - the numbers of the cities in which the concerts $(a_i ≠ a_{i+1})$ are held. At the beginning of the concert tour, the group is in the city of $a_1$. It is guaranteed that the group can perform all concerts. \OutputFile The first line of the output file should contain the number $l$ - the number of trips that the group should make. The second line should contain $l$ numbers - the numbers of the flights used. If there is a sequence of routes between gigs such that Roger will gain weight indefinitely, then the first line of the output file should contain the message `infinitely kind`.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4 8 5
1 2 -2
2 3 3
3 4 -5
4 1 3
1 3 2
3 1 -2
3 2 -3
2 4 -10
1 3 1 2 4
Output example #1
6
5 6 5 7 2 3