This reaction is an example of electrophilic aromatic substitution. In alkaline medium, phenol generates phenoxide ion which is more electron rich than phenol and hence more reactive for electrophilic attack. The electrophile in this reaction is aryldiazonium cation. Stronger the electrophile faster is the reaction. p-Nitrophenyldiazonium cation is a stronger electrophile than p-toluene diazonium cation. Therefore, it couples preferentially with phenol.