Nitrogen substitution of carbon in graphite: Structure evolution toward molecular forms