#Lutece1568. Aston1shed Poker
Aston1shed Poker
Migrated from Lutece 1568 Aston1shed Poker
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
The evil invented poker, and poker made people depraving.
As you known, a deck of poker consists of cards, each card has a suit and a rank.
There are four suits in a deck of poker, we use the characters in set representing the suits spades , hearts , diamonds , and clubs .
The rank of a card is represented as an integer from to .
Now you are given pairwise distinct cards from a deck of poker, you need to calculate the ways to arrange these cards such that there are no successive card(s) which have the same rank.
Input
There are two integers and in the first line.
For the next lines, each line describes a card, represented by it's rank and suit, see the sample for more details.
, .
Output
Print the number of ways to arrange these cards modulo .
Samples
3 2
12h
13h
13s
2
Resources
The 15th UESTC Programming Contest Final