In the board game Pandemic, an outbreak occurs when a city contains more than 3 disease cubes. When the outbreak occurs, any disease cubes in the city in excess of 3 are removed, and each city connected to it gains one disease cube. This means that chain reactions can, and will occur.
Important note: Each city may only outbreak once in each chain reaction.
Input
A list of cities each containing:
- An integer representing the number of disease cubes .
- And a number of identifiers of the form (A, B ... AA, AB) (lowercase is allowed) representing which cites in list order it is connected to.
Output
A list of integers representing the number of disease cubes in each city after outbreaks have been resolved.
Winning Condition
This is code-golf, so the shortest code in bytes wins.