AMENDED AND RESTATED TERM LOAN AGREEMENT Dated as of August 1, 2017 by and among SENIOR HOUSING PROPERTIES TRUST,