A two-step process of galaxy formation is presented. As objects generated first, we consider quasars (QSOs) formed at the cosmological redshift z=4-10. The cooled shells at the shock fronts generated by QSO explosions are split into galaxies of the mass 1010-11 Msun. Clusters of galaxies are formed at the collision of the cold shells, suggesting the large-scale shell-like or chain-like distributions of galaxies. We can explain the masses, sizes, and space densities of galaxies and clusters of galaxies.