in this hospital visit what was the last id of the ward of patient 40707?
select transfers.wardid from transfers where transfers.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 40707 and admissions.dischtime is null ) and transfers.wardid is not null order by transfers.intime desc limit 1