We use very deep spectra obtained with the Ultraviolet-Visual Echelle Spectrograph at the Very Large Telescope to derive physical conditions and chemical abundances of four H II regions of the Large Magellanic Cloud (LMC) and four H II regions of the Small Magellanic Cloud (SMC). The observations cover the spectral range 3100-10400 Å with a spectral resolution of Δλ ≥ λ/11600, and we measure 95-225 emission lines in each object. We derive ionic and total abundances of O, N, S, Ne, Ar, Cl, and Fe using collisionally excited lines. We find average values of 12 + log (O/H) = 8.37 in the LMC and 8.01 in the SMC, with standard deviations of σ = 0.03 and 0.02 dex, respectively. The S/O, Ne/O, Ar/O, and Cl/O abundance ratios are very similar in both clouds with σ = 0.02-0.03 dex, which indicates that the chemical elements are well mixed in the interstellar medium of each galaxy. The LMC is enhanced in N/O by ~0.20 dex with respect to the SMC, and the dispersions in N/O, σ = 0.05 dex in each cloud, are larger than those found for the other elements. The derived standard deviations would be much larger for all the abundance ratios, up to 0.20 dex for N/O, if previous spectra of these objects were used to perform the analysis. Finally, we find a wide range of iron depletions in both clouds with more than 90 per cent of the iron atoms deposited on to dust grains in most objects.