Single-atom logic for heterocycle editing