{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\"text/css\"\u003e pre { text-align:left; font-family: \"Courier New\", Courier, monospace; font-size: 16px; white-space: pre; line-height:20px; text-indent: 0px; }\u003c/style\u003e\u003cdiv class\u003d\"pro_desc\"\u003e\n \u003cp\u003eThe pollution of the earth is so serious that people can not survive any more. Fortunately, people have found a new planet that maybe has life, and we call it \"Pandora Planet\".\u003c/p\u003e\n \u003cp\u003e\u003c/p\u003e\n \u003cp\u003eLeonardo Da Vinci is the only astronaut on the earth. He will be sent to the Pandora Planet to gather some plant specimens and go back. The plant specimen is important to the people to decide whether the planet is fit to live or not.\u003c/p\u003e\n \u003cp\u003e\u003c/p\u003e\n \u003cp\u003eAssuming that Da Vinci can only move in an N×M grid. The positions of the plant specimens he wants to collect are all marked by the satellite. His task is to find a path to collect all the plant specimens and return to the spaceship. There are some savage beasts in the planet. Da Vinci can not investigate the grid with the savage beast. These grids are also marked by the satellite. In order to save time Da Vinci could only visit each grid exactly once and also return to the start grid, that is, you can not visit a grid twice except the start grid. You should note that you can choose any grid as the start grid.\u003c/p\u003e\n \u003cp\u003e\u003c/p\u003e\n \u003cp\u003eNow he wants to know the number of different paths he can collect all the plant specimens. \u003cb\u003eWe only care about the path and ignore where the start grid is, so the two paths in Figure 1 are considered as the same.\u003c/b\u003e\u003c/p\u003e \n \u003ccenter\u003e\n \u003cimg src\u003d\"CDN_BASE_URL/37134b45c4c5d7744d90ec40f556e6e2?v\u003d1620366882\"\u003e\n \u003c/center\u003e \n \u003ccenter\u003e\n Figure 1\n \u003c/center\u003e\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"pro_desc\"\u003e\n \u003cp\u003eThe first line of the input contains an integer T (T≤100), indicating the number of cases. Each case begins with a line containing two integers N and M (1≤N, M≤12), the size of the planet is N×M. Each of the following N lines contains M characters Gij(1≤i≤N, 1≤j≤M), G\u003csub\u003eij\u003c/sub\u003e denotes the status of the grid in row i and column j, where \u0027X\u0027 denotes the grid with savage beast, \u0027*\u0027 denotes the safe grid that you can decide to go or not, \u0027O\u0027 denotes the plant specimen you should collect. \u003cb\u003eWe guarantee that there are at least three plant specimens in the map.\u003c/b\u003e\u003c/p\u003e\n\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"pro_desc\"\u003e\n \u003cp\u003eFor each test case, print a line containing the test case number (beginning with 1) and the number of different paths he can collect all the plant specimens. You can make sure that the answer will fit in a 64-bit signed integer.\u003c/p\u003e\n\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e2\r\n2 2\r\nOO\r\nO*\r\n4 4\r\n***O\r\nXO**\r\n**O*\r\nXX**\r\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003eCase 1: 1\r\nCase 2: 7\r\n\u003c/pre\u003e"}}]}