Let x, y, and z all exceed 1, and let w be a positive number such that \log_x w = 24, \log_x yx = 40, and \log_{xy^2} zw = 12. Find \log_z w.