SAS agrees union deals in face of bankruptcy fears