Mario Pasalic scored with one minute remaining as nine-man AC Milan ended their crisis with an astonishing 1-0 Serie A victory at Bologna.