Cabbage

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

<<The hungry>> Children of the Volga Plain are known to be very fond of pickled cabbage. However, each of them has a favorite cabbage variety and would not eat any other kind. The preferences seem to be random. Different Children can like either different or the same varieties of cabbage. To make everyone happy, portions must be the same. Alchen, the chief, wants to make the portions as big as possible.

Initially, Alchen has a certain stock of each of the cabbage varieties, and a certain sum of money. He can buy extra cabbage with this money, a different amount of each variety. The prices are well-known. However, he won't be able to sell the cabbage he's already got.

Help Alchen to figure out the best portion sizes for his proteges.

입력

The first line of the input file contains a single integer TT --- the number of test cases(1T1001 \le T \le 100). It is followed by TT blocks.

The first line of a block contains three integers: NN --- the number of pickled cabbage varieties(1N1051 \le N \le 10^5), MM --- the number of the hungry Children(1M1051 \le M \le 10^5), SS --- the sum of money allocated for buying extra pickled cabbage(1S1091 \le S \le 10^9).

The second line of a block contains MM integers T_iT\_i, where T_iT\_i is the number of the pickled cabbage variety preferred by the ii-th Child of the Volga Plain (1T_iN1 \le T\_i \le N).

Each of the following NN lines contains two integers: A_iA\_i --- the initially available amount of cabbage of the ii-th variety, in kilograms (0A_i1040 \le A\_i \le 10^4), and C_iC\_i --- the price of a kilogram of cabbage of this variety (1C_i1041 \le C\_i \le 10^4).

The sum MM for all test cases is smaller than or equals 10510^5, and the sum NN for all test cases is smaller than or equals 10510^5.

출력

The output file must contain TT lines, and the ii-th line must contain the answer to the ii-th test case. The answer to a test is the maximum possible portion size, in kilograms.

The absolute or relative error of each answer must be smaller than or equal 10910^{-9}.