AIG reaches deal to repay government