THE MAIN SEQUENCES OF STAR-FORMING GALAXIES AND ACTIVE GALACTIC NUCLEI AT HIGH REDSHIFT