#SGM0000019. Trình soạn thảo (Editor)
Trình soạn thảo (Editor)
Editor
Source: Codeforces
Version: Phuoc Hung OJ Extended
Simulate an infinite editor line with a cursor. Initially the cursor points to the first position. A string of commands is given:
L: move one position left; remain at the first position if already there.R: move one position right.(or): overwrite the current position with that bracket.- a lowercase letter: overwrite the current position with that letter; letters contribute zero to bracket balance.
After each command, ignore letters and inspect the current bracket sequence. Print if it is invalid. If it is valid, print the maximum nesting depth, which equals the minimum number of colors required so that nested bracket pairs use different colors.
Input
The first line contains , .
The second line contains the string of valid commands.
Output
Print integers on one line; the -th integer is the result after the first commands.
Subtasks
- Subtask 1 — 20%: .
- Subtask 2 — 30%: .
- Subtask 3 — 50%: .
Examples
Input
11
(R)R(R)Ra)c
Output
-1 -1 1 1 -1 -1 1 1 1 -1 1
Explanation
The sample follows the operations exactly; each printed line corresponds to a query that requires output.