Zadok, who was a descendant of Eleazar, and Ahimelech, who was a descendant of Ithamar, helped David to separate his descendants into two groups. Each group had certain duties.