Thermodynamic stabilities of ternary metal borides: An ab initio guide for synthesizing layered superconductors