The development of a text editor is a hard problem. You need to implement an extra module for brackets coloring in text.
Your editor consists of a line with infinite length and cursor, which points to the current character. Please note that it points to only one of the characters (and not between a pair of characters). Thus, it points to an index character. The user can move the cursor left or right one position. If the cursor is already at the first (leftmost) position, then it does not move left.
Initially, the cursor is in the first (leftmost) character.
Also, the user can write a letter or brackets (either (, or )) to the position that the cursor is currently pointing at. A new character always overwrites the old value at that position.
Your editor must check, whether the current line is the correct text. Text is correct if the brackets in them form the correct bracket sequence.
Formally, correct text (CT) must satisfy the following rules:
Examples of correct texts: hello(codeforces), round, ((i)(write))edi(tor)s, ( me). Examples of incorrect texts: hello)oops(, round), ((me).
The user uses special commands to work with your editor. Each command has its symbol, which must be written to execute this command.
The correspondence of commands and characters is as follows:
For a complete understanding, take a look at the first example and its illustrations in the note below.
You are given a string containing the characters that the user entered. For the brackets coloring module's work, after each command you need to:
If two pairs of brackets are nested (the first in the second or vice versa), then these pairs of brackets should be painted in different colors. If two pairs of brackets are not nested, then they can be painted in different or the same colors. For example, for the bracket sequence ()(())()() the least number of colors is $$$2$$$, and for the bracket sequence (()(()())())(()) — is $$$3$$$.
Write a program that prints the minimal number of colors after processing each command.
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^6$$$) — the number of commands.
The second line contains $$$s$$$ — a sequence of commands. The string $$$s$$$ consists of $$$n$$$ characters. It is guaranteed that all characters in a string are valid commands.
In a single line print $$$n$$$ integers, where the $$$i$$$-th number is:
11 (RaRbR)L)L(
-1 -1 -1 -1 -1 -1 1 1 -1 -1 2
11 (R)R(R)Ra)c
-1 -1 1 1 -1 -1 1 1 1 -1 1
NoteIn the first example, the text in the editor will take the following form:
(
^ (
^ (a
^ (a
^ (ab
^ (ab
^ (ab)
^ (ab)
^ (a))
^ (a))
^ (())
^