Cahn–Ingold–Prelog priority of CN vs CH2NH2
Each multiple bond is considered to be equivalent to an individual bond. So $\ce{-CN}$ has the same priority as (N,N,N), making it higher than (N,H,H). Read more about it here.