Fill all other indexes with remaining characters
idx = 0 ; NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( sieve [ i ] ) : NEW_LINE INDENT ans [ i ] = v [ idx ] [ 1 ] ; NEW_LINE v [ idx ] [ 0 ] -= 1 ; NEW_LINE DEDENT DEDENT