And dinosaurs are reptiles, mammals and reptiles are amniotes [1], both amniotes and amphibians are tetrapods, tetrapods are actually fish[2], and there's no such thing as a fish[3]!
[1] https://en.m.wikipedia.org/wiki/Amniote
[1] https://en.m.wikipedia.org/wiki/Amniote
But we're more closely related to sharks than either is to the jawless fishes like the hagfish. The hagfish are just plain weird.