#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 NN 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 −1-1 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 NN, 1≤N≤1061\le N\le 10^6.

The second line contains the string of NN valid commands.

Output

Print NN integers on one line; the ii-th integer is the result after the first ii commands.

Subtasks

  • Subtask 1 — 20%: 1≤N≤501\le N\le 50.
  • Subtask 2 — 30%: 1≤N≤50001\le N\le 5000.
  • Subtask 3 — 50%: 1≤N≤1061\le N\le 10^6.

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.