AB initio study of BeCN, MgCN, CaCN and BaCN