DICE: Discrete Inversion Enabling Controllable Editing for Multinomial Diffusion and Masked Generative Models