{"task": {"agent_timeout": 600, "task": "1157", "verifier_timeout": 7200, "instruction": "Please implement a Python 3 solution to the below problem.\nReason through the problem and:\n1. Restate the problem in plain English\n2. Conceptualize a solution first in plain English\n3. Write a pseudocode solution\n4. Save your solution as solution.py\nNo outside libraries are allowed.\n\n[BEGIN PROBLEM]\nBessie the cow is trying to walk from her favorite pasture back to her barn.\n\nThe pasture and farm are on an $N \\times N$ grid ($2 \\leq N \\leq 50$), with her\npasture in the top-left corner and the barn in the bottom-right corner. Bessie\nwants to get home as soon as possible, so she will only walk down and to the\nright. There are haybales in some locations that Bessie cannot walk through; she\nmust walk around them.\n\nBessie is feeling a little tired today, so she wants to change the direction she\nwalks at most $K$ times ($1 \\leq K \\leq 3$) .\n\nHow many distinct paths can Bessie walk from her favorite pasture to the barn?\nTwo paths are distinct if Bessie walks in a square in one path but not in the\nother.\n\nINPUT FORMAT (input arrives from the terminal / stdin):\nThe input for each test case contains $T$ sub-test cases, each describing a\ndifferent farm and each of which must be  answered correctly to pass the full\ntest case.  The first line of input  contains $T$ ($1 \\leq T \\leq 50$).  Each of\nthe $T$ sub-test cases follow.\n\nEach sub-test case starts with a line containing $N$ and $K$. \n\nThe next $N$ lines each contain a string of $N$ characters. Each character is\neither $\\texttt{.}$ if it is empty or $\\texttt{H}$ if it has a haybale. It is\nguaranteed the top-left and bottom-right corners of the farm will not contain\nhaybales.\n\nOUTPUT FORMAT (print output to the terminal / stdout):\nOutput $T$ lines, the $i$th line containing the number of distinct paths Bessie\ncan take in the $i$th sub-test case.\n\nSAMPLE INPUT:\n7\n3 1\n...\n...\n...\n3 2\n...\n...\n...\n3 3\n...\n...\n...\n3 3\n...\n.H.\n...\n3 2\n.HH\nHHH\nHH.\n3 3\n.H.\nH..\n...\n4 3\n...H\n.H..\n....\nH...\nSAMPLE OUTPUT: \n2\n4\n6\n2\n0\n0\n6\n\nWe'll denote Bessie's possible paths as strings of D's and R's, indicating that\nBessie moved either down or right, respectively.\n\nIn the first sub-test case, Bessie's two possible walks are DDRR and RRDD.\n\nIn the second sub-test case, Bessie's four possible walks are DDRR, DRRD, RDDR,\nand RRDD.\n\nIn the third sub-test case, Bessie's six possible walks are DDRR, DRDR, DRRD,\nRDDR, RDRD, and RRDD.\n\nIn the fourth sub-test case, Bessie's two possible walks are DDRR and RRDD.\n\nIn the fifth and sixth sub-test cases, it is impossible for Bessie to walk back\nto the barn.\n\nIn the seventh sub-test case, Bessie's six possible walks are DDRDRR, DDRRDR,\nDDRRRD, RRDDDR, RRDDRD, and RRDRDD.\n\nSCORING:\nTest case 2 satisfies $K = 1$.Test cases 3-5 satisfy $K = 2$.Test cases 6-10 satisfy $K = 3$.\n\n\nProblem credits: Nick Wu\n\n[END PROBLEM]\n", "memory": "2048m", "runnable": false, "difficulty": "medium", "language": "", "cpus": 1, "instruction_truncated": false, "category": "python_programming", "compose": false, "has_solution": true, "oracle": null, "docker_image": "", "taskset": "usaco", "tags": ["python", "programming", "usaco"]}, "runs": []}