import Control.Monad
import Data.List

insertion s = isub 0 s s ""
    where isub lv orig "" pre = pre ++ orig ++ replicate lv ')'
          isub lv orig (c:cs) pre
              | lv==0 && c==')' = isub 0 orig cs ('(':pre)
              | c==')'          = isub (lv-1) orig cs pre
              | otherwise       = isub (lv+1) orig cs pre
              

main = getLine >>= const getLine >>= putStrLn . insertion