Quantum-chemical study of quasi-one-dimensional vanadium and niobium sulfides with Peierls distortion