Relative stability of hydrogenated nanodiamond and nanographite from density function theory