{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\nIn the year 2008, the 29th Olympic Games will be held in Beijing. This will signify the prosperity of China as well as becoming a festival for people all over the world.\n\u003c/p\u003e\n\n\u003cp\u003e\nThe official mascots of Beijing 2008 Olympic Games are Fuwa, which are named as Beibei, Jingjing, Haunhuan, Yingying and Nini. Fuwa embodies the natural characteristics of the four most popular animals in China -- Fish, Panda, Tibetan Antelope, Swallow -- and the Olympic Flame. To popularize the official mascots of Beijing 2008 Olympic Games, some volunteers make a PC game with Fuwa.\n\u003c/p\u003e\n\u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/120c9e5fc95669b34604945a11635080?v\u003d1713622175\"\u003e\u003c/center\u003e\n\u003cp\u003e\nAs shown in the picture, the game has a matrix of Fuwa. The player is to find out all the rectangles whose four corners have the same kind of Fuwa. You should make a program to help the player calculate how many such rectangles exist in the Fuwa matrix.\n\u003c/p\u003e\n\n\u003cp\u003e\u003cb\u003eInput\u003c/b\u003e\u003c/p\u003e\n\n\u003cp\u003e\nStandard input will contain multiple test cases. The first line of the input is a single integer \u003ci\u003eT\u003c/i\u003e (1 \u0026lt;\u003d \u003ci\u003eT\u003c/i\u003e \u0026lt;\u003d 50) which is the number of test cases. And it will be followed by \u003ci\u003eT\u003c/i\u003e consecutive test cases. \n\u003c/p\u003e\u003cp\u003e\nThe first line of each test case has two integers \u003ci\u003eM\u003c/i\u003e and \u003ci\u003eN\u003c/i\u003e (1 \u0026lt;\u003d \u003ci\u003eM\u003c/i\u003e, \u003ci\u003eN\u003c/i\u003e \u0026lt;\u003d 250), which means the number of rows and columns of the Fuwa matrix. \nAnd then there are \u003ci\u003eM\u003c/i\u003e lines, each has \u003ci\u003eN\u003c/i\u003e characters, denote the matrix. The characters -- \u0027B\u0027 \u0027J\u0027 \u0027H\u0027 \u0027Y\u0027 \u0027N\u0027 -- each denotes one kind of Fuwa.\n\u003c/p\u003e\n\n\u003cp\u003e\u003cb\u003eOutput\u003c/b\u003e\u003c/p\u003e\n\n\u003cp\u003e\nResults should be directed to standard output. The output of each test case should be a single integer in one line, which is the number of the rectangles whose four corners have the same kind of Fuwa.\n\u003c/p\u003e\n\n\u003cp\u003e\u003cb\u003eSample Input\u003c/b\u003e\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e\u003cpre\u003e2\n2 2\nBB\nBB\n5 6\nBJHYNB\nBHBYYH\nBNBYNN\nJNBYNN\nBHBYYH\n\u003c/pre\u003e\u003cp\u003e\u003c/p\u003e\n\n\u003cp\u003e\u003cb\u003eSample Output\u003c/b\u003e\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e\u003cpre\u003e1\n8\n\u003c/pre\u003e\u003cp\u003e\u003c/p\u003e\n"}}]}