added solution for opened/closed brackets generation