You and Justin are playing a game on a
Then you can place any number of rooks on the chessboard. A rook can move horizontally or vertically through any number of squares, but cannot move through squares that have been cut out. A rook can attack a square if and only if it can move to that square. After you place these rooks, Justin is supposed to find a square that is not occupied by rooks and cannot be attacked by any rook.
You want to win this game, that is to say, Justin cannot find any square satisfying these requirements. Now you need to calculate the number of ways to place rooks to ensure you can win. Since the answer may be large, output it modulo
The first line contains an integer
The second line contains
A single integer, denoting the number of ways modulo
3
2 1 2
17
For 20% testcases:
For 50% testcases:
For all testcases: