Measurement of the decay amplitudes of B0 → J/ψK*0 and Bs0 → J/ψφ decays