{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eSaruman the White and Gandalf the Grey play a game. The winner will get the Master-ring. There are rings joined into \u003ci\u003eK\u003c/i\u003e chains lying in front of the players. For each ring, the percentage of gold is known; it is an integer in the range from 1 to 100. Saruman and Gandalf make moves by turns. In each move a player chooses a ring and dematerializes it together with all the rings from the same chain that contain no more gold than the chosen ring. As a result, the chain may break up into several smaller chains,\r\nand the game is continued with the remaining chains. He who \r\ndematerializes the last ring is a winner. Gandalf moves first. Your task is to determine if Gandalf can win and if he can which ring he must choose for his first move.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe first line contains the integer \u003ci\u003eK\u003c/i\u003e,\r\n1\u0026nbsp;≤\u0026nbsp;\u003ci\u003eK\u003c/i\u003e\u0026nbsp;≤\u0026nbsp;50.\r\nEach of the next \u003ci\u003eK\u003c/i\u003e lines describes the corresponding chain in the following format: the first number is the length of the chain, which is an integer from 1 to 100, then there go the percentages of gold in the rings of this chain. The numbers in the line are separated with a space.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eOutput «S» if Saruman will win the Master-ring.\r\nOtherwise, in the first line output «G»\r\nand in the second line output two integers that describe Gandalf\u0027s first move: the number of the chain and the number of the ring in it. The chains and rings in them are numbered from 1. If there are several first moves that guarantee Gandalf\u0027s win, output the move with the minimal number of the chain, and if there are several such moves, output the move with the minimal number of the ring.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n3 1 2 1\r\n1 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eG\r\n1 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cbr\u003e\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n3 2 1 2\r\n1 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eS\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}