{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\r\n\tA potentiometer, or \u003cspan data-scayt_word\u003d\"potmeter\" data-scaytid\u003d\"1\"\u003epotmeter\u003c/span\u003e for short, is an electronic device with a variable electric resistance. It has two terminals and some kind of control mechanism (often a dial, a wheel or a slide) with which the resistance between the terminals can be adjusted from zero (no resistance) to some maximum value. Resistance is measured in Ohms, and when two or more resistors are connected in series (one after the other, in a row), the total resistance of the array is the sum of the \u003cspan data-scayt_word\u003d\"resistances\" data-scaytid\u003d\"2\"\u003eresistances\u003c/span\u003e of the individual resistors.\u003c/p\u003e\r\n\u003cp style\u003d\"text-align:justify\"\u003e\r\n\tIn this problem we will consider an array of \u003cb\u003eN\u003c/b\u003e \u003cspan data-scayt_word\u003d\"potmeters\" data-scaytid\u003d\"9\"\u003epotmeters\u003c/span\u003e, numbered \u003cb\u003e1\u003c/b\u003e to \u003cb\u003eN\u003c/b\u003e from left to right. The left terminal of some \u003cspan data-scayt_word\u003d\"potmeter\" data-scaytid\u003d\"3\"\u003epotmeter\u003c/span\u003e numbered \u003cb\u003ex\u003c/b\u003e is connected to the right terminal of \u003cspan data-scayt_word\u003d\"potmeter\" data-scaytid\u003d\"4\"\u003epotmeter\u003c/span\u003e \u003cb\u003ex-1\u003c/b\u003e, and its right terminal to the left terminal of \u003cspan data-scayt_word\u003d\"potmeter\" data-scaytid\u003d\"5\"\u003epotmeter\u003c/span\u003e \u003cb\u003ex+1\u003c/b\u003e. The left terminal of \u003cspan data-scayt_word\u003d\"potmeter\" data-scaytid\u003d\"6\"\u003epotmeter\u003c/span\u003e \u003cb\u003e1\u003c/b\u003e and the right terminal of \u003cspan data-scayt_word\u003d\"potmeter\" data-scaytid\u003d\"7\"\u003epotmeter\u003c/span\u003e \u003cb\u003eN\u003c/b\u003e are not connected.\u003c/p\u003e\r\n\u003cp style\u003d\"text-align:justify\"\u003e\r\n\tInitially all the \u003cspan data-scayt_word\u003d\"potmeters\" data-scaytid\u003d\"10\"\u003epotmeters\u003c/span\u003e are set to some value between 0 and 1000 Ohms. Then we can do two things:\u003c/p\u003e\r\n\u003cul type\u003d\"disc\"\u003e\r\n\t\u003cli class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\t\tSet one of the \u003cspan data-scayt_word\u003d\"potmeters\" data-scaytid\u003d\"11\"\u003epotmeters\u003c/span\u003e to another value.\u003c/li\u003e\r\n\t\u003cli class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\t\tMeasure the resistance between two terminals anywhere in the array.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003ch5 style\u003d\"text-align:justify\"\u003e\r\n\t\u003cspan class\u003d\"StyleArial16pt\"\u003e\u003cspan style\u003d\"font-size:16.0pt\"\u003eInput\u003c/span\u003e\u003c/span\u003e\u003c/h5\u003e\r\n\u003cp class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\tThe input consists less than 3 cases. Each case starts with \u003cb\u003eN\u003c/b\u003e, the number of \u003cspan data-scayt_word\u003d\"potmeters\" data-scaytid\u003d\"12\"\u003epotmeters\u003c/span\u003e in the array, on a line by itself. \u003cb\u003eN\u003c/b\u003e can be as large as 200000. Each of next N lines contains one numbers between 0 and 1000, the initial \u003cspan data-scayt_word\u003d\"resistances\" data-scaytid\u003d\"8\"\u003eresistances\u003c/span\u003e of the \u003cspan data-scayt_word\u003d\"potmeters\" data-scaytid\u003d\"13\"\u003epotmeters\u003c/span\u003e in the order \u003cb\u003e1\u003c/b\u003e to \u003cb\u003eN\u003c/b\u003e. Then follow a number of actions, each on a line by itself. The number of actions can be as many as 200000. There are three types of action:\u003c/p\u003e\r\n\u003cul type\u003d\"disc\"\u003e\r\n\t\u003cli class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\t\t\u0026quot;S x r\u0026quot; - set \u003cspan data-scayt_word\u003d\"potmeter\" data-scaytid\u003d\"14\"\u003epotmeter\u003c/span\u003e \u003cb\u003ex\u003c/b\u003e to \u003cb\u003er\u003c/b\u003e Ohms. \u003cb\u003ex\u003c/b\u003e is a valid \u003cspan data-scayt_word\u003d\"potmeter\" data-scaytid\u003d\"15\"\u003epotmeter\u003c/span\u003e number and \u003cb\u003er\u003c/b\u003e is between 0 and 1000.\u003c/li\u003e\r\n\t\u003cli class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\t\t\u0026quot;M x y\u0026quot; - measure the resistance between the left terminal of \u003cspan data-scayt_word\u003d\"potmeter\" data-scaytid\u003d\"16\"\u003epotmeter\u003c/span\u003e \u003cb\u003ex\u003c/b\u003e and the right terminal of \u003cspan data-scayt_word\u003d\"potmeter\" data-scaytid\u003d\"17\"\u003epotmeter\u003c/span\u003e \u003cb\u003ey\u003c/b\u003e. Both numbers will be valid and \u003cb\u003ex\u003c/b\u003e is smaller than or equal to \u003cb\u003ey\u003c/b\u003e.\u003c/li\u003e\r\n\t\u003cli class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\t\t\u0026quot;END\u0026quot; - end of this case. Appears only once at the end of a list of actions.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cp class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\tA case with \u003cb\u003eN\u003c/b\u003e\u003d0 signals the end of the input and it should not be processed.\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch4 style\u003d\"text-align:justify\"\u003e\r\n\t\u003cspan class\u003d\"StyleArial16pt\"\u003e\u003cspan style\u003d\"font-size:16.0pt\"\u003eOutput \u003c/span\u003e\u003c/span\u003e\u003c/h4\u003e\r\n\u003cp class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\tFor each case in the input produce a line \u0026quot;Case n:\u0026quot;, where n is the case number, starting from 1.\u003cbr /\u003e\r\n\tFor each measurement in the input, output a line containing one number: the measured resistance in Ohms. The actions should be applied to the array of \u003cspan data-scayt_word\u003d\"potmeters\" data-scaytid\u003d\"18\"\u003epotmeters\u003c/span\u003e in the order given in the input.\u003cbr /\u003e\r\n\tPrint a blank line between cases.\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\t\u003cb\u003eWarning: Input Data is pretty big (~� 8 MB) so use faster IO.\u003c/b\u003e\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cbr clear\u003d\"all\" style\u003d\"page-break-before:always\" /\u003e\r\n\u003ch1 align\u003d\"left\" style\u003d\"text-align:left\"\u003e\r\n\t\u003cb\u003e\u003cspan style\u003d\"font-size:16.0pt;\r\nfont-family:Arial;font-style:normal\"\u003eSample \u003cspan data-scayt_word\u003d\"Input����������������������������\" data-scaytid\u003d\"19\"\u003eInput����������������������������\u003c/span\u003e Output for Sample Input\u003c/span\u003e\u003c/b\u003e\u003c/h1\u003e\r\n\u003ctable border\u003d\"1\" cellpadding\u003d\"0\" cellspacing\u003d\"0\" class\u003d\"MsoNormalTable\" style\u003d\"background:#CCCCCC;border-collapse:collapse;border:none\"\u003e\r\n\t\u003ctbody\u003e\r\n\t\t\u003ctr\u003e\r\n\t\t\t\u003ctd style\u003d\"width:3.2in;border:solid windowtext 1.0pt;\r\n padding:0in 5.4pt 0in 5.4pt\" valign\u003d\"top\" width\u003d\"307\"\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e3\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e100\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e100\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e100\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003eM 1 1\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003eM 1 3\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003eS 2 200\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003eM 1 2\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003eS 3 0\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003eM 2 3\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003eEND\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e10\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e1\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e2\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e3\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e4\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e5\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e6\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e7\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e8\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e9\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e10\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003eM 1 10\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003eEND\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e0\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cpre\u003e\r\n\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt\"\u003e\u0026nbsp;\u003c/span\u003e\u003c/b\u003e\u003c/pre\u003e\r\n\t\t\t\u003c/td\u003e\r\n\t\t\t\u003ctd style\u003d\"width:231.85pt;border:solid windowtext 1.0pt;\r\n border-left:none;padding:0in 5.4pt 0in 5.4pt\" valign\u003d\"top\" width\u003d\"309\"\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003eCase 1:\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e100\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e300\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e300\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e200\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e\u0026nbsp;\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003eCase 2:\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\u003cb\u003e\u003cspan style\u003d\"font-size:11.0pt;font-family:\u0026quot;Courier New\u0026quot;\"\u003e55\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\u003c/td\u003e\r\n\t\t\u003c/tr\u003e\r\n\t\u003c/tbody\u003e\r\n\u003c/table\u003e\r\n\u003cdiv align\u003d\"center\" class\u003d\"MsoNormal\" style\u003d\"text-align:center\"\u003e\r\n\t\u003chr align\u003d\"center\" size\u003d\"2\" width\u003d\"100%\" /\u003e\r\n\u003c/div\u003e\r\n\u003cp class\u003d\"MsoNormal\" style\u003d\"text-align:justify\"\u003e\r\n\tProblem setter: \u003cspan data-scayt_word\u003d\"Joachim\" data-scaytid\u003d\"20\"\u003eJoachim\u003c/span\u003e \u003cspan data-scayt_word\u003d\"Wulff\" data-scaytid\u003d\"21\"\u003eWulff\u003c/span\u003e, Special Thanks: \u003cspan data-scayt_word\u003d\"Shahriar\" data-scaytid\u003d\"22\"\u003eShahriar\u003c/span\u003e \u003cspan data-scayt_word\u003d\"Manzoor\" data-scaytid\u003d\"23\"\u003eManzoor\u003c/span\u003e\u003c/p\u003e"}}]}