A newspaper columnist recently wrote a column comparing
Disneyland’s price increases to other things in the economy;
e.g., If gasoline were to have increased at the same rate as
Disneyland’s admission since 1990, it would cost per gallon.
Consider the prices of a number of commodities over a number
of consecutive years. There is an inflation rate ()
for year to the next
year (). Also, each
commodity has a
modifier () that is fixed for that commodity.
So, for commodity in
year :
Unfortunately, the modifiers are unknown, and some of the
prices and inflation rates are unknown.
Given some inflation rates, the prices for a number of
commodities over a number of consecutive years, and some
queries for prices for certain commodities in certain years,
answer the queries.
Input
Each test case will begin with a line with three
space-separated integers (), (), and (),
where is the number of
consecutive years, is
the number of commodities, and is the number of queries to
answer.
Each of the next lines will contain a single real number (, or
), which are
the inflation rates. A value of indicates that the inflation
rate is unknown. The first inflation rate is the change from
year to year
, the second from year
to year , and so on. Known inflation rates
will conform to the limits specified; unknown but uniquely
determinable inflation rates may not, and are only guaranteed
to be strictly greater than zero.
Each of the next
lines will describe one year’s prices. They will contain
space-separated real
numbers (, or ), which indicate the price of that commodity in
that year. A value of indicates that the price is
unknown.
Each of the next
lines will contain two space-separated integers () and
(), which
represent a query for the price of commodity in year . All queries will be distinct.
All prices that can be uniquely determined will be strictly
greater than zero and strictly less than . Values for prices
and inflation rates in the input may not be exact, but will be
accurate to decimal
places. All real values contain no more than digits after the decimal
point.
Output
Produce lines of
output. Each line should contain a single real number, which is
the price of the given commodity in the given year, or
if it cannot be
determined. Answer the queries in the order that they appear in
the input. Your answers will be accepted if they are within an
absolute or relative error of .
Sample Input 1 |
Sample Output 1 |
4 2 2
1.3333333333
1.2500000000
-1
3.00 -1
4.00 8.00
5.00 10.00
-1 11.00
2 1
1 4
|
6.0000000000
5.5000000000
|