Pitmutation
시간 제한2초메모리 제한1024 MB
두 선수가 카드 한 장씩 내어 높은 쪽이 점수를 얻는 게임에서, 알려지지 않은 카드 배치 중 첫 번째 선수가 정확히 S점을 얻는 경우의 수를 센다.
문제
Pitmuation is a two player card game, where each player has a deck of cards numbered from to . The two players shuffle their decks and they put the cards on the table one by one. At each step, the player with the higher card wins one point. If the two cards are equal, there are no points awarded. The game ends after steps, when all the cards have been used.
For some indices between and you know the cards of the first player, and for the other indices you know the cards of the second player.
Given the size of the decks , an integer and the known cards for the two players, determine the number of configurations of the unknown cards where the first player is awarded a total of exactly points.
입력
The first line contains two integers and .
The second line contains integers between and , corresponding to the first player. The s represent unknown cards, while the other values represent known cards.
The third line contains integers corresponding to the cards of the second player, in the same manner.
출력
Output the answer modulo .