Engineering mathematics

A well-mixed reactor has mass M of a tracked species. Species enters at rate r_in, leaves at rate r_out, and is produced inside at rate r_gen. Which balance describes the species accumulation?