Molecular structure of highly excited resonant states in $^24\mathrmMg$ and the corresponding $^8\mathrmBe+^16\mathrmO$ and $^12\mathrmC+^12\mathrmC$ decays