Pair Linked Mokepon
시간 제한2초메모리 제한2048 MB
두 Mokepon 게임에서 필요한 식별자를 모두 모아 각자의 마지막 역에 도달할 수 있게 아이템을 배치하는 경우의 수를 센다.
문제
The popular game of Mokepon can be represented as a list of stations with special items located at them and a player beginning at station . Each item has an identifier id (id) (and no two items may have the same identifier), and the player is required to have the item with identifier to be able to move to station from station . Stations may have multiple (including none) items, and the player can pick up and hold an unlimited number of items. The objective is to reach the last station: station .
You and your friend find this game too easy, so you decide to link up two games of Mokepon: your game has stations and your friend's game has stations. However, special items may appear in either game, and are now uniquely identified by the pair of id: its identifier, and which game it comes from. To progress to station in a given game, either one of you must have picked up the item with identifier for that game.
The games randomize where items gets placed in each of the game, and so not every placement of items may be possible to win from. Your goal is to count the number of distributions of items such that it is possible for the two of you to both reach the end station in your respective games. Since this number may be large, calculate it modulo a prime .
We say two distributions of items to stations are different if there is at least one station where the set of items at that station differ.
입력
The only line of input contains three integers, , , and ( , ) --- the number of stations in your and your friend's game, respectively, and the modulo to calculate with respect to.
It is guaranteed that is a prime.
출력
Output a single integer, the number of distributions of items such that both players win their respective games, modulo .
힌트
In the first sample, there are two special items: and corresponding to the two games and respectively, and thus configurations of stations where they could be located. The eight winning possibilities (in the notation (station, game)) are listed below, along with illustrations of the first two possibilities.
- ; : Both players can immediately progress to their respective end stations.
- ; : The first player unlocks their final station, at which point the second player can progress.
- ;
- ;
- ;
- ;
- ;
- ;
