How valence electrons change in groups and periods?