Letter from Prostokvashino
"Dear children! During the summer holidays in Prostokvashino, Sharik found a piece of a sawed-off chessboard and began teaching Matroskin and me how to play chess. Matroskin quickly mastered the knight's moves and, with his strong mathematical skills, keeps asking me: "How many closed knight's tours are possible starting from this square, ensuring it returns to the starting point and visits each other square no more than once?" I managed to solve this puzzle for the example shown in the picture, but Matroskin is relentless. Please write a program that can determine this number for any square on this unusual chessboard, as Matroskin hasn't yet learned to use my laptop. With your help, I can quickly provide answers to the persistent cat. Thank you in advance. With respect for your programming skills – Uncle Fyodor."
Input
Each test consists of several test cases. Each line indicates a new starting position for the knight on the board. The number of test cases in a single test does not exceed 20.
The board always has the dimensions shown in the picture, with columns labeled by Latin letters from a to d, and rows numbered from 1 to 5.
Output
For each test case, output the answer to Matroskin's question on a separate line.