Use a monoid
HW 6, Exercise 8