



"N-T solitaire" is a card game for a single player. There are cards in the game, where 3 \le N \le 15. Each card is uniquely determined by its value (an integer in the range to ) and suit (, , , or ).
Initially, all cards are distributed into piles (4 \le T \le 8). The first 4N \bmod T piles each contain \left\lfloor \frac{4N}{T} \right\rfloor + 1 cards, and the remaining piles contain \left\lfloor \frac{4N}{T} \right\rfloor cards. Here, "/" and "Cards in each pile are listed from bottom to top (from left to right in the input).
The only allowed move is: if the sum of the values of the top cards of any two piles is N+1, these two cards (regardless of their suits) may both be moved to the discard pile.
Write a program that determines the maximum number of cards that can be moved to the discard pile.
The first line contains two integers and (3 \le N \le 15, 4 \le T \le 8).
Each of the next lines contains the description of a pile. Each card is described by its value (an integer) followed immediately by its suit (a character with ASCII code 03 (), 04 (), 05 (), or 06 ()), with no space between value and suit. The cards in a pile are separated by a single space. The order is from bottom card (leftmost) to top card (rightmost).
Output a single integer: the maximum possible number of cards that can be moved to the discard pile.
Example
7 4
3\texttt{\char"032 5 1 7 1 4 2 3 4 6 2 1 7 5 6 4 3 7 5 12
Example 1