Role of the rationals in the Markov and Lagrange spectra