Earth materials

Why can fossils in sedimentary rocks help reconstruct ancient environments?