Optimal Reinsurance And Investment Problem For An Insurer With Counterparty Risk