Dispersion relations for photoproduction of K-mesons on nucleons and π-mesons on hyperons