Welcome to ZOJ
 Problem Sets Information Select Problem Runs Ranklist
ZOJ Problem Set - 3564
Stock I

Time Limit: 2 Seconds      Memory Limit: 65536 KB

The capital stock (or just stock) of a business entity represents the original capital paid into or invested in the business by its founders. It serves as a security for the creditors of a business since it cannot be withdrawn to the detriment of the creditors. Stock is distinct from the property and the assets of a business which may fluctuate in quantity and value.

The only key to be success in the stock is buying at a low price and selling at a high price. There are a lot of technical terms. But in this problem, you should only know something following.

• Ticker Symbol: Each stock has its own code with six digits, such as 600000 for Shanghai Pudong Development Bank. Considering two markets in China, the code starts with 6 is for Shanghai Market, 0 is for Shenzhen Market.
• Stamp Duty: When you sell out your stock, you should pay 0.1% of turnover to the government as stamp duty.
• Fee: When you buy in or sell out your stock, you should pay 0.3% of turnover to the brokerage as the fee. Each transaction should pay 5 yuan at least.
• Transfer Fee: When you buy in or sell out your stock in Shanghai Market, you should pay 1 yuan for each 1000 shares, and the part of less than 1000 shares should be calculated as 1000 shares
• Unit Price: The smallest unit price of stock is 0.01 yuan each share.
• Dividend Issue: If a stock has an operation of dividend by a coefficient D before the opening bell, you will get D yuan cash each 10 shares (ignore the part of which less than 10 shares), but 10% of these cash will be paid to government. The price auto minus D/10 yuan each share.
• Scrip Issue: If a stock has an operation of scrip by a coefficient S before the opening bell, you will get S shares each 10 shares (ignore the part of which less than 10 shares). The price auto divided by (10+S)/10 each share.
• Unit Share: The smallest unit of share is 1 share. If some operation will result in less than 1 share, this part will round to signal digit (zero or one share).

SXSTAR has bought a stock with N shares at P price each stock. Because of the Dividend Issue and Scrip Issue, the price has changed a lot. He wants to know the lowest price to sell them out at which he will not lose money.

Input

There are several test cases (<=200). You should process to the end of input. For each test case, there are two parts. The first part has two lines. The first line has two integers N (0 <= N <= 1000000) and Ticker Symbol (indicates the code of stock SXSTAR has bought). The second line has one real number P (0 < P <= 100000). The first line of the second part has only one integer M (0 <= M <= 200). Then followed by M lines. Each line has a character CH (CH='D' means Dividend Issue; CH='S' means Scrip Issue) and a real number C (0 <= C <= 100000, indicates the corresponding coefficient). All these operations are listed in time order.

Output

For each case, you should print a single line with the number of the lowest price to sell them out at which he will not lose money after all the operation given. Your answer should include two decimal places as the definition of Unit Price. Data ensure that the final answer is positive.

Sample Input

```10000 000001
11
0
10000 000002
22
1
S 10
```

Sample Output

```11.08
11.08
```

Author: SHEN, Xin
Contest: ZOJ Monthly, December 2011
Submit    Status