Extremal values of the Sombor index in unicyclic and bicyclic graphs