



"N-T solitaire" is a card game for a single player.
There are cards in the game (3 \leq N \leq 15). Each card is uniquely defined by its value (an integer from to ) and its suit (, , , or ).
Initially, all cards are distributed into piles (4 \leq T \leq 8). The first (4N) \bmod T piles contain (4N \div T)+1 cards each, while the remaining piles contain 4N \div T cards each (where and denote integer division and remainder, respectively). The cards in each pile are ordered from bottom to top (left to right in the input).
You may remove the top card from two different piles if the sum of their values equals N+1, regardless of their suits. This is the only way to move cards to the discard pile.
Write a program to determine the maximum number of cards that can be moved to the discard pile.
The first line contains two integers and . Each of the next lines describes one pile, from the first to the -th. Each card is given by its value (an integer) immediately followed by a suit symbol (a character with ASCII code (), (), (), or ()), without a space in between. Cards within one pile are separated by single spaces, ordered from bottom to top (left to right in the input).
Print a single integer: the maximum number of cards that can be moved to the discard pile.
Example 1