Afghanistan: Nearly 40 die in funeral, hospital attacks