395. "Binary Cat" Club

Time limit per test: 0.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard



"Binary Cat" club is extremely popular among Berland citizens. Club is a pretty crowded place and some unpleasant incidents happen there from time to time. So the club management monitors their visitors thoroughly. Usual measures like "face control" are accompanied with so-called "logging". Each time visitor enters the club, the "" record is added to the log. is the name of the person who just entered. Similarly the "" record is added when a person leaves the club. From time to time security adds records like "", where is the number of the club guests present at the moment. At the moment the club was opened, it was empty. All records are added in the chronological order. If a person entered and exited the club several times, all these events are recorded. At the moment the club is closed some guests may still be there to participate in after-party. The club is big enough to contain any number of visitors at the same time.

However all this security precautions didn't help. Recently a big scandal happened in the club. The scandal was about the discussion of implementation details of Malhotra-Kumar-Maheshwari algorithm. Police requested the log of the events for the night of the incident from the club management. During logs archive inspection club personnel found out that logs for the night of the incident are not complete due to technical reasons. Some of the records in the log are missing, but all the remaining records are preserved in their original order.

Now club management wants to "polish" the log a bit, so that it looks plausible. They believe that the log looks plausible, if for the sequence of records in the log there is a sequence of actions which can happen in real life. For example, if the log contains a record that somebody leaves the club, the record about the same person entering the club should be present earlier in the log. Or, a person cannot enter the club the second time, if she did not leave the club after the first entry. The records "" should represent the actual number of guests in the club.

The club managers would like to add some random records to the log in such a way, that the relative order of existing records is preserved and the final log is plausible. Your task is to find minimal possible number of records to be added to the log and to create one of the variants of "polished" log.

Input
The first line of the input contains integer number N (1 ≤ N ≤ 200), where N is the number of existing records in the log. Following N lines contain records of the log, one per line. Each record has the form "", "" and "". The value of is between 0 and 100, inclusive. All names have length between 1 and 16 characters and consist of only lowercase Latin letters.

Output
Write in the first line M, the minimal possible number of records in "polished" log. The following M lines should contain the records of the "polished" log in the same format they were given in the input. The limitations on the format of names and the number of visitors remain. If there are several solutions, choose any of them.

Example(s)
sample input
sample output
3
+ andrew
+ ilya
- mike
4
+ andrew
+ ilya
+ mike
- mike

sample input
sample output
1
= 2
3
+ first
+ second
= 2

sample input
sample output
3
- silentbob
- silentbob
= 1
6
+ silentbob
- silentbob
+ silentbob
- silentbob
+ silentbob
= 1




Online Contester Team © 2002 - 2010. All rights reserved.