Minute optimization on permutations ID list