Origins of Fermi-level pinning on GaN and InN polar and nonpolar surfaces