musicians performers arriving and stages stages on site. Each arriving musician is sent to one of the stages. Everyone on the same stage performs together as one band; some stages may stay empty.
After the show, the jury gives every band (that is, every non-empty stage) a rating, an integer from 1 to max_rating.
Two festival outcomes differ if at least one musician ended up on a different stage or at least one band got a different rating. How many outcomes are possible? The answer can be huge, so return it modulo 10⁹ + 7.musicians=2, stages=2, max_rating=2 → 12
If both musicians share a stage (2 ways), there is one band and 2 possible ratings: 4 outcomes. If they are on different stages (2 ways), there are two bands rated 2 · 2 = 4 ways: 8 outcomes. 12 in total.
musicians=3, stages=1, max_rating=5 → 5
With a single stage all three play together, and that band can get any of 5 ratings.
musicians=4, stages=3, max_rating=1 → 81
The rating is always 1, so only the stage assignments count: 3⁴ = 81.
musicians=2, stages=2, max_rating=2
12
Run checks the first 3 tests in your browser. Submit checks all 94 tests on the server, hidden ones included.