Gamma rays from accreting matter onto collapsed objects