And Yet Another Bracket Sequence

CodeForces - 524F