Optimal risk sharing and dividend strategies under interacting external default risk