This page is still under construction.

Parts of this page are still being built. What you see may change.

Bailout Bonus

Time limit1sMemory limit128 MB

Summary
Given a list of bailed-out companies, a tax rate, and executives with company and bonus, sum the floor of the taxed fraction for executives at bailed companies.
Level

Easy2 of 10

Topics
Implementation, Hash map, Math, Brute force
Solved
No attempts yet

Problem

To keep many financial companies from collapsing, the United States government (and several other governments) bailed them out by providing multi-billion-dollar emergency loans. Afterward, several of these companies went ahead and paid their executives large performance bonuses. After a public outcry, one measure taken to recover this money for the government was to impose a hefty 95% tax on the bonuses of employees at any company that had received bailout money. Your task is to compute how much money the government recovers.

You are given a list of the companies that received bailout money and the proposed tax rate rr (such as 95%), written as an integer (in this case, 9595). You are also given a list of executives, each with their company affiliation and proposed bonus. Every executive who works for a bailed-out company must pay back an rr percent fraction of their bonus, rounded down to the nearest integer. For simplicity, executives who work for companies that were not bailed out return none of their bonus.

Input

The first line contains the number of data sets, KK. It is followed by KK data sets, each of the following form.

The first line of a data set contains four integers CC, BB, nn, and rr:

  • 1≤C≤5001 \le C \le 500 is the total number of companies.
  • 0≤B≤C0 \le B \le C is the number of those companies that were bailed out.
  • 1≤n≤100001 \le n \le 10000 is the total number of executives.
  • 0≤r≤1000 \le r \le 100 is the tax rate, in percent.

The next line contains BB integers: the indices (each between 11 and CC) of the bailed-out companies. When B=0B = 0, this line is empty. Then follow nn lines, each describing one executive. Each such line contains two integers cic_i and pip_i, where 1≤ci≤C1 \le c_i \le C is the company that executive ii works for and pip_i is the bonus that executive ii received.

Output

For each data set, first print Data Set x: on a line by itself, where xx is the number of the data set (starting from 11). On the next line, print the total amount of money the government recovers through taxes for that data set. Print a blank line between consecutive data sets.

Examples3

  1. Example 1

    Input
    2
    4 2 6 95
    1 4
    1 1000000
    3 25000
    3 102425
    4 567444
    1 150
    4 7000
    2 0 2 99
    
    1 500000
    2 500000
    
    Expected output
    Data Set 1:
    1495863
    
    Data Set 2:
    0
    
  2. Example 2

    Input
    1
    2 2 2 100
    1 2
    1 12345
    2 67890
    
    Expected output
    Data Set 1:
    80235
    
  3. Example 3

    Input
    3
    2 1 3 50
    2
    1 1000
    2 2000
    2 400
    1 1 1 10
    1
    1 55
    5 3 4 95
    2 3 5
    1 100000
    2 200
    4 5000
    5 999
    
    Expected output
    Data Set 1:
    1200
    
    Data Set 2:
    5
    
    Data Set 3:
    1139