Among the simplest covalent compounds that the second row nonmetals can form are those that result from combination with hydrogen. Based on the number of electrons in their valence shells and the octet rule, we can predict how many hydrogen atoms will be needed to combine with each of those elements. Carbon, with 4 electrons in its valence shell, will need another four electrons to fulfill the octet rule. Thus it needs to combine with 4 hydrogen atoms to form a stable compound called methane (CH4) as shown above.
Nitrogen, the next nonmetal, has 5 electrons in the valence shell, so it needs to combine with 3 hydrogen atoms to fulfill the octet rule and form a stable compound called ammonia (NH3). This leaves two electrons that cannot be used for bonding (otherwise nitrogen would have to share more than 8 electrons, which is impossible). In the ammonia molecule, these electrons are paired and unshared, meaning that they are not engaged in bonding. Such electron pairs are referred to as lone pairs, unshared electrons, or nonbonding electrons.
A similar process leads to the formation of stable hydrogen compounds for the next two nonmetals, oxygen and fluorine. We see that the water molecule contains two pairs of nonbonding electrons, and hydrogen fluoride contains three pairs.