A series of nitrogen-rich molecules N6XHm, N8XHm, and N10XHm (X = B, Al, Ga, m = 1 and X = C, Si, Ge, m = 2) consisting of N3 and N5 radicals, are systematically investigated by using B3LYP and B3PW91 DFT methods. It is found that for the nitrogen-rich molecules, the structures with N3-chains (N5-ring) are more stable than those containing a N3-ring (N5-chain). This result could be well-explained by the intrinsic stability of the N3 and N5 radicals and their charge distribution in nitrogen-rich molecules. The dissociation energies further indicate that the B-doped and C-doped structures are the most stable among the molecules with three elements of group 13 and 14, respectively. Energy decomposition analysis shows the bond of boron-nitrogen is stronger than that of carbon-nitrogen. Detailed bonding analysis demonstrates that the B-N bond is determined by σ and π interactions between the B and N atoms, whereas C-N bonds by only σ interactions. These results imply that the boron atom is more suitable than the carbon atom for building the nitrogen-rich molecules studied in this article.