import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } void calc(string s) { auto ans = new int[s.length]; int[] stack; for (int i = 0; i < s.length; i++) { switch (s[i]) { case '(': stack ~= i; break; case ')': assert(stack.length > 0); int p = stack[$-1]; stack = stack[0..$-1]; ans[i] = p; ans[p] = i; break; default: break; } } foreach (p; ans) writeln(p + 1); } void main() { readint; auto s = readln.chomp; calc(s); }