{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cp\u003eA newspaper columnist recently wrote a column comparing\n Disneyland’s price increases to other things in the economy;\n e.g., If gasoline were to have increased at the same rate as\n Disneyland’s admission since 1990, it would cost \u003cspan class\u003d\"tex2jax_process\"\u003e$\\$ 6.66$\u003c/span\u003e per gallon.\u003c/p\u003e\n \u003cp\u003eConsider the prices of a number of commodities over a number\n of consecutive years. There is an inflation rate (\u003cspan class\u003d\"tex2jax_process\"\u003e$\\operatorname {inflation}(x){\u0026gt;}0$\u003c/span\u003e)\n for year \u003cspan class\u003d\"tex2jax_process\"\u003e$x$\u003c/span\u003e to the next\n year (\u003cspan class\u003d\"tex2jax_process\"\u003e$x{+}1$\u003c/span\u003e). Also, each\n commodity \u003cspan class\u003d\"tex2jax_process\"\u003e$A$\u003c/span\u003e has a\n modifier (\u003cspan class\u003d\"tex2jax_process\"\u003e$\\operatorname\n {modifier}(A){\u0026gt;}0$\u003c/span\u003e) that is fixed for that commodity.\n So, for commodity \u003cspan class\u003d\"tex2jax_process\"\u003e$A$\u003c/span\u003e in\n year \u003cspan class\u003d\"tex2jax_process\"\u003e$x{+}1$\u003c/span\u003e:\u003c/p\u003e\n \u003ccenter\u003e\n \u003cspan class\u003d\"tex2jax_process\"\u003e$\\operatorname\n {price}(A,x{+}1)\\! \u003d\\! \\operatorname {price}(A,x)\\cdot\n \\operatorname {inflation}(x)\\cdot \\operatorname\n {modifier}(A)$\u003c/span\u003e\n \u003c/center\u003e\n \u003cp\u003eUnfortunately, the modifiers are unknown, and some of the\n prices and inflation rates are unknown.\u003c/p\u003e\n \u003cp\u003eGiven some inflation rates, the prices for a number of\n commodities over a number of consecutive years, and some\n queries for prices for certain commodities in certain years,\n answer the queries.\u003c/p\u003e\n \u003ch2\u003eInput\u003c/h2\u003e\n \u003cp\u003eEach test case will begin with a line with three\n space-separated integers \u003cspan class\u003d\"tex2jax_process\"\u003e$y$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1{\\le }y\\! \\le \\! 10$\u003c/span\u003e), \u003cspan class\u003d\"tex2jax_process\"\u003e$c$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1{\\le }c{\\le }100$\u003c/span\u003e), and \u003cspan class\u003d\"tex2jax_process\"\u003e$q$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1\\! \\le \\! q\\! \\le \\! y{\\cdot }c$\u003c/span\u003e),\n where \u003cspan class\u003d\"tex2jax_process\"\u003e$y$\u003c/span\u003e is the number of\n consecutive years, \u003cspan class\u003d\"tex2jax_process\"\u003e$c$\u003c/span\u003e is\n the number of commodities, and \u003cspan class\u003d\"tex2jax_process\"\u003e$q$\u003c/span\u003e is the number of queries to\n answer.\u003c/p\u003e\n \u003cp\u003eEach of the next \u003cspan class\u003d\"tex2jax_process\"\u003e$y\\! -\\!\n 1$\u003c/span\u003e lines will contain a single real number \u003cspan class\u003d\"tex2jax_process\"\u003e$r$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1.0\\! \\le \\! r\\! \\le \\! 1.5$\u003c/span\u003e, or\n \u003cspan class\u003d\"tex2jax_process\"\u003e$r\\! \u003d\\! -1.0$\u003c/span\u003e), which are\n the inflation rates. A value of \u003cspan class\u003d\"tex2jax_process\"\u003e$-1.0$\u003c/span\u003e indicates that the inflation\n rate is unknown. The first inflation rate is the change from\n year \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e to year\n \u003cspan class\u003d\"tex2jax_process\"\u003e$2$\u003c/span\u003e, the second from year\n \u003cspan class\u003d\"tex2jax_process\"\u003e$2$\u003c/span\u003e to year \u003cspan class\u003d\"tex2jax_process\"\u003e$3$\u003c/span\u003e, and so on. Known inflation rates\n will conform to the limits specified; unknown but uniquely\n determinable inflation rates may not, and are only guaranteed\n to be strictly greater than zero.\u003c/p\u003e\n \u003cp\u003eEach of the next \u003cspan class\u003d\"tex2jax_process\"\u003e$y$\u003c/span\u003e\n lines will describe one year’s prices. They will contain\n \u003cspan class\u003d\"tex2jax_process\"\u003e$c$\u003c/span\u003e space-separated real\n numbers \u003cspan class\u003d\"tex2jax_process\"\u003e$p$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1.0\\! \u0026lt;\\! p\\! \u0026lt;\\! 1\\, 000\\,\n 000.0$\u003c/span\u003e, or \u003cspan class\u003d\"tex2jax_process\"\u003e$p\\! \u003d\\!\n -1.0$\u003c/span\u003e), which indicate the price of that commodity in\n that year. A value of \u003cspan class\u003d\"tex2jax_process\"\u003e$-1.0$\u003c/span\u003e indicates that the price is\n unknown.\u003c/p\u003e\n \u003cp\u003eEach of the next \u003cspan class\u003d\"tex2jax_process\"\u003e$q$\u003c/span\u003e\n lines will contain two space-separated integers \u003cspan class\u003d\"tex2jax_process\"\u003e$a$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1\\! \\le \\! a\\! \\le \\! c$\u003c/span\u003e) and\n \u003cspan class\u003d\"tex2jax_process\"\u003e$b$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1\\! \\le \\! b\\! \\le \\! y$\u003c/span\u003e), which\n represent a query for the price of commodity \u003cspan class\u003d\"tex2jax_process\"\u003e$a$\u003c/span\u003e in year \u003cspan class\u003d\"tex2jax_process\"\u003e$b$\u003c/span\u003e. All queries will be distinct.\u003c/p\u003e\n \u003cp\u003eAll prices that can be uniquely determined will be strictly\n greater than zero and strictly less than \u003cspan class\u003d\"tex2jax_process\"\u003e$1\\, 000\\, 000.0$\u003c/span\u003e. Values for prices\n and inflation rates in the input may not be exact, but will be\n accurate to \u003cspan class\u003d\"tex2jax_process\"\u003e$10$\u003c/span\u003e decimal\n places. All real values contain no more than \u003cspan class\u003d\"tex2jax_process\"\u003e$10$\u003c/span\u003e digits after the decimal\n point.\u003c/p\u003e\n \u003ch2\u003eOutput\u003c/h2\u003e\n \u003cp\u003eProduce \u003cspan class\u003d\"tex2jax_process\"\u003e$q$\u003c/span\u003e lines of\n output. Each line should contain a single real number, which is\n the price of the given commodity in the given year, or\n \u003cspan class\u003d\"tex2jax_process\"\u003e$-1.0$\u003c/span\u003e if it cannot be\n determined. Answer the queries in the order that they appear in\n the input. Your answers will be accepted if they are within an\n absolute or relative error of \u003cspan class\u003d\"tex2jax_process\"\u003e$10^{-4}$\u003c/span\u003e.\u003c/p\u003e\n \u003ch2\u003eSample 1\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\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\u003e4 2 2\n1.3333333333\n1.2500000000\n-1\n3.00 -1\n4.00 8.00\n5.00 10.00\n-1 11.00\n2 1\n1 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6.0000000000\n5.5000000000\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}