Ab Initio Study of Boron- and Nitrogen-Doped Graphene and Carbon Nanotubes Functionalized with Carboxyl Groups