Catalyzes the pyrimidine ring opening between N-3 and C-4 by an unusual flavin hydroperoxide-catalyzed mechanism, adding oxygen atoms in the process to yield ureidoacrylate peracid, that immediately reacts with FMN forming ureidoacrylate and FMN-N(5)-oxide. The FMN-N(5)-oxide reacts spontaneously with NADH to produce FMN. Requires the flavin reductase RutF to regenerate FMN in vivo. FMNH2 + NADH + O2 + uracil = (Z)-3-ureidoacrylate + FMN + H(+) + H2O + NAD(+) FMNH2 + NADH + O2 + thymine = (Z)-2-methylureidoacrylate + FMN + H(+) + H2O + NAD(+) Belongs to the NtaA/SnaA/DszA monooxygenase family. RutA subfamily.