Types: n: int, s: str
Ranges: 1 ≤ n ≤ 10^9, 1 ≤ len(s) ≤ 2×10^6
Addtl Info: Sum of lengths of s in all datasets ≤ 5×10^6, Nesting depth of parentheses ≤ 1000, Input ends with line containing single zero