# Programming contests

## DEIK Regionális Programozó Csapatverseny, középiskolai kategória, 2019. december 8.

December 8, 2019 10:15 AM – December 8, 2019 3:15 PM

# Code Air

Nowadays, most airlines determine the price of their tickets dynamically. The amount passengers have to pay for a journey may depend on the date of purchase, the load factor of the selected flight, and even the chosen seat.

Code Air is operating aircraft of different types, but there are exactly six seats in a row in each aircraft. However, the lengths of the aircraft (and thus, the number of rows) vary from type to type, and so do the positions of emergency exit row seats, which provide more generous legroom. Rows are numbered from the front of the plane, and columns (seats in a row) are labeled with a letter from A to F.

Unfortunately, the programmers of the airline have gone on strike, so you are asked to implement the sales algorithm.

## Input Specification

The first line of the input contains four integers:

• the base price of tickets B,
• the amount of ticket price increase D after each ticket sale (each ticket costs D more than the previous one),
• the extra cost W for window seats (columns A and F),
• and the extra cost L for the seats with extra legroom (emergency exit row seats).

The second line contains two integers: the number of rows R and the number of emergency exit rows E. The third line consists of E positive integers, the numbers of the emergency exit rows. Each of the remaining lines of the input contains the identifier of a purchased seat in the form SO, where S is the number of a valid row, and O is the valid label of the selected column. The values read from the input and computed during the calculations all fit in a 32-bit signed integer.

## Output Specification

The first line of the output should contain the total income after the ticket sales. This is followed by as many lines as the number of purchases. These lines are of the form seat`:` amount, where seat is the identifier of the purchased seat, and amount is the price of the ticket to be paid by the passenger.

## Sample Input

1. `20000 700 2000 5000`
2. `35 4`
3. `1 2 17 18`
4. `23A`
5. `35B`
6. `1A`
7. `1C`
8. `5E`
1. `121000`
2. `23A: 22000`
3. `35B: 20700`
4. `1A: 28400`
5. `1C: 27100`
6. `5E: 22800`