Electronic structure and spectra of molecules of boron and aluminium monocarbides