SPOJ Brackets

Can anybody tell me how to build segment tree for this problem?? what all properties should it contain?? I am not able to figure it out…

you can use this for reference.

//