{"task": {"agent_timeout": 600, "task": "1277", "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]\n\nBecause Bessie is bored of playing with her usual text string where the only\ncharacters are 'C,' 'O,' and 'W,' Farmer John gave her $Q$ new strings\n($1 \\leq Q \\leq 100$), where the only characters are 'M' and 'O.' Bessie's\nfavorite word out of the characters 'M' and 'O' is obviously \"MOO,\" so she wants\nto turn each of the $Q$ strings into \"MOO\" using the following operations:\n\nReplace either the first or last character with its opposite (so that 'M'\nbecomes 'O' and 'O' becomes 'M'). Delete either the first or last character. \nUnfortunately, Bessie is lazy and does not want to perform more operations than\nabsolutely necessary. For each string, please help her determine the minimum\nnumber of operations necessary to form \"MOO\" or output $-1$ if this is\nimpossible. \n\nINPUT FORMAT (input arrives from the terminal / stdin):\nThe first line of input contains the value of $Q$.\n\nThe next $Q$ lines of input each consist of a string, each of its characters\neither 'M' or 'O'. Each string has at least 1 and at most 100 characters.\n\nOUTPUT FORMAT (print output to the terminal / stdout):\nOutput the answer for each input string on a separate line.\n\nSAMPLE INPUT:\n3\nMOMMOM\nMMO\nMOO\nSAMPLE OUTPUT: \n4\n-1\n0\n\nA sequence of $4$ operations transforming the first string into \"MOO\" is as\nfollows:\n\n\nReplace the last character with O (operation 1)\nDelete the first character (operation 2)\nDelete the first character (operation 2)\nDelete the first character (operation 2)\n\nThe second string cannot be transformed into \"MOO.\" The third string is already\n\"MOO,\" so no operations need to be performed.\n\nSCORING:\nInputs 2-4: Every string has length at most $3$.Inputs 5-11: No additional constraints.\n\n\nProblem credits: Aryansh Shrivastava\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": []}