fun main(args:Array) { val n = readLine()!!.toInt() val cs = readLine()!!.toList().map(Char::toString) val pairs = mutableListOf>() for( start in (0..cs.size-2)) { if( cs[start] != "(" ) continue var cur = start+1 var state = 0 while(true) { if( cs[cur] == ")" ) { if( state == 0 ) { pairs.add( Pair(start, cur) ); break } else state -= 1 } else { state += 1 } cur += 1 } } val m = mutableMapOf() pairs.map { val (k,v) = it m[k+1] = v+1 m[v+1] = k+1 } (1..n).map { println( m[it] ) } }