fixed bug in on_both_sides()
make power of matrix robust
add segment tree implementing range minimum query