|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|4 초||256 MB||69||12||11||29.730%|
Chess is a game in which two sides control pieces in an attempt to capture each other’s king. The pieces vary in mobility. At the beginning of a game the kings are rather vulnerable. They are less mobile than most other pieces and they tend to hide behind their pawns. Like in real life, as soon as both queens have left the game it is time for the kings to come into action. Because there is little threat left for the king, he can now move safely around the board. Indeed his mobility seems to be quite strong at this stage making him one of the more dangerous pieces. Your task is to measure the mobility of the king in the endgame.
Consider a chess board of N × N squares. The king is the only piece on the board. He starts at a given position and wants to go to another given position in the minimum number of moves. The king can move to any adjacent square in any orthogonal or diagonal direction.
The input starts with a line containing an integer T, the number of test cases. Then for each test case:
For each test case, output one line with a single integer: the number of ways by which the king can reach the destination square in the minimum number of moves. As this number can be very large, you must reduce your answer modulo 5,318,008.
2 3 1 2 3 2 8 2 2 7 7