Get-Rich-Quick Schemes

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

문제

After falling for a large number of fake get-rich-quick schemes, Marika is in serious need for cash, and really needs a get-rich-quick scheme. Instead of listenting to the ideas of strangers, Marika asked her mathematically talented friend David for some help. David suggested the following scheme, based on a feature of certain credit cards, called cashback.

Cashback means that you earn a certain percentage of cash back on purchase you make, depending on the type of purchase. Formally, there are nn categories of merchandise. If you purchase merchandise from category ii for xx SEK, you earn p_ixp\_i \cdot x SEK back, up to some maximum limit m_im\_i in a single month. While this does not help you earn money (since p_i<1p\_i < 1), you realized that you can simply return any products you bought to the store to get the money back.

Things are made more difficult by the fact that a particular store will get suspicious if you return too many products per month. In store ii, you can buy and return merchandise for at most a_ia\_i SEK before start refusing you as a customer. Furthermore, a particular store only sells merchandise from a set of categories specific to that store. However, it has products costing any real amount of money from each category.

In order to get-rich-quick, Marika wants to earn as much money per month as possible. How much can she earn if she plans her purchases optimally?

입력

The input consists of:

  • one line with the integer nn (1n3001 \le n \le 300), the number of categories.
  • nn lines with the integers p_ip\_i and m_im\_i (0p_i<1000 \le p\_i < 100, 0m_i1090 \le m\_i \le 10^9), the cashback rate (in percent) and the maximum limit of a product. The ii'th line contains the rate and limit of the ii'th product.
  • one line with the integer ss (1s3001 \le s \le 300), the number of stores.
  • ss lines with the integers l_il\_i and a_ia\_i, followed by a_ia\_i distinct integers k_i,1,,k_i,a_ik\_{i,1}, \dots, k\_{i, a\_i}, (1l_i1091 \le l\_i \le 10^9, 1a_in1 \le a\_i \le n, 1k_i,jn1 \le k\_{i, j} \le n) The integers k_i,jk\_{i, j} on the ii'th line are the numbers of the categories sold by the ii'th store. The categories are numbered between 11 and nn in the order they are listed in the input.

출력

Output the maximum amount of money Marika can earn per month if purchasing items optimally. Your answer will be considered correct if it has a relative or absolute error of at most 10610^{-6}.