Supplementary Materials A Algorithm details