{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv\u003e\n \u0026nbsp;Flip game is played on a rectangular \n \u003cspan\u003e4x4\u003c/span\u003e field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the other one is black and each piece is lying either it\u0027s black or white side up. Each round you flip 3 to 5 pieces, thus changing the color of their upper side from black to white and vice versa. The pieces to be flipped are chosen every round according to the following rules:\n \u003cbr\u003e \n \u003col\u003e \n \u003cli\u003e Choose any one of the 16 pieces.\u003c/li\u003e \n \u003cli\u003e Flip the chosen piece and also all adjacent pieces to the left, to the right, to the top, and to the bottom of the chosen piece (if there are any).\u003c/li\u003e \n \u003c/ol\u003e \n \u003cbr\u003e \n \u003cimg align\u003d\"right\" src\u003d\"http://7xjob4.com1.z0.glb.clouddn.com/14b4b3ec0b5261bea3a5ad9f1313252c\"\u003eConsider the following position as an example:\n \u003cbr\u003e \n \u003cbr\u003e \n \u003cspan\u003ebwbw\u003c/span\u003e\n \u003cbr\u003e \n \u003cspan\u003ewwww\u003c/span\u003e\n \u003cbr\u003e \n \u003cspan\u003ebbwb\u003c/span\u003e\n \u003cbr\u003e \n \u003cspan\u003ebwwb\u003c/span\u003e\n \u003cbr\u003e Here \"b\" denotes pieces lying their black side up and \"w\" denotes pieces lying their white side up. If we choose to flip the \n \u003cspan\u003e1st\u003c/span\u003e piece from the \n \u003cspan\u003e3rd\u003c/span\u003e row (this choice is shown at the picture), then the field will become:\n \u003cbr\u003e \n \u003cbr\u003e \n \u003cspan\u003ebwbw\u003c/span\u003e\n \u003cbr\u003e \n \u003cspan\u003ebwww\u003c/span\u003e\n \u003cbr\u003e \n \u003cspan\u003ewwwb\u003c/span\u003e\n \u003cbr\u003e \n \u003cspan\u003ewwwb\u003c/span\u003e\n \u003cbr\u003e The goal of the game is to flip either all pieces white side up or all pieces black side up. You are to write a program that will search for the minimum number of rounds needed to achieve this goal.\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv\u003e\n The input consists of 4 lines with 4 characters \"w\" or \"b\" each that denote game field position.\n\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv\u003e\n Write to the output file a single integer number - the minimum number of rounds needed to achieve the goal of the game from the given position. If the goal is initially achieved, then write 0. If it\u0027s impossible to achieve the goal, then write the word \"Impossible\" (without quotes).\n\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e\r\n\u003cspan\u003ebwwb\u003c/span\u003e\r\n\u003cspan\u003ebbwb\u003c/span\u003e\r\n\u003cspan\u003ebwwb\u003c/span\u003e\r\n\u003cspan\u003ebwww\u003c/span\u003e\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e\r\n4\r\n\u003c/pre\u003e"}}]}