Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(input) {

	var text = input.split("\n")[1]

	var p = /\(([\[\]]*?)\)|([\[\]\)]*?)\)|\(([\[\]\(]*)/

	while( p.test(text) )
		text = text.replace(p, "[$1$2$3]")

	console.log(text.replace(/\[/g, "(").replace(/\]/g, ")"))

}