matrix chain multiplication, good